当前位置: 首页>>代码示例>>C++>>正文


C++ Chain::getNrOfSegments方法代码示例

本文整理汇总了C++中Chain::getNrOfSegments方法的典型用法代码示例。如果您正苦于以下问题:C++ Chain::getNrOfSegments方法的具体用法?C++ Chain::getNrOfSegments怎么用?C++ Chain::getNrOfSegments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chain的用法示例。


在下文中一共展示了Chain::getNrOfSegments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doExport

bool KDLColladaLibraryJointsExporter::doExport(vector <Chain>& kdlChains)
{
    if (kdlChains.empty())
    {
        LOG(DEBUG) << "KDL Chains array is empty, has nothing to export";
        return false;
    }


    LOG(WARNING) << "Taking first element from the KDL chain array";

    Chain kdlChain = kdlChains[0];
    openLibrary();

    unsigned int jointNr = kdlChain.getNrOfSegments();

    for (unsigned int i = 0; i < jointNr; i++)
    {
        Segment segment = kdlChain.getSegment(i);
        Joint kdlJoint = segment.getJoint();
        string uniqueId = defaultJointIdPrefix + toString(i);
        COLLADASW::Joint colladaJoint = makeColladaSWJoint(COLLADASW::LibraryJoints::mSW, kdlJoint, uniqueId);
        LOG(INFO) << "Joint id: " << colladaJoint.getJointId();
        LOG(INFO) << "Joint name: " << colladaJoint.getJointName();
        addJoint(colladaJoint);
        joints.push_back(colladaJoint);
    }

    closeLibrary();

    return true;
}
开发者ID:zakharov,项目名称:KDLCollada,代码行数:32,代码来源:KDLColladaLibraryJointsExporter.cpp

示例2: addChain

bool Tree::addChain(const Chain& chain, const std::string& hook_name) {
    string parent_name = hook_name;
    for (unsigned int i = 0; i < chain.getNrOfSegments(); i++) {
        if (this->addSegment(chain.getSegment(i), parent_name))
          parent_name = chain.getSegment(i).getName();
        else
            return false;
    }
    return true;
}
开发者ID:shakhimardanov,项目名称:orocos_kdl_diamondback,代码行数:10,代码来源:tree.cpp

示例3: addChain

bool Tree::addChain(const Chain& chain, const std::string& chain_name,
        const std::string& hook_name) {
    string parent_name = hook_name;
    for (unsigned int i = 0; i < chain.getNrOfSegments(); i++) {
        ostringstream segment_name;
        segment_name << chain_name << "Segment" << i;
        if (this->addSegment(chain.getSegment(i), segment_name.str(),
                parent_name))
            parent_name = segment_name.str();
        else
            return false;
    }
    return true;
}
开发者ID:Eibriel,项目名称:blender-dfelinto,代码行数:14,代码来源:tree.cpp

示例4: JointsToCartesian

/*
 * To compute the jacobian, we start at the base, and iterate up the chain. We assume that the link we are currently on
 * is the last link in the chain, so the tip of our current link is effectively the end-effector of our chain. Once we compute
 * the jacobian for this pseudo-end effector, we move to the next link, and transform the previously computed jacobian to be for
 * the new end-effector.
 */
int LinkParamJacobianSolver::JointsToCartesian(const Chain& chain, const JntArray& joint_states, LinkParamJacobian& jac)
{
  const unsigned int N = chain.getNrOfJoints() ;

  if ( joint_states.rows() != N )                                 // Sanity check on input data
    return -1 ;

  jac.links_.resize(N) ;

  Frame T_start_to_eef ;                                          // Defines transform from the start of the chain to end-effector [of the part of the chain we've seen so far]
  Frame T_start_to_prev_eef = Frame::Identity() ;

  unsigned int joint_num = 0 ;                                    // Keep track of which joint we're currently on. Since some joints are fixed,
                                                                  //    the joint # could be different than the segment #

  for (unsigned int i=0; i<chain.getNrOfSegments(); i++)                            // Walk up the chain
  {
    const bool movable = chain.getSegment(i).getJoint().getType() != Joint::None ;  // Not sure what the right answer is for dealing with fixed joints
    const bool process_segment = movable ;                                          //    For now, compute Jacobians only for movable joints.

    if(process_segment)
      T_start_to_eef = T_start_to_prev_eef * chain.getSegment(i).pose(joint_states(joint_num)) ;
    else
      T_start_to_eef = T_start_to_prev_eef * chain.getSegment(i).pose(0.0) ;

    Vector cur_segment_length = T_start_to_eef.p - T_start_to_prev_eef.p ;  // Defines vector-length of the current segment in the global frame
    jac.changeRefPoint(cur_segment_length) ;                                // Walk the previously computed jacobians up the chain

    if (process_segment)
    {
      // Build Twists for the translation elements x,y,z.  These translations occur in the base frame of the current segment
      Twist trans_twist[3] ;
      trans_twist[0].vel[0] = 1.0 ;
      trans_twist[0].vel[1] = 0.0 ;
      trans_twist[0].vel[2] = 0.0 ;
      trans_twist[1].vel[0] = 0.0 ;
      trans_twist[1].vel[1] = 1.0 ;
      trans_twist[1].vel[2] = 0.0 ;
      trans_twist[2].vel[0] = 0.0 ;
      trans_twist[2].vel[1] = 0.0 ;
      trans_twist[2].vel[2] = 1.0 ;

      // Build rotation from start to base frame of current link. This also includes the rotation from the current link's joint.
      Rotation R_start_to_cur_base = T_start_to_prev_eef.M * chain.getSegment(i).getJoint().pose(joint_states(joint_num)).M ;
      for (int j=0; j<3; j++)
      {
        trans_twist[j] = R_start_to_cur_base*trans_twist[j] ;                 // Rotate translations from the base frame of the current link to the start frame
        jac.links_[joint_num].trans_[j] = trans_twist[j] ;                   // Copy data into the output datatype
      }

      // Build Twists for incremental rotations at the end of the segment.  These translations occur after the segment transform.
      Twist rot_twist[3] ;

      // First build twists in the [current] end-effector frame
      rot_twist[0].rot[0] = 1.0 ;
      rot_twist[0].rot[1] = 0.0 ;
      rot_twist[0].rot[2] = 0.0 ;
      rot_twist[1].rot[0] = 0.0 ;
      rot_twist[1].rot[1] = 1.0 ;
      rot_twist[1].rot[2] = 0.0 ;
      rot_twist[2].rot[0] = 0.0 ;
      rot_twist[2].rot[1] = 0.0 ;
      rot_twist[2].rot[2] = 1.0 ;

      // Now we need to transform these rotation twists to the base (beginning-of-segment) frame
      for (int j=0; j<3; j++)
      {
        rot_twist[j] = T_start_to_eef.M*rot_twist[j] ;
        jac.links_[joint_num].rot_[j] = rot_twist[j] ;                                   // Copy data into the output datatype
      }
    }
    if (movable)
      joint_num++ ;

    T_start_to_prev_eef = T_start_to_eef ;
  }
  return 0 ;
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:84,代码来源:link_param_jacobian_solver.cpp


注:本文中的Chain::getNrOfSegments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。