Choreonoid  1.8
CustomJointPathBase.h
Go to the documentation of this file.
1 #ifndef CNOID_BODY_CUSTOM_JOINT_PATH_BASE_H
2 #define CNOID_BODY_CUSTOM_JOINT_PATH_BASE_H
3 
4 #include "JointPath.h"
5 #include "Link.h"
6 #include "exportdecl.h"
7 
8 namespace cnoid {
9 
17 class CNOID_EXPORT CustomJointPathBase : public JointPath
18 {
19  typedef std::function<bool(const Isometry3& T_global, const Isometry3& T_relative)> InverseKinematicsFunc;
20  InverseKinematicsFunc calcCustomInverseKinematics;
21  bool isReversed_;
22 
23 public:
24  CustomJointPathBase(Link* baseLink, Link* endLink);
25 
26  bool checkLinkPath(const std::string& from, const std::string& to, bool& out_isReversed) const;
27 
28  void setCustomInverseKinematics(InverseKinematicsFunc func, bool isReversed = false);
29  InverseKinematicsFunc customInverseKinematics() const { return calcCustomInverseKinematics; }
30  bool isReversed() const { return isReversed_; }
31 
32  virtual bool calcInverseKinematics(const Isometry3& T) override;
33  virtual bool hasCustomIK() const override;
34 
35  template<typename iterator> void copyJointDisplacements(iterator q_iter){
36  if(!isReversed_){
37  for(auto& joint : joints()){
38  joint->q() = *q_iter++;
39  }
40  } else {
41  for(auto j_iter = joints().rbegin(); j_iter != joints().rend(); ++j_iter){
42  (*j_iter)->q() = *q_iter++;
43  }
44  }
45  }
46 };
47 
48 }
49 
50 #endif
cnoid::JointPath::iterator
LinkTraverse::iterator iterator
Definition: JointPath.h:72
cnoid::JointPath
Definition: JointPath.h:23
cnoid::Isometry3
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
cnoid::CustomJointPathBase::copyJointDisplacements
void copyJointDisplacements(iterator q_iter)
Definition: CustomJointPathBase.h:35
JointPath.h
The header file of the JointPath class.
cnoid::CustomJointPathBase::customInverseKinematics
InverseKinematicsFunc customInverseKinematics() const
Definition: CustomJointPathBase.h:29
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::CustomJointPathBase
Definition: CustomJointPathBase.h:17
cnoid::CustomJointPathBase::isReversed
bool isReversed() const
Definition: CustomJointPathBase.h:30