Vec3f PhysicsHingeJoint::getAnchor2(void) { dVector3 a; dJointGetHingeAnchor2(_JointID, a); return Vec3f(a[0], a[1], a[2]); }
void doStuff(const std::string & prefix,amarsi::Limbs limb){ std::ostringstream name; name<<prefix<<"_TOE"; dBodyID toeBody=dWebotsGetBodyFromDEF(name.str().c_str()); dGeomID toe=dWebotsGetGeomFromDEF(name.str().c_str()); //std::cerr<<"Get Geom of value "<<toe<<std::endl; if(!toe || !toeBody){ std::cerr<<"Did not found "<<name<<" "<<toe<<" "<<toeBody<<std::endl; s_data->disablePhysics(); return; } std::ostringstream nameTibia; nameTibia<<prefix<<"_FRONT_KNEE"; dBodyID tibia = dWebotsGetBodyFromDEF(nameTibia.str().c_str()); if(!tibia){ std::cerr<<"Did not found "<<nameTibia<<std::endl; s_data->disablePhysics(); return; } // std::cerr<<nameTibia<<" "<<tibia<<std::endl; int numJoint=dBodyGetNumJoints(tibia); std::ostringstream nameFemur; nameFemur<<prefix<<"_HIP_SERVO"; dBodyID femur = dWebotsGetBodyFromDEF(nameFemur.str().c_str()); if(!femur){ std::cerr<<"Did not found "<<nameFemur<<std::endl; s_data->disablePhysics(); return; } for(int i=0;i<numJoint;++i){ dJointID j=dBodyGetJoint(tibia,i); dBodyID b1= dJointGetBody(j,0); dBodyID b2= dJointGetBody(j,1); dReal pos[4]; if(b1==femur || b2==femur){ if(b1==femur) dJointGetHingeAnchor2(j,pos); else dJointGetHingeAnchor(j,pos); dVector3 posRel; dBodyGetPosRelPoint(tibia,pos[0],pos[1],pos[3],posRel); // std::cerr<<"pos : "<<posRel[0]<<" "<<posRel[1]<<" "<<posRel[2]<<std::endl; // s_data->addKneeJoint(j,limb); } } std::ostringstream nameAnkle; nameAnkle<<prefix<<"_ANKLE"<<std::flush; dBodyID ankleBody = dWebotsGetBodyFromDEF(nameAnkle.str().c_str()); dGeomID ankle=dWebotsGetGeomFromDEF(nameAnkle.str().c_str()); if(!ankle || !ankleBody){ std::cerr<<"Did not found "<<nameAnkle<<" "<<ankle<<" " <<ankleBody<<std::endl; s_data->disablePhysics(); return; } insertGeomInMonitored(ankle,limb); insertGeomInMonitored(toe,limb); s_data->addResettableBody(femur); s_data->addResettableBody(tibia); s_data->addResettableBody(ankleBody); s_data->addResettableBody(toeBody); }