Choreonoid  1.8
ExtraJoint.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODY_EXTRA_JOINT_H
7 #define CNOID_BODY_EXTRA_JOINT_H
8 
9 #include "Link.h"
10 
11 namespace cnoid {
12 
14 {
15 public:
17 
19  for(int i=0; i < 2; ++i){
20  points[i].setZero();
21  links[i] = nullptr;
22  }
23  };
25  : ExtraJoint() {
26  type_ = type;
27  axis_ = axis;
28  };
29 
30  ExtraJointType type() const { return type_; }
31  void setType(const ExtraJointType type) { type_ = type; }
32 
33  const Vector3& axis() const { return axis_; }
34  void setAxis(const Vector3& axis) { axis_ = axis; }
35 
36  Link* link(int which) const { return links[which]; }
37 
38  void setLink(int which, Link* link) {
39  links[which] = link;
40  if(link){
41  linkNames[which] = link->name();
42  }
43  }
44 
45  const Vector3& point(int which) const { return points[which]; }
46  void setPoint(int which, const Vector3& p) { points[which] = p; }
47 
48  const std::string& bodyName(int which) const { return bodyNames[which]; }
49  const std::string& linkName(int which) const { return linkNames[which]; }
50 
51  bool isForLinksOfSameBody() const {
52  if(links[0] && links[1]){
53  return links[0]->body() == links[1]->body();
54  }
55  return false;
56  }
57 
58 private:
59  ExtraJointType type_;
60  Vector3 axis_;
61  Link* links[2];
62  Vector3 points[2];
63  std::string bodyNames[2];
64  std::string linkNames[2];
65 };
66 
67 }
68 
69 #endif
cnoid::ExtraJoint::axis
const Vector3 & axis() const
Definition: ExtraJoint.h:33
cnoid::ExtraJoint::bodyName
const std::string & bodyName(int which) const
Definition: ExtraJoint.h:48
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::ExtraJoint::ExtraJoint
ExtraJoint()
Definition: ExtraJoint.h:18
cnoid::ExtraJoint::type
ExtraJointType type() const
Definition: ExtraJoint.h:30
cnoid::ExtraJoint::setPoint
void setPoint(int which, const Vector3 &p)
Definition: ExtraJoint.h:46
cnoid::ExtraJoint::linkName
const std::string & linkName(int which) const
Definition: ExtraJoint.h:49
cnoid::ExtraJoint::isForLinksOfSameBody
bool isForLinksOfSameBody() const
Definition: ExtraJoint.h:51
cnoid::ExtraJoint::setLink
void setLink(int which, Link *link)
Definition: ExtraJoint.h:38
cnoid::ExtraJoint::setAxis
void setAxis(const Vector3 &axis)
Definition: ExtraJoint.h:34
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::ExtraJoint::EJ_PISTON
@ EJ_PISTON
Definition: ExtraJoint.h:16
cnoid::ExtraJoint::EJ_BALL
@ EJ_BALL
Definition: ExtraJoint.h:16
cnoid::ExtraJoint
Definition: ExtraJoint.h:13
cnoid::ExtraJoint::ExtraJointType
ExtraJointType
Definition: ExtraJoint.h:16
cnoid::ExtraJoint::setType
void setType(const ExtraJointType type)
Definition: ExtraJoint.h:31
cnoid::ExtraJoint::link
Link * link(int which) const
Definition: ExtraJoint.h:36
cnoid::ExtraJoint::ExtraJoint
ExtraJoint(ExtraJointType type, const Vector3 &axis)
Definition: ExtraJoint.h:24
cnoid::ExtraJoint::point
const Vector3 & point(int which) const
Definition: ExtraJoint.h:45