DART  6.6.2
SharedLibraryIkFast.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_DYNAMICS_SHAREDLIBRARYIKFAST_HPP_
34 #define DART_DYNAMICS_SHAREDLIBRARYIKFAST_HPP_
35 
37 #include "dart/dynamics/IkFast.hpp"
38 
39 namespace dart {
40 namespace dynamics {
41 
47 {
48 public:
65  const std::string& filePath,
66  const std::vector<std::size_t>& dofMap,
67  const std::vector<std::size_t>& freeDofMap,
68  const std::string& methodName = "IKFast",
69  const Analytical::Properties& properties = Analytical::Properties());
70 
71  // Documentation inherited.
72  auto clone(InverseKinematics* newIK) const
73  -> std::unique_ptr<GradientMethod> override;
74 
75 protected:
76  // Documentation inherited.
77  int getNumFreeParameters() const override;
78 
79  // Documentation inherited.
80  int* getFreeParameters() const override;
81 
82  // Documentation inherited.
83  int getNumJoints() const override;
84 
85  // Documentation inherited.
86  int getIkRealSize() const override;
87 
88  // Documentation inherited.
89  int getIkType() const override;
90 
91  // Documentation inherited.
92  bool computeIk(
93  const IkReal* targetTranspose,
94  const IkReal* targetRotation,
95  const IkReal* freeParams,
96  ikfast::IkSolutionListBase<IkReal>& solutions) override;
97 
98  // Documentation inherited.
99  const char* getKinematicsHash() override;
100 
101  // Documentation inherited.
102  const char* getIkFastVersion() override;
103 
104  // Documentation inherited.
105  void configure() const override;
106 
107 protected:
108  using IkFastFuncGetInt = int (*)();
109  using IkFastFuncGetIntPtr = int* (*)();
110  using IkFastFuncComputeIk = bool (*)(
111  const IkReal* targetTranspose,
112  const IkReal* targetRotation,
113  const IkReal* freeParams,
114  ikfast::IkSolutionListBase<IkReal>& solutions);
115  using IkFastFuncGetConstCharPtr = const char* (*)();
116 
118  std::string mFilePath;
119 
120  mutable std::shared_ptr<common::SharedLibrary> mSharedLibrary;
121 
130 
132  mutable std::vector<std::size_t> mDofs;
133 };
134 
135 } // namespace dynamics
136 } // namespace dart
137 
138 #endif // DART_DYNAMICS_SHAREDLIBRARYIKFAST_HPP_
BodyPropPtr properties
Definition: SdfParser.cpp:80
A base class for IkFast-based analytical inverse kinematics classes.
Definition: IkFast.hpp:51
The InverseKinematics class provides a convenient way of setting up an IK optimization problem.
Definition: InverseKinematics.hpp:76
IkFast-based analytical inverse kinematics class.
Definition: SharedLibraryIkFast.hpp:47
int getIkRealSize() const override
Definition: SharedLibraryIkFast.cpp:183
IkFastFuncGetIntPtr mGetFreeParameters
Definition: SharedLibraryIkFast.hpp:123
int *(*)() IkFastFuncGetIntPtr
Definition: SharedLibraryIkFast.hpp:109
IkFastFuncGetInt mGetIkType
Definition: SharedLibraryIkFast.hpp:126
SharedLibraryIkFast(InverseKinematics *ik, const std::string &filePath, const std::vector< std::size_t > &dofMap, const std::vector< std::size_t > &freeDofMap, const std::string &methodName="IKFast", const Analytical::Properties &properties=Analytical::Properties())
Constructor.
Definition: SharedLibraryIkFast.cpp:73
IkFastFuncGetInt mGetNumJoints
Definition: SharedLibraryIkFast.hpp:124
int getNumJoints() const override
Definition: SharedLibraryIkFast.cpp:170
auto clone(InverseKinematics *newIK) const -> std::unique_ptr< GradientMethod > override
Enable this GradientMethod to be cloned to a new IK module.
Definition: SharedLibraryIkFast.cpp:131
IkFastFuncGetInt mGetIkRealSize
Definition: SharedLibraryIkFast.hpp:125
const char * getIkFastVersion() override
Definition: SharedLibraryIkFast.cpp:239
IkFastFuncGetConstCharPtr mGetKinematicsHash
Definition: SharedLibraryIkFast.hpp:128
std::vector< std::size_t > mDofs
Indices of the DegreeOfFreedoms associated to this IkFast.
Definition: SharedLibraryIkFast.hpp:132
int getIkType() const override
Definition: SharedLibraryIkFast.cpp:196
bool computeIk(const IkReal *targetTranspose, const IkReal *targetRotation, const IkReal *freeParams, ikfast::IkSolutionListBase< IkReal > &solutions) override
Computes the inverse kinematics solutions using the generated IKFast code.
Definition: SharedLibraryIkFast.cpp:209
bool(*)(const IkReal *targetTranspose, const IkReal *targetRotation, const IkReal *freeParams, ikfast::IkSolutionListBase< IkReal > &solutions) IkFastFuncComputeIk
Definition: SharedLibraryIkFast.hpp:114
std::string mFilePath
File path to the ikfast shared library.
Definition: SharedLibraryIkFast.hpp:118
IkFastFuncGetInt mGetNumFreeParameters
Definition: SharedLibraryIkFast.hpp:122
int(*)() IkFastFuncGetInt
Definition: SharedLibraryIkFast.hpp:108
IkFastFuncGetConstCharPtr mGetIkFastVersion
Definition: SharedLibraryIkFast.hpp:129
void configure() const override
Configure IkFast.
Definition: SharedLibraryIkFast.cpp:252
const char *(*)() IkFastFuncGetConstCharPtr
Definition: SharedLibraryIkFast.hpp:115
const char * getKinematicsHash() override
Definition: SharedLibraryIkFast.cpp:226
std::shared_ptr< common::SharedLibrary > mSharedLibrary
Definition: SharedLibraryIkFast.hpp:120
IkFastFuncComputeIk mComputeIk
Definition: SharedLibraryIkFast.hpp:127
int * getFreeParameters() const override
Definition: SharedLibraryIkFast.cpp:157
int getNumFreeParameters() const override
Definition: SharedLibraryIkFast.cpp:144
Definition: BulletCollisionDetector.cpp:63