43 virtual void onJointPathUpdated();
47 virtual bool calcInverseKinematics(
const Vector3& end_p,
const Matrix33& end_R);
48 virtual bool hasAnalyticalIK();
56 customizerInterface->destroy(customizerHandle);
62 for(
unsigned int sensorType =0; sensorType < numSensorTypes(); ++sensorType){
63 int n = numSensors(sensorType);
64 for(
int i=0;
i <
n; ++
i){
65 Sensor* s = sensor(sensorType,
i);
79 customizerInterface = 0;
80 bodyHandleEntity.body =
this;
81 bodyHandle = &bodyHandleEntity;
86 : allSensors(
Sensor::NUM_SENSOR_TYPES)
111 std::map<Link*, int> linkToIndexMap;
115 linkToIndexMap[lnk] =
i;
119 for(
int sensorType = 0; sensorType <
n; ++sensorType){
123 int linkIndex = linkToIndexMap[orgSensor->
link];
126 *cloneSensor = *orgSensor;
135 for(
int j=0;
j < 2; ++
j){
177 empty->
R.setIdentity();
189 empty->
Rs.setIdentity();
195 empty->
dvo.setZero();
196 empty->
fext.setZero();
221 for(
int i=0;
i <
n; ++
i){
245 std::cerr <<
"Warning: Model " <<
modelName_ <<
246 " has empty joint ID in the valid IDs." << std::endl;
281 for(
int i=0;
i <
n; ++
i){
302 for(
int i=0;
i <
n; ++
i){
317 for(
int i=0;
i <
n;
i++){
319 link->
wc = link->
p + link->
R * link->
c;
320 mc += link->
m * link->
wc;
353 out_M.resize(totaldof,totaldof);
354 b1.resize(totaldof, 1);
361 ddqorg[
i] = ptr->
ddq;
376 for(
int i=0;
i < 3; ++
i){
381 for(
int i=0;
i < 3; ++
i){
396 out_M(j, j) += ptr->
Jm2;
401 for(
int i = 0;
i < out_M.cols(); ++
i){
408 ptr->
ddq = ddqorg[
i];
425 out_M.block<6,1>(0, column) << f, tau;
429 for(
int i = 0;
i <
n; ++
i){
431 out_M(
i + 6, column) = ptr->
u;
446 sw.noalias() = parent->
R * ptr->
a;
447 sv = ptr->
p.cross(sw);
453 ptr->
vo = parent->
vo + sv * ptr->
dq;
454 ptr->
w = parent->
w + sw * ptr->
dq;
456 dsv = parent->
w.cross(sv) + parent->
vo.cross(sw);
457 dsw = parent->
w.cross(sw);
459 ptr->
dw = parent->
dw + dsw * ptr->
dq + sw * ptr->
ddq;
460 ptr->
dvo = parent->
dvo + dsv * ptr->
dq + sv * ptr->
ddq;
469 c = ptr->
R * ptr->
c + ptr->
p;
470 I.noalias() = ptr->
R * ptr->
I * ptr->
R.transpose();
472 I.noalias() += ptr->
m * c_hat * c_hat.transpose();
473 P.noalias() = ptr->
m * (ptr->
vo + ptr->
w.cross(c));
474 L = ptr->
m * c.cross(ptr->
vo) + I * ptr->
w;
476 out_f = ptr->
m * (ptr->
dvo + ptr->
dw.cross(c)) + ptr->
w.cross(P);
477 out_tau = ptr->
m * c.cross(ptr->
dvo) + I * ptr->
dw + ptr->
vo.cross(P) + ptr->
w.cross(L);
487 ptr->
u = ptr->
sv.dot(out_f) + ptr->
sw.dot(out_tau);
514 for(
int i=0;
i <
n;
i++){
517 dwc = link->
v + link->
w.cross(link->
R * link->
c);
522 Llocal.noalias() = link->
I * link->
R.transpose()*link->
w;
523 L = link->
wc.cross(P) + link->
R * Llocal;
542 for(
int i=0;
i <
n;
i++){
571 if(sensorType < Sensor::NUM_SENSOR_TYPES && id >= 0){
574 int n = sensors.size();
576 sensors.resize(
id + 1, 0);
578 sensor = sensors[id];
580 std::cerr <<
"duplicated sensor Id is specified(id = " 581 <<
id <<
", name = " << name <<
")" << std::endl;
593 link->
sensors.push_back(sensor);
601 if(sensorType < Sensor::NUM_SENSOR_TYPES && id >= 0){
603 int n = sensors.size();
605 sensors.resize(
id + 1, 0);
607 Sensor* sameId = sensors[id];
609 std::cerr <<
"duplicated sensor Id is specified(id = " 610 <<
id <<
", name = " << sensor->
name <<
")" << std::endl;
652 for(
int i=0;
i <
n; ++
i){
654 link->
fext.setZero();
663 for(
int i=0;
i <
n; ++
i){
674 out <<
"Body: model name = " <<
modelName_ <<
" name = " <<
name_ <<
"\n\n";
677 for(
int i=0;
i <
n; ++
i){
696 return interface ? installCustomizer(interface) : false;
738 return (link ? link->
index : -1);
834 p_relative.noalias() = baseLink_->
R.transpose() * (end_p - baseLink_->
p);
835 R_relative.noalias() = baseLink_->
R.transpose() * end_R;
837 p_relative.noalias() = end_R.transpose() * (baseLink_->
p - end_p);
838 R_relative.noalias() = end_R.transpose() * baseLink_->
R;
850 double errsqr = dp.dot(dp) + omega.dot(omega);
878 jp = getJointPath(rootLink(), base);
879 Link *skip = jp->joint(0);
880 skip->
subm = rootLink()->m;
881 skip->
submwc = rootLink()->m*rootLink()->wc;
901 for (
unsigned int i=1;
i<jp->numJoints();
i++){
909 rootLink()->calcSubMassCM();
916 for (
unsigned int i=0;
i<jp->numJoints();
i++) sgn[jp->joint(
i)->jointId] = -1;
937 std::cerr <<
"calcCMJacobian() : unsupported jointType(" 943 J(0, c ) = 1.0; J(0, c+1) = 0.0; J(0, c+2) = 0.0;
944 J(1, c ) = 0.0; J(1, c+1) = 1.0; J(1, c+2) = 0.0;
945 J(2, c ) = 0.0; J(2, c+1) = 0.0; J(2, c+2) = 1.0;
947 Vector3 dp(rootLink()->submwc/totalMass_ - rootLink()->p);
948 J(0, c+3) = 0.0; J(0, c+4) = dp(2); J(0, c+5) = -dp(1);
949 J(1, c+3) = -dp(2); J(1, c+4) = 0.0; J(1, c+5) = dp(0);
950 J(2, c+3) = dp(1); J(2, c+4) = -dp(0); J(2, c+5) = 0.0;
960 calcCMJacobian(base, M);
965 jp = getJointPath(rootLink(), base);
966 Link *skip = jp->joint(0);
967 skip->
subm = rootLink()->m;
968 skip->
submwc = rootLink()->m*rootLink()->wc;
988 for (
unsigned int i=1;
i<jp->numJoints();
i++){
996 rootLink()->calcSubMassCM();
1003 for (
unsigned int i=0;
i<jp->numJoints();
i++) sgn[jp->joint(
i)->jointId] = -1;
1030 std::cerr <<
"calcCMJacobian() : unsupported jointType(" 1036 H.block(0, c, 3, 3).setZero();
1038 rootLink_->calcSubMassInertia(Iw);
1039 H.block(0, c+3, 3, 3) = Iw;
1046 H.block(0,0,3,c) -= cm_cross * M;
Link * createEmptyJoint(int jointId)
std::vector< SensorArray > allSensors
double Ir
rotor inertia [kg.m^2]
virtual void onJointPathUpdated()
BodyCustomizerInitializeAnalyticIkFunc initializeAnalyticIk
ConstraintForceArray constraintForces
Vector3 fext
external force
Vector3 vo
translation elements of spacial velocity
static void destroy(Sensor *sensor)
double ddq
joint acceleration
Vector3 submwc
sum of m x wc of subtree
virtual bool calcInverseKinematics(const Vector3 &end_p, const Matrix33 &end_R)
static const int BODY_INTERFACE_VERSION
void calcForwardKinematics(bool calcVelocity=false, bool calcAcceleration=false) const
static int getLinkIndexFromName(BodyHandle bodyHandle, const char *linkName)
void setDefaultRootPosition(const Vector3 &p, const Matrix33 &R)
void calcCMJacobian(Link *base, dmatrix &J)
compute CoM Jacobian
virtual ~CustomizedJointPath()
ColdetModelPtr coldetModel
static Link * extractLink(BodyHandle bodyHandle, int linkIndex)
NameToLinkMap nameToLinkMap
bool isCustomizedIkPathReversed
translational joint (1 dof)
friend class CustomizedJointPath
void setRootLink(Link *link)
void addSensor(Sensor *sensor, int sensorType, int id)
void getDefaultRootPosition(Vector3 &out_p, Matrix33 &out_R)
void setAttitude(const Matrix33 &R)
Vector3 w
angular velocity, omega
static BodyInterface * bodyInterface()
void calcSubMassCM()
compute sum of m x wc of subtree
Sensor * createSensor(Link *link, int sensorType, int id, const std::string &name)
unsigned int numSensors(int sensorType) const
void calcTotalMomentum(Vector3 &out_P, Vector3 &out_L)
BodyCustomizerCreateFunc create
Vector3 defaultRootPosition
std::vector< Sensor * > SensorArray
BodyCustomizerSetVirtualJointForcesFunc setVirtualJointForces
void setColumnOfMassMatrix(dmatrix &M, int column)
BodyCustomizerDestroyFunc destroy
static bool pluginsInDefaultDirectoriesLoaded
void initializeConfiguration()
void calcMassMatrix(dmatrix &out_M)
unsigned int numLinks() const
virtual void find(Link *root, bool doUpward=false, bool doDownward=true)
void updateLinkColdetModelPositions()
void calcForwardKinematics(bool calcVelocity=false, bool calcAcceleration=false) const
double lvlimit
the lower limit of joint velocities
NameToLightMap nameToLightMap
BodyCustomizerInterface * customizerInterface
Vector3 tauext
external torque (around the world origin)
static double * getJointVelocityPtr(BodyHandle bodyHandle, int linkIndex)
Vector3 dv
linear acceleration
def j(str, encoding="cp932")
const std::string & name()
static Sensor * create(int type)
Link * joint(int index) const
Vector3 b
relative position (parent local)
Matrix33 Rs
relative attitude of the link segment (self local)
The header file of the LinkPath and JointPath classes.
Vector3 dvo
derivative of vo
Light * createLight(Link *link, int lightType, const std::string &name)
NameToSensorMap nameToSensorMap
CustomizedJointPath(Body *body, Link *baseLink, Link *targetLink)
std::vector< ExtraJoint > extraJoints
Vector3 dw
derivative of omega
unsigned int numSensorTypes() const
unsigned int numJoints() const
Link * joint(int id) const
Light * light(const std::string &name)
Link * link(int index) const
double uvlimit
the upper limit of joint velocities
static const char * getLinkName(BodyHandle bodyHandle, int linkIndex)
Vector3 cross(const Vector3 &v1, const Vector3 &v2)
The definitions of the body customizer interface for increasing binary compatibility.
void calcTotalMomentumFromJacobian(Vector3 &out_P, Vector3 &out_L)
Matrix33 I
inertia tensor (self local, around c)
Matrix33 hat(const Vector3 &c)
int jointId
jointId value written in a model file
virtual bool hasAnalyticalIK()
virtual bool calcInverseKinematics(const Vector3 &end_p, const Matrix33 &end_R)
unsigned int numJoints() const
Matrix33 defaultRootAttitude
void calcAngularMomentumJacobian(Link *base, dmatrix &H)
compute Angular Momentum Jacobian around CoM of base
std::ostream & operator<<(std::ostream &out, Body &body)
HRP_UTIL_EXPORT Vector3 omegaFromRot(const Matrix33 &r)
JointPathPtr getJointPath(Link *baseLink, Link *targetLink)
double llimit
the lower limit of joint values
boost::shared_ptr< JointPath > JointPathPtr
unsigned int numLinks() const
static const bool PUT_DEBUG_MESSAGE
std::vector< Sensor * > sensors
sensors attached to this link
void calcSubMassInertia(Matrix33 &subIw)
compute sum of I of subtree
double ulimit
the upper limit of joint values
void setVirtualJointForcesSub()
Vector3 a
rotational joint axis (self local)
void putInformation(std::ostream &out)
Vector3 d
translation joint axis (self local)
double subm
mass of subtree
Sensor * sensor(int sensorType, int sensorId) const
BodyCustomizerHandle customizerHandle
void clearExternalForces()
void calcForwardKinematics(bool calcVelocity=false, bool calcAcceleration=false)
HRPMODEL_API int loadBodyCustomizers(const std::string pathString, BodyInterface *bodyInterface)
Vector3 c
center of mass (self local)
LinkTraverse linkTraverse_
Matrix33 segmentAttitude()
double Jm2
Equivalent rotor inertia: n^2*Jm [kg.m^2].
static double * getJointValuePtr(BodyHandle bodyHandle, int linkIndex)
void calcInverseDynamics(Link *link, Vector3 &out_f, Vector3 &out_tau)
LinkArray jointIdToLinkArray
static double * getJointTorqueForcePtr(BodyHandle bodyHandle, int linkIndex)