本文整理汇总了C++中kdl::Chain类的典型用法代码示例。如果您正苦于以下问题:C++ Chain类的具体用法?C++ Chain怎么用?C++ Chain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Chain类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getKDLChainInfo
void getKDLChainInfo(kinematics_msgs::KinematicSolverInfo &chain_info)
{
unsigned int nj = chain.getNrOfJoints();
unsigned int nl = chain.getNrOfSegments();
ROS_DEBUG("nj: %d", nj);
ROS_DEBUG("nl: %d", nl);
//---setting up response
//joint_names
for(unsigned int i=0; i<nj; i++)
{
ROS_DEBUG("joint_name[%d]: %s", i, chain.getSegment(i).getJoint().getName().c_str());
chain_info.joint_names.push_back(chain.getSegment(i).getJoint().getName());
}
//limits
//joint limits are only saved in KDL::ChainIkSolverPos_NR_JL iksolverpos -> ik_solve().....but this is not visible here!
/*for(unsigned int i=0; i<nj; i++)
{
chain_info.limits[i].joint_name=chain.getSegment(i).getJoint().getName();
chain_info.limits[i].has_position_limits=
chain_info.limits[i].min_position=
chain_info.limits[i].max_position=
chain_info.limits[i].has_velocity_limits=
chain_info.limits[i].max_velocity=
chain_info.limits[i].has_acceleration_limits=
chain_info.limits[i].max_acceleration=
}*/
//link_names
for(unsigned int i=0; i<nl; i++)
{
chain_info.link_names.push_back(chain.getSegment(i).getName());
}
}
开发者ID:browatbn,项目名称:cob_driver,代码行数:35,代码来源:ik_solver_kdl.cpp
示例2:
ChainKinematics::ChainKinematics(const KDL::Chain chain, const double lambda) :
kinChain_(chain),
Njnt_(chain.getNrOfJoints()),
Nsegment_(chain.getNrOfSegments()) {
initialize(lambda);
}
开发者ID:fjp,项目名称:ba,代码行数:8,代码来源:ChainKinematics.cpp
示例3: idynChainGet_usingKDL_aux
KDL::Wrenches idynChainGet_usingKDL_aux(iCub::iDyn::iDynChain & idynChain, iCub::iDyn::iDynInvSensor & idynSensor,yarp::sig::Vector & ddp0)
{
yarp::sig::Vector q,dq,ddq;
q = idynChain.getAng();
dq = idynChain.getDAng();
ddq = idynChain.getD2Ang();
KDL::Chain kdlChain;
std::vector<std::string> la_joints;
la_joints.push_back("left_shoulder_pitch");
la_joints.push_back("left_shoulder_roll");
la_joints.push_back("left_arm_ft_sensor");
la_joints.push_back("left_shoulder_yaw");
la_joints.push_back("left_elbow");
la_joints.push_back("left_wrist_prosup");
la_joints.push_back("left_wrist_pitch");
la_joints.push_back("left_wrist_yaw");
idynSensorChain2kdlChain(idynChain,idynSensor,kdlChain,la_joints,la_joints);
std::cout << kdlChain << std::endl;
int nj = idynChain.getN();
//cout << "idynChainGet_usingKDL_aux with sensor" << " nrJoints " << kdlChain.getNrOfJoints() << " nrsegments " << kdlChain.getNrOfSegments() << endl;
assert(nj==kdlChain.getNrOfJoints());
assert(nj+1==kdlChain.getNrOfSegments());
KDL::JntArray jointpositions = KDL::JntArray(nj);
KDL::JntArray jointvel = KDL::JntArray(nj);
KDL::JntArray jointacc = KDL::JntArray(nj);
KDL::JntArray torques = KDL::JntArray(nj);
for(unsigned int i=0;i<nj;i++){
jointpositions(i)=q[i];
jointvel(i) = dq[i];
jointacc(i) = ddq[i];
}
KDL::Wrenches f_ext(nj+1);
KDL::Wrenches f_int(nj+1);
KDL::Vector grav_kdl;
idynVector2kdlVector(idynChain.getH0().submatrix(0,2,0,2).transposed()*ddp0,grav_kdl);
KDL::ChainIdSolver_RNE_IW neSolver = KDL::ChainIdSolver_RNE_IW(kdlChain,-grav_kdl);
int ret = neSolver.CartToJnt_and_internal_wrenches(jointpositions,jointvel,jointacc,f_ext,torques,f_int);
assert(ret >= 0);
return f_int;
}
开发者ID:traversaro,项目名称:icub_kdl,代码行数:57,代码来源:iDyn_KDL_emulation.cpp
示例4: getKDLChainInfo
void getKDLChainInfo(const KDL::Chain &chain,
kinematics_msgs::KinematicSolverInfo &chain_info)
{
int i=0; // segment number
while(i < (int)chain.getNrOfSegments())
{
chain_info.link_names.push_back(chain.getSegment(i).getName());
i++;
}
}
开发者ID:nttputus,项目名称:youbot-manipulation,代码行数:10,代码来源:arm_kinematics_constraint_aware_utils.cpp
示例5: init_message
sensor_msgs::JointState init_message(const KDL::Chain &chain) {
sensor_msgs::JointState msg;
for (unsigned int i=0; i < chain.getNrOfSegments(); ++i) {
KDL::Segment segment = chain.getSegment(i);
KDL::Joint joint = segment.getJoint();
if (joint.getType() == KDL::Joint::JointType::None) continue;
msg.name.push_back(joint.getName());
msg.position.push_back(0);
}
return msg;
}
开发者ID:ubi-agni,项目名称:rviz_cbf_plugin,代码行数:11,代码来源:run_cbf.cpp
示例6:
FkLookup::ChainFK::ChainFK(const KDL::Tree& tree, const std::string& root, const std::string& tip):root_name(root),tip_name(tip){
KDL::Chain chain;
tree.getChain(root_name, tip_name, chain);
solver = new KDL::ChainFkSolverPos_recursive(chain);
unsigned int num = chain.getNrOfSegments();
for(unsigned int i = 0; i < num; ++i){
const KDL::Joint &joint = chain.getSegment(i).getJoint();
if (joint.getType() != KDL::Joint::None) joints.insert(std::make_pair(joint.getName(),joints.size()));
}
ROS_ASSERT(joints.size() == chain.getNrOfJoints());
}
开发者ID:ipa-fmw,项目名称:cob_manipulation,代码行数:11,代码来源:ik_wrapper.cpp
示例7: getSegmentIndex
bool leatherman::getSegmentIndex(const KDL::Chain &c, std::string name, int &index)
{
for(size_t j = 0; j < c.getNrOfSegments(); ++j)
{
if(c.getSegment(j).getName().compare(name) == 0)
{
index = j;
return true;
}
}
return false;
}
开发者ID:karthik4294,项目名称:PR2_arm_planner,代码行数:12,代码来源:utils.cpp
示例8: LWR_knife
KDL::Chain kukaControl::LWR_knife() {
KDL::Chain chain;
// base
chain.addSegment(
// KDL::Segment(KDL::Joint(KDL::Joint::None),KDL::Frame::DH_Craig1989(0, 0, 0.33989, 0)));
KDL::Segment(KDL::Joint(KDL::Joint::None),
KDL::Frame::DH_Craig1989(0, 0, 0.34, 0)));
// joint 1
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, -M_PI_2, 0, 0)));
// joint 2
chain.addSegment(
// KDL::Segment(KDL::Joint(KDL::Joint::RotZ),KDL::Frame::DH_Craig1989(0, M_PI_2, 0.40011, 0)));
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, M_PI_2, 0.40, 0)));
// joint 3
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, M_PI_2, 0, 0)));
// joint 4
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, -M_PI_2, 0.4000, 0)));
// joint 5
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, -M_PI_2, 0, 0)));
// joint 6
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, M_PI_2, 0, 0)));
// joint 7 (with flange adapter)
/* chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, 0, 0.12597, 0)));*/
// for HSC
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, 0, 0.12597 + 0.41275, 0)));
KDL::Frame ee = KDL::Frame(KDL::Vector(0.0625, -0.0925, -0.07))
* KDL::Frame(
KDL::Rotation::EulerZYX(32.0 * M_PI / 180, 0.0,
54.18 * M_PI / 180));
chain.addSegment(KDL::Segment(KDL::Joint(KDL::Joint::None), ee));
return chain;
}
开发者ID:handsomeboy,项目名称:ENPM661-Planning-for-Autonomous-Robots,代码行数:52,代码来源:kukaControl.cpp
示例9: getKDLSegmentIndex
int getKDLSegmentIndex(const KDL::Chain &chain,
const std::string &name)
{
int i=0; // segment number
while(i < (int)chain.getNrOfSegments())
{
if(chain.getSegment(i).getName() == name)
{
return i+1;
}
i++;
}
return -1;
}
开发者ID:nttputus,项目名称:youbot-manipulation,代码行数:14,代码来源:arm_kinematics_constraint_aware_utils.cpp
示例10: computeRNEDynamicsForChain
void computeRNEDynamicsForChain(KDL::Tree& a_tree, const std::string& rootLink, const std::string& tipLink, KDL::Vector& grav,
std::vector<kdle::JointState>& jointState, std::vector<kdle::SegmentState>& linkState)
{
KDL::Chain achain;
a_tree.getChain(rootLink, tipLink, achain);
KDL::JntArray q(achain.getNrOfJoints());
KDL::JntArray q_dot(achain.getNrOfJoints());
KDL::JntArray q_dotdot(achain.getNrOfJoints());
JntArray torques(achain.getNrOfJoints());
KDL::Wrenches f_ext;
f_ext.resize(achain.getNrOfSegments());
std::cout << endl << endl;
printf("RNE dynamics values \n");
KDL::ChainIdSolver_RNE *rneDynamics = new ChainIdSolver_RNE(achain, -grav);
for (unsigned int i = 0; i < achain.getNrOfJoints(); ++i)
{
q(i) = jointState[i].q;
q_dot(i) = jointState[i].qdot;
q_dotdot(i) = jointState[i].qdotdot;
printf("q, qdot %f, %f\n", q(i), q_dot(i));
}
rneDynamics->CartToJnt(q, q_dot, q_dotdot, f_ext, torques);
for (unsigned int i = 0; i < achain.getNrOfJoints(); ++i)
{
printf("index, q, qdot, torques %d, %f, %f, %f\n", i, q(i), q_dot(i), torques(i));
}
return;
}
开发者ID:shakhimardanov,项目名称:orocos_kdl_electric_with_extensions,代码行数:35,代码来源:inversedynamics2.cpp
示例11: Test
void RobotAlgos::Test(void)
{
//Definition of a kinematic chain & add segments to the chain
KDL::Chain chain;
chain.addSegment(Segment(Joint(Joint::RotZ),Frame(Vector(0.0,0.0,1.020))));
chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.480))));
chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.645))));
chain.addSegment(Segment(Joint(Joint::RotZ)));
chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.120))));
chain.addSegment(Segment(Joint(Joint::RotZ)));
// Create solver based on kinematic chain
ChainFkSolverPos_recursive fksolver = ChainFkSolverPos_recursive(chain);
// Create joint array
unsigned int nj = chain.getNrOfJoints();
KDL::JntArray jointpositions = JntArray(nj);
// Assign some values to the joint positions
for(unsigned int i=0;i<nj;i++){
float myinput;
printf ("Enter the position of joint %i: ",i);
scanf ("%e",&myinput);
jointpositions(i)=(double)myinput;
}
// Create the frame that will contain the results
KDL::Frame cartpos;
// Calculate forward position kinematics
int kinematics_status;
kinematics_status = fksolver.JntToCart(jointpositions,cartpos);
if(kinematics_status>=0){
std::cout << cartpos <<std::endl;
printf("%s \n","Succes, thanks KDL!");
}else{
printf("%s \n","Error: could not calculate forward kinematics :(");
}
//Creation of the solvers:
ChainFkSolverPos_recursive fksolver1(chain);//Forward position solver
ChainIkSolverVel_pinv iksolver1v(chain);//Inverse velocity solver
ChainIkSolverPos_NR iksolver1(chain,fksolver1,iksolver1v,100,1e-6);//Maximum 100 iterations, stop at accuracy 1e-6
//Creation of jntarrays:
JntArray result(chain.getNrOfJoints());
JntArray q_init(chain.getNrOfJoints());
//Set destination frame
Frame F_dest=cartpos;
iksolver1.CartToJnt(q_init,F_dest,result);
for(unsigned int i=0;i<nj;i++){
printf ("Axle %i: %f \n",i,result(i));
}
}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:60,代码来源:RobotAlgos.cpp
示例12: main
int main()
{
KDLCollada kdlCollada;
vector <KDL::Chain> kinematicsModels;
const string filename = "puma.dae"; // loading collada kinematics model and converting it to kdl serial chain
if (!kdlCollada.load(COLLADA_MODELS_PATH + filename, kinematicsModels))
{
cout << "Failed to import " << filename;
return 0;
}
cout << "Imported " << kinematicsModels.size() << " kinematics chains" << endl;
for (unsigned int i = 0; i < kinematicsModels.size(); i++) // parsing output kdl serail chain
{
KDL::Chain chain = kinematicsModels[i];
cout << "Chain " << i << " has " << chain.getNrOfSegments() << " segments" << endl;
for (unsigned int u = 0; u < chain.getNrOfSegments(); u++)
{
KDL::Segment segment = chain.segments[u];
string segmentName = segment.getName();
cout << "Segment " << segmentName << " :" <<endl;
KDL::Frame f_tip = segment.getFrameToTip();
KDL::Vector rotAxis = f_tip.M.GetRot();
double rotAngle = f_tip.M.GetRotAngle(rotAxis);
KDL::Vector trans = f_tip.p;
cout << " frame: rotation " << rotAxis.x() << " " << rotAxis.y() << " " << rotAxis.z() << " " << rotAngle * 180 / M_PI << endl;
cout << " frame: translation " << trans.x() << " " << trans.y() << " " << trans.z() << endl;
KDL::RigidBodyInertia inertia = segment.getInertia();
KDL::Joint joint = segment.getJoint();
string jointName = joint.getName();
string jointType = joint.getTypeName();
KDL::Vector jointAxis = joint.JointAxis();
KDL::Vector jointOrigin = joint.JointOrigin();
cout << " joint name: " << jointName << endl;
cout << " type: " << jointType << endl;
cout << " axis: " << jointAxis.x() << " " <<jointAxis.y() << " " << jointAxis.z() << endl;
cout << " origin: " << jointOrigin.x() << " " << jointOrigin.y() << " " << jointOrigin.z() << endl;
}
}
return 0;
}
开发者ID:zakharov,项目名称:KDLCollada,代码行数:48,代码来源:helloworld.cpp
示例13: ChainJntToJacSolver
TEST_F(PR2IKTest, SingleRowRotation)
{
YAML::Node node = YAML::LoadFile("pr2_left_arm_scope.yaml");
ASSERT_NO_THROW(node.as< giskard_core::ScopeSpec >());
giskard_core::ScopeSpec scope_spec = node.as<giskard_core::ScopeSpec>();
ASSERT_NO_THROW(giskard_core::generate(scope_spec));
giskard_core::Scope scope = giskard_core::generate(scope_spec);
ASSERT_TRUE(scope.has_double_expression("pr2_rot_x"));
KDL::Expression<double>::Ptr exp = scope.find_double_expression("pr2_rot_x");
ASSERT_TRUE(exp.get());
std::string base = "base_link";
std::string tip = "l_wrist_roll_link";
KDL::Chain chain;
ASSERT_TRUE(tree.getChain(base, tip, chain));
ASSERT_EQ(chain.getNrOfJoints(), exp->number_of_derivatives());
boost::shared_ptr<KDL::ChainJntToJacSolver> jac_solver;
jac_solver = boost::shared_ptr<KDL::ChainJntToJacSolver>(
new KDL::ChainJntToJacSolver(chain));
for(int i=-11; i<12; ++i)
{
std::vector<double> exp_in;
KDL::JntArray solver_in(exp->number_of_derivatives());
for(size_t j=0; j<exp->number_of_derivatives(); ++j)
{
double value = 0.1*i;
exp_in.push_back(value);
solver_in(j) = value;
}
exp->setInputValues(exp_in);
exp->value();
KDL::Jacobian solver_jac(chain.getNrOfJoints());
ASSERT_GE(jac_solver->JntToJac(solver_in, solver_jac), 0.0);
for (size_t j=0; j<chain.getNrOfJoints(); ++j)
EXPECT_NEAR(solver_jac(3,j), exp->derivative(j), KDL::epsilon);
}
}
开发者ID:SemRoCo,项目名称:giskard,代码行数:46,代码来源:pr2_ik.cpp
示例14: LWR_HSC_nozzle_RCM_used
KDL::Chain kukaControl::LWR_HSC_nozzle_RCM_used() {
KDL::Chain chain;
// base
chain.addSegment(
// KDL::Segment(KDL::Joint(KDL::Joint::None),KDL::Frame::DH_Craig1989(0, 0, 0.33989, 0)));
KDL::Segment(KDL::Joint(KDL::Joint::None),
KDL::Frame::DH_Craig1989(0, 0, 0.34, 0)));
//KDL::Frame::DH_Craig1989(0, M_PI_2, 0.36, 0)));
// joint 1
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, -M_PI_2, 0, 0)));
// joint 2
chain.addSegment(
// KDL::Segment(KDL::Joint(KDL::Joint::RotZ),KDL::Frame::DH_Craig1989(0, M_PI_2, 0.40011, 0)));
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, M_PI_2, 0.40, 0)));
//KDL::Frame::DH_Craig1989(0, M_PI_2, 0.42, 0)));
// joint 3
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, M_PI_2, 0, 0)));
// joint 4
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, -M_PI_2, 0.4000, 0)));
// joint 5
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, -M_PI_2, 0, 0)));
// joint 6
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, M_PI_2, 0, 0)));
// joint 7 (with flange adapter)
/* chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, 0, 0.12597, 0)));*/
// for HSC
chain.addSegment(
KDL::Segment(KDL::Joint(KDL::Joint::RotZ),
KDL::Frame::DH_Craig1989(0, 0,
0.12597 + Dist_from_EndeffectorToRcmPoint, 0)));
return chain;
}
开发者ID:handsomeboy,项目名称:ENPM661-Planning-for-Autonomous-Robots,代码行数:48,代码来源:kukaControl.cpp
示例15: initInternals
void ArmKinematics::initInternals(const KDL::Chain& chain)
{
dof_ = chain.getNrOfJoints();
q_tmp_.resize(dof_);
deleteInternals();
fk_solver_ = new KDL::ChainFkSolverPos_recursive(chain);
ik_solver_ = new KDL::ChainIkSolverVel_wdls(chain);
}
开发者ID:RoboHow,项目名称:cram_seds,代码行数:10,代码来源:arm_kinematics.cpp
示例16: initialize
bool OrientationConstraint::initialize(const arm_navigation_msgs::OrientationConstraint& constraint,
const KDL::Chain& chain)
{
constraint_ = constraint;
link_id_ = -1;
for (unsigned int i=0; i<chain.getNrOfSegments(); ++i)
{
if (constraint_.link_name == chain.getSegment(i).getName())
{
link_id_ = i;
break;
}
}
if (link_id_ == -1)
{
ROS_ERROR("OrientationConstraint: couldn't find link %s in chain.", constraint_.link_name.c_str());
return false;
}
return true;
}
开发者ID:HiroyukiMikita,项目名称:usc-clmc-ros-pkg,代码行数:20,代码来源:constraints.cpp
示例17: getPositionFK
bool ExcavaROBArmKinematics::getPositionFK(excavaROB_arm_kinematics_msgs::GetPositionFK::Request &request,
excavaROB_arm_kinematics_msgs::GetPositionFK::Response &response) {
KDL::Frame p_out;
KDL::JntArray jnt_pos_in;
geometry_msgs::PoseStamped pose;
tf::Stamped<tf::Pose> tf_pose;
if (num_joints_arm_ != request.fk_link_names.size()) {
ROS_ERROR("The request has not the same dimension of the arm_chain joints.");
return false;
}
jnt_pos_in.resize(num_joints_arm_);
for (unsigned int i = 0; i < num_joints_arm_; i++) {
int jnt_index = getJointIndex(request.joint_state.name[i]);
if (jnt_index >= 0)
jnt_pos_in(jnt_index) = request.joint_state.position[i];
}
response.pose_stamped.resize(num_joints_arm_);
response.fk_link_names.resize(num_joints_arm_);
bool valid = true;
for (unsigned int i = 0; i < num_joints_arm_; i++) {
int segmentIndex = getKDLSegmentIndex(request.fk_link_names[i]);
ROS_DEBUG("End effector index: %d", segmentIndex);
ROS_DEBUG("Chain indices: %d", arm_chain_.getNrOfSegments());
if (fk_solver_->JntToCart(jnt_pos_in, p_out, segmentIndex) >= 0) {
tf_pose.frame_id_ = root_name_;
tf_pose.stamp_ = ros::Time();
tf::PoseKDLToTF(p_out, tf_pose);
try {
tf_listener_.transformPose(request.header.frame_id, tf_pose, tf_pose);
} catch (...) {
ROS_ERROR("ExcavaROB Kinematics: Could not transform FK pose to frame: %s", request.header.frame_id.c_str());
response.error_code.val = response.error_code.FRAME_TRANSFORM_FAILURE;
return false;
}
tf::poseStampedTFToMsg(tf_pose, pose);
response.pose_stamped[i] = pose;
response.fk_link_names[i] = request.fk_link_names[i];
response.error_code.val = response.error_code.SUCCESS;
} else {
ROS_ERROR("ExcavaROB Kinematics: Could not compute FK for %s", request.fk_link_names[i].c_str());
response.error_code.val = response.error_code.NO_FK_SOLUTION;
valid = false;
}
}
return true;
}
开发者ID:cmastalli,项目名称:excavabot,代码行数:51,代码来源:excavaROB_arm_kinematics.cpp
示例18: fk_solve_TCP
bool fk_solve_TCP(kinematics_msgs::GetPositionFK::Request &req,
kinematics_msgs::GetPositionFK::Response &res )
{
ROS_INFO("[TESTING]: get_fk_TCP_service has been called!");
unsigned int nj = chain.getNrOfJoints();
ChainFkSolverPos_recursive fksolver1(chain);//Forward position solver
JntArray conf(nj);
geometry_msgs::PoseStamped pose;
tf::Stamped<tf::Pose> tf_pose;
for(int i = 0; i < nj; i++)
conf(i) = req.robot_state.joint_state.position[i];
Frame F_ist;
res.pose_stamped.resize(1);
res.fk_link_names.resize(1);
if(fksolver1.JntToCart(conf, F_ist) >= 0)
{
std::cout << "Calculated Position out of Configuration:\n";
std::cout << F_ist <<"\n";
//TODO: fill out response!!!
tf_pose.frame_id_ = "base_link";//root_name_;
tf_pose.stamp_ = ros::Time();
tf::PoseKDLToTF(F_ist,tf_pose);
try
{
//tf_.transformPose(req.header.frame_id,tf_pose,tf_pose);
}
catch(...)
{
ROS_ERROR("Could not transform FK pose to frame: %s",req.header.frame_id.c_str());
res.error_code.val = res.error_code.FRAME_TRANSFORM_FAILURE;
return false;
}
tf::poseStampedTFToMsg(tf_pose,pose);
res.pose_stamped[0] = pose;
res.fk_link_names[0] = "arm_7_link";
res.error_code.val = res.error_code.SUCCESS;
}
else
{
ROS_ERROR("Could not compute FK for arm_7_link");
res.error_code.val = res.error_code.NO_FK_SOLUTION;
}
return true;
}
开发者ID:browatbn,项目名称:cob_driver,代码行数:51,代码来源:ik_solver_kdl.cpp
示例19: n_tilde
VirtualForcePublisher()
{
ros::NodeHandle n_tilde("~");
ros::NodeHandle n;
// subscribe to joint state
joint_state_sub_ = n.subscribe("joint_states", 1, &VirtualForcePublisher::callbackJointState, this);
wrench_stamped_pub_ = n.advertise<geometry_msgs::WrenchStamped>("wrench", 1);
// set publish frequency
double publish_freq;
n_tilde.param("publish_frequency", publish_freq, 50.0);
publish_interval_ = ros::Duration(1.0/std::max(publish_freq,1.0));
//set time constant of low pass filter
n_tilde.param("time_constant", t_const_, 0.3);
// set root and tip
n_tilde.param("root", root, std::string("torso_lift_link"));
n_tilde.param("tip", tip, std::string("l_gripper_tool_frame"));
// load robot model
urdf::Model robot_model;
robot_model.initParam("robot_description");
KDL::Tree kdl_tree;
kdl_parser::treeFromUrdfModel(robot_model, kdl_tree);
kdl_tree.getChain(root, tip, chain_);
jnt_to_jac_solver_.reset(new KDL::ChainJntToJacSolver(chain_));
jnt_pos_.resize(chain_.getNrOfJoints());
jacobian_.resize(chain_.getNrOfJoints());
for (size_t i=0; i<chain_.getNrOfSegments(); i++) {
if (chain_.getSegment(i).getJoint().getType() != KDL::Joint::None) {
std::cerr << "kdl_chain(" << i << ") " << chain_.getSegment(i).getJoint().getName().c_str() << std::endl;
}
}
}
开发者ID:gitter-badger,项目名称:jsk_common,代码行数:38,代码来源:virtual_force_publisher.cpp
示例20: initialize_kinematics_from_urdf
bool kdl_urdf_tools::initialize_kinematics_from_urdf(
const std::string &robot_description,
const std::string &root_link,
const std::string &tip_link,
unsigned int &n_dof,
KDL::Chain &kdl_chain,
KDL::Tree &kdl_tree,
urdf::Model &urdf_model)
{
if(robot_description.length() == 0) {
ROS_ERROR("URDF string is empty.");
return false;
}
// Construct an URDF model from the xml string
urdf_model.initString(robot_description);
// Get a KDL tree from the robot URDF
if (!kdl_parser::treeFromUrdfModel(urdf_model, kdl_tree)){
ROS_ERROR("Failed to construct kdl tree");
return false;
}
// Populate the KDL chain
if(!kdl_tree.getChain(root_link, tip_link, kdl_chain))
{
ROS_ERROR_STREAM("Failed to get KDL chain from tree: ");
ROS_ERROR_STREAM(" "<<root_link<<" --> "<<tip_link);
ROS_ERROR_STREAM(" Tree has "<<kdl_tree.getNrOfJoints()<<" joints");
ROS_ERROR_STREAM(" Tree has "<<kdl_tree.getNrOfSegments()<<" segments");
ROS_ERROR_STREAM(" The segments are:");
KDL::SegmentMap segment_map = kdl_tree.getSegments();
KDL::SegmentMap::iterator it;
for( it=segment_map.begin();
it != segment_map.end();
it++ )
{
ROS_ERROR_STREAM( " "<<(*it).first);
}
return false;
}
// Store the number of degrees of freedom of the chain
n_dof = kdl_chain.getNrOfJoints();
return true;
}
开发者ID:jhu-lcsr,项目名称:lcsr_ros_orocos_tools,代码行数:50,代码来源:tools.cpp
注:本文中的kdl::Chain类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论