3
\author Shin'ichiro Nakaoka
6
#ifndef CNOID_BODY_LINK_H_INCLUDED
7
#define CNOID_BODY_LINK_H_INCLUDED
12
#include <cnoid/EigenTypes>
13
#include <cnoid/ColdetModel>
14
#include "exportdecl.h"
20
CNOID_EXPORT std::ostream& operator<<(std::ostream &out, cnoid::Link& link);
26
class CNOID_EXPORT Link {
31
Link(const Link& link);
34
inline const std::string& name() {
37
inline void setName(const std::string& name){
41
inline bool isValid() { return (index >= 0); }
42
void addChild(Link* link);
43
bool detachChild(Link* link);
44
inline bool isRoot() { return !parent; }
46
inline void setAttitude(const Matrix3& R) { this->R = R * Rs.transpose(); }
47
inline Matrix3 attitude() { return this->R * Rs; }
48
inline Matrix3 calcRfromAttitude(const Matrix3& R) { return R * Rs.transpose(); }
51
@brief compute sum of m x wc of subtree
52
@note assuming wc is already computed by Body::calcCM()
57
@deprecated use setAttitude().
59
inline void setSegmentAttitude(const Matrix3& R) { this->R = R * Rs.transpose(); }
62
@deprecated use attitude().
64
inline Matrix3 segmentAttitude() { return this->R * Rs; }
66
void updateColdetModelPosition() {
67
coldetModel->setPosition(R, p);
73
int jointId; ///< jointId value written in a model file
76
FIXED_JOINT, ///< fixed joint(0 dof)
77
FREE_JOINT, /// 6-DOF root link
78
ROTATIONAL_JOINT, ///< rotational joint (1 dof)
79
SLIDE_JOINT ///< translational joint (1 dof)
88
Vector3 p; ///< position
91
Internal world attitude.
92
In the model computation, it corresponds to the identity matrix
93
when all the joint angles of a robot are zero so that multiplication of
94
local attitdue matrices can be omitted to simplify the computation.
95
If you want to use the original coordinate in the model file,
96
use setAttitude() and attitude() to access.
100
Vector3 v; ///< linear velocity
101
Vector3 w; ///< angular velocity, omega
102
Vector3 dv; ///< linear acceleration
103
Vector3 dw; ///< derivative of omega
105
double q; ///< joint value
106
double dq; ///< joint velocity
107
double ddq; ///< joint acceleration
108
double u; ///< joint torque
110
Vector3 a; ///< rotational joint axis (self local)
111
Vector3 d; ///< translation joint axis (self local)
112
Vector3 b; ///< relative position (parent local)
114
Matrix3 Rs; ///< relative attitude of the link segment (self local)
117
Matrix3 I; ///< inertia tensor (self local, around c)
118
Vector3 c; ///< center of mass (self local)
119
Vector3 wc; ///< R * c + p
121
Vector3 vo; ///< translation elements of spacial velocity
122
Vector3 dvo; ///< derivative of vo
124
/** A unit vector of angular velocity (the world coordinate) generated by the joint
125
The value is parent->R * a when the joint is the rotational type. */
128
/** A unit vector of spatial velocity (the world coordinate) generated by the joint.
129
The value is parent->R * d when the joint is the translation type. */
132
Vector3 cv; ///< dsv * dq (cross velocity term)
133
Vector3 cw; ///< dsw * dq (cross velocity term)
135
Vector3 fext; ///< external force
136
Vector3 tauext; ///< external torque (around the world origin)
139
//Vector3 f; ///< force from the parent link
140
//Vector3 tau; ///< torque from the parent link
142
Matrix3 Iww; ///< bottm right block of the articulated inertia
143
Matrix3 Iwv; ///< bottom left block (transpose of top right block) of the articulated inertia
144
Matrix3 Ivv; ///< top left block of the articulated inertia
145
Vector3 pf; ///< bias force (linear element)
146
Vector3 ptau; ///< bias force (torque element)
147
Vector3 hhv; ///< top block of Ia*s
148
Vector3 hhw; ///< bottom bock of Ia*s
150
double dd; ///< Ia*s*s^T
152
double Jm2; ///< Equivalent rotor inertia: n^2*Jm [kg.m^2]
154
double ulimit; ///< the upper limit of joint values
155
double llimit; ///< the lower limit of joint values
156
double uvlimit; ///< the upper limit of joint velocities
157
double lvlimit; ///< the lower limit of joint velocities
159
double defaultJointValue;
162
double Ir; ///< rotor inertia [kg.m^2]
164
double gearEfficiency;
165
double rotorResistor;
169
ColdetModelPtr coldetModel;
171
struct ConstraintForce {
176
typedef std::vector<ConstraintForce> ConstraintForceArray;
177
ConstraintForceArray constraintForces;
179
double subm; ///< mass of subtree
180
Vector3 submwc; ///< sum of m x wc of subtree
186
Link& operator=(const Link& link); // no implementation is given to disable the copy operator
187
void setBodyIter(Body* body);
188
friend std::ostream& ::operator<<(std::ostream &out, Link& link);
189
void putInformation(std::ostream& out); // for the iostream output