DART  6.10.1
SharedLibraryIkFast.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, 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  void computeFk(
100  const IkReal* parameters,
101  IkReal* targetTranspose,
102  IkReal* targetRotation) override;
103 
104  // Documentation inherited.
105  const char* getKinematicsHash() override;
106 
107  // Documentation inherited.
108  const char* getIkFastVersion() override;
109 
110  // Documentation inherited.
111  void configure() const override;
112 
113 protected:
114  using IkFastFuncGetInt = int (*)();
115  using IkFastFuncGetIntPtr = int* (*)();
116  using IkFastFuncComputeIk = bool (*)(
117  const IkReal* targetTranspose,
118  const IkReal* targetRotation,
119  const IkReal* freeParams,
120  ikfast::IkSolutionListBase<IkReal>& solutions);
121  using IkFastFuncComputeFk = void (*)(
122  const IkReal* parameters,
123  IkReal* targetTranspose,
124  IkReal* targetRotation);
125  using IkFastFuncGetConstCharPtr = const char* (*)();
126 
128  std::string mFilePath;
129 
130  mutable std::shared_ptr<common::SharedLibrary> mSharedLibrary;
131 
141 };
142 
143 } // namespace dynamics
144 } // namespace dart
145 
146 #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
Returns the size in bytes of the configured number type.
Definition: SharedLibraryIkFast.cpp:181
IkFastFuncGetIntPtr mGetFreeParameters
Definition: SharedLibraryIkFast.hpp:133
int *(*)() IkFastFuncGetIntPtr
Definition: SharedLibraryIkFast.hpp:115
IkFastFuncGetInt mGetIkType
Definition: SharedLibraryIkFast.hpp:136
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:134
int getNumJoints() const override
Returns the total number of indices of the chane.
Definition: SharedLibraryIkFast.cpp:168
auto clone(InverseKinematics *newIK) const -> std::unique_ptr< GradientMethod > override
Enable this GradientMethod to be cloned to a new IK module.
Definition: SharedLibraryIkFast.cpp:129
IkFastFuncGetInt mGetIkRealSize
Definition: SharedLibraryIkFast.hpp:135
const char * getIkFastVersion() override
Returns the IkFast version used to generate this file.
Definition: SharedLibraryIkFast.cpp:251
IkFastFuncGetConstCharPtr mGetKinematicsHash
Definition: SharedLibraryIkFast.hpp:139
void computeFk(const IkReal *parameters, IkReal *targetTranspose, IkReal *targetRotation) override
Computes the forward kinematics solutions using the generated IKFast code.
Definition: SharedLibraryIkFast.cpp:224
int getIkType() const override
Returns the IK type.
Definition: SharedLibraryIkFast.cpp:194
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:207
bool(*)(const IkReal *targetTranspose, const IkReal *targetRotation, const IkReal *freeParams, ikfast::IkSolutionListBase< IkReal > &solutions) IkFastFuncComputeIk
Definition: SharedLibraryIkFast.hpp:120
void(*)(const IkReal *parameters, IkReal *targetTranspose, IkReal *targetRotation) IkFastFuncComputeFk
Definition: SharedLibraryIkFast.hpp:124
std::string mFilePath
File path to the ikfast shared library.
Definition: SharedLibraryIkFast.hpp:128
IkFastFuncGetInt mGetNumFreeParameters
Definition: SharedLibraryIkFast.hpp:132
int(*)() IkFastFuncGetInt
Definition: SharedLibraryIkFast.hpp:114
IkFastFuncComputeFk mComputeFk
Definition: SharedLibraryIkFast.hpp:138
IkFastFuncGetConstCharPtr mGetIkFastVersion
Definition: SharedLibraryIkFast.hpp:140
void configure() const override
Configure IkFast.
Definition: SharedLibraryIkFast.cpp:264
const char *(*)() IkFastFuncGetConstCharPtr
Definition: SharedLibraryIkFast.hpp:125
const char * getKinematicsHash() override
Returns a hash of all the chain values used for double checking that the correct IK is used.
Definition: SharedLibraryIkFast.cpp:238
std::shared_ptr< common::SharedLibrary > mSharedLibrary
Definition: SharedLibraryIkFast.hpp:130
IkFastFuncComputeIk mComputeIk
Definition: SharedLibraryIkFast.hpp:137
int * getFreeParameters() const override
Returns the indicies of the free parameters indexed by the chain joints.
Definition: SharedLibraryIkFast.cpp:155
int getNumFreeParameters() const override
Returns the number of free parameters users has to set apriori.
Definition: SharedLibraryIkFast.cpp:142
Definition: BulletCollisionDetector.cpp:65