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


C++ DyLink类代码示例

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


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

示例1: lock

void AISTSimulatorItemImpl::doSetForcedPosition()
{
    boost::unique_lock<boost::mutex> lock(forcedBodyPositionMutex);
    DyLink* rootLink = forcedPositionBody->rootLink();
    rootLink->setPosition(forcedBodyPosition);
    rootLink->v().setZero();
    rootLink->w().setZero();
    rootLink->vo().setZero();
    forcedPositionBody->calcSpatialForwardKinematics();
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:10,代码来源:AISTSimulatorItem.cpp

示例2: addBody

void AISTSimulatorItemImpl::addBody(AISTSimBody* simBody)
{
    DyBody* body = static_cast<DyBody*>(simBody->body());

    DyLink* rootLink = body->rootLink();
    rootLink->v().setZero();
    rootLink->dv().setZero();
    rootLink->w().setZero();
    rootLink->dw().setZero();
    rootLink->vo().setZero();
    rootLink->dvo().setZero();

    for(int i=0; i < body->numLinks(); ++i){
        Link* link = body->link(i);
        link->u() = 0.0;
        link->dq() = 0.0;
        link->ddq() = 0.0;
    }
    
    body->clearExternalForces();
    body->calcForwardKinematics(true, true);

    int bodyIndex;
    if(dynamicsMode.is(AISTSimulatorItem::HG_DYNAMICS)){
        ForwardDynamicsCBMPtr cbm = make_shared_aligned<ForwardDynamicsCBM>(body);
        cbm->setHighGainModeForAllJoints();
        bodyIndex = world.addBody(body, cbm);
    } else {
        bodyIndex = world.addBody(body);
    }
    bodyIndexMap[body] = bodyIndex;
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:32,代码来源:AISTSimulatorItem.cpp

示例3: initialize

void ForwardDynamicsABM::initialize()
{
    DyLink* rootLink = body->rootLink();
    rootLink->sw().setZero();
    rootLink->sv().setZero();
    rootLink->cv().setZero();
    rootLink->cw().setZero();
    rootLink->hhv().setZero();
    rootLink->hhw().setZero();
    rootLink->uu() = 0.0;
    rootLink->dd() = 0.0;

    initializeSensors();
    calcABMFirstHalf();
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:15,代码来源:ForwardDynamicsABM.cpp

示例4: extractBodyContactPoints

void ContactForceExtractorItem::extractBodyContactPoints(DyBody* body, ostream& os)
{
    bool put = false;
    for(int i=0; i < body->numLinks(); ++i){
        DyLink* link = body->link(i);
        DyLink::ConstraintForceArray& forces = link->constraintForces();
        if(!forces.empty()){
            if(!put){
                os << body->name() << ":\n";
                put = true;
            }
            os << " " << link->name() << ":\n";
            for(size_t i=0; i < forces.size(); ++i){
                const DyLink::ConstraintForce& force = forces[i];
                const Vector3& p = force.point;
                const Vector3& f = force.force;
                os << "  point(" << p.x() << ", " << p.y() << ", " << p.z()
                   << "), force(" << f.x() << ", " << f.y() << ", " << f.z() << ")\n";
            }
        }
    }
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:22,代码来源:ContactForceExtractionSamplePlugin.cpp

示例5: calcABMLastHalf

void ForwardDynamicsABM::calcMotionWithEulerMethod()
{
    calcABMLastHalf();

    if(!sensorHelper.forceSensors().empty()){
        updateForceSensors();
    }

    DyLink* root = body->rootLink();

    if(!root->isFixedJoint()){
        root->dv() =
            root->dvo() - root->p().cross(root->dw())
            + root->w().cross(root->vo() + root->w().cross(root->p()));
        Position T;
        SE3exp(T, root->T(), root->w(), root->vo(), timeStep);
        root->T() = T;
        root->vo() += root->dvo() * timeStep;
        root->w()  += root->dw()  * timeStep;
    }

    int n = body->numLinks();
    for(int i=1; i < n; ++i){
        DyLink* link = body->link(i);
        link->q()  += link->dq()  * timeStep;
        link->dq() += link->ddq() * timeStep;
    }
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:28,代码来源:ForwardDynamicsABM.cpp

示例6: a

void ForwardDynamicsABM::calcABMPhase3()
{
    const LinkTraverse& traverse = body->linkTraverse();

    DyLink* root = static_cast<DyLink*>(traverse[0]);

    if(root->isFreeJoint()){

        // - | Ivv  trans(Iwv) | * | dvo | = | pf   |
        //   | Iwv     Iww     |   | dw  |   | ptau |

        Eigen::Matrix<double, 6, 6> M;
        M << root->Ivv(), root->Iwv().transpose(),
            root->Iwv(), root->Iww();
        
        Eigen::Matrix<double, 6, 1> f;
        f << root->pf(),
            root->ptau();
        f *= -1.0;

        Eigen::Matrix<double, 6, 1> a(M.colPivHouseholderQr().solve(f));

        root->dvo() = a.head<3>();
        root->dw() = a.tail<3>();

    } else {
        root->dvo().setZero();
        root->dw().setZero();
    }

    const int n = traverse.numLinks();
    for(int i=1; i < n; ++i){
        DyLink* link = static_cast<DyLink*>(traverse[i]);
        const DyLink* parent = link->parent();
        if(!link->isFixedJoint()){
            link->ddq() = (link->uu() - (link->hhv().dot(parent->dvo()) + link->hhw().dot(parent->dw()))) / link->dd();
            link->dvo().noalias() = parent->dvo() + link->cv() + link->sv() * link->ddq();
            link->dw().noalias()  = parent->dw()  + link->cw() + link->sw() * link->ddq();
        }else{
            link->ddq() = 0.0;
            link->dvo() = parent->dvo();
            link->dw()  = parent->dw(); 
        }
    }
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:45,代码来源:ForwardDynamicsABM.cpp

示例7:

// A remaining part of phase 2 that requires external forces
void ForwardDynamicsABM::calcABMPhase2Part2()
{
    const LinkTraverse& traverse = body->linkTraverse();
    const int n = traverse.numLinks();

    for(int i = n-1; i >= 0; --i){
        DyLink* link = static_cast<DyLink*>(traverse[i]);

        link->pf()   -= link->f_ext();
        link->ptau() -= link->tau_ext();

        for(DyLink* child = link->child(); child; child = child->sibling()){
            link->pf()   += child->pf();
            link->ptau() += child->ptau();

            if(!child->isFixedJoint()){
                const double uu_dd = child->uu() / child->dd();
                link->pf()   += uu_dd * child->hhv();
                link->ptau() += uu_dd * child->hhw();
            }
        }

        if(i > 0){
            if(!link->isFixedJoint()){
                link->uu() += link->u() - (link->sv().dot(link->pf()) + link->sw().dot(link->ptau()));
            }
        }
    }
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:30,代码来源:ForwardDynamicsABM.cpp

示例8: switch

/**
   \note v, dv, dw are not used in the forward dynamics, but are calculated
   for forward dynamics users.
*/
void ForwardDynamicsABM::calcABMPhase1(bool updateNonSpatialVariables)
{
    const LinkTraverse& traverse = body->linkTraverse();
    const int n = traverse.numLinks();

    for(int i=0; i < n; ++i){
        DyLink* link = static_cast<DyLink*>(traverse[i]);
        const DyLink* parent = link->parent();

        if(parent){
            
            switch(link->jointType()){
                
            case Link::ROTATIONAL_JOINT:
            {
                const Vector3 arm = parent->R() * link->b();
                link->R().noalias() = parent->R() * AngleAxisd(link->q(), link->a());
                link->p().noalias() = arm + parent->p();
                link->sw().noalias() = parent->R() * link->a();
                link->sv().noalias() = link->p().cross(link->sw());
                link->w().noalias() = link->dq() * link->sw() + parent->w();
                if(updateNonSpatialVariables){
                    link->dw().noalias() =
                        parent->dw() + link->dq() * parent->w().cross(link->sw()) + (link->ddq() * link->sw());
                    link->dv().noalias() =
                        parent->dv() + parent->w().cross(parent->w().cross(arm)) + parent->dw().cross(arm);
                }
                break;
            }
                
            case Link::SLIDE_JOINT:
                link->p().noalias() = parent->R() * (link->b() + link->q() * link->d()) + parent->p();
                link->R() = parent->R();
                link->sw().setZero();
                link->sv().noalias() = parent->R() * link->d();
                link->w() = parent->w();
                if(updateNonSpatialVariables){
                    link->dw() = parent->dw();
                    const Vector3 arm = parent->R() * link->b();
                    link->dv().noalias() =
                        parent->dv() + parent->w().cross(parent->w().cross(arm)) + parent->dw().cross(arm)
                        + 2.0 * link->dq() * parent->w().cross(link->sv()) + link->ddq() * link->sv();
                }
                break;
                
            case Link::FIXED_JOINT:
            default:
                link->p().noalias() = parent->R() * link->b() + parent->p();
                link->R() = parent->R();
                link->w() = parent->w();
                link->vo() = parent->vo();
                link->sw().setZero();
                link->sv().setZero();
                link->cv().setZero();
                link->cw().setZero();
                if(updateNonSpatialVariables){
                    link->dw() = parent->dw();
                    const Vector3 arm = parent->R() * link->b();
                    link->dv().noalias() = parent->dv() +
                        parent->w().cross(parent->w().cross(arm)) + parent->dw().cross(arm);
                }
                
                goto COMMON_CALCS_FOR_ALL_JOINT_TYPES;
            }
            
            // Common for ROTATE and SLIDE
            link->vo().noalias() = link->dq() * link->sv() + parent->vo();
            const Vector3 dsv = parent->w().cross(link->sv()) + parent->vo().cross(link->sw());
            const Vector3 dsw = parent->w().cross(link->sw());
            link->cv() = link->dq() * dsv;
            link->cw() = link->dq() * dsw;
        }
        
COMMON_CALCS_FOR_ALL_JOINT_TYPES:

        if(updateNonSpatialVariables){
            link->v().noalias() = link->vo() + link->w().cross(link->p());
        }
        link->wc().noalias() = link->R() * link->c() + link->p();
        
        // compute I^s (Eq.(6.24) of Kajita's textbook))
        const Matrix3 Iw = link->R() * link->I() * link->R().transpose();
        
        const double m = link->m();
        const Matrix3 c_hat = hat(link->wc());
        link->Iww().noalias() = m * c_hat * c_hat.transpose() + Iw;

        link->Ivv() <<
            m,  0.0, 0.0,
            0.0,  m,  0.0,
            0.0, 0.0,  m;
        
        link->Iwv() = m * c_hat;
        
        // compute P and L (Eq.(6.25) of Kajita's textbook)
        const Vector3 P = m * (link->vo() + link->w().cross(link->wc()));
//.........这里部分代码省略.........
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:101,代码来源:ForwardDynamicsABM.cpp

示例9: SE3exp

void ForwardDynamicsABM::integrateRungeKuttaOneStep(double r, double dt)
{
    DyLink* root = body->rootLink();

    if(!root->isFixedJoint()){

        SE3exp(root->T(), T0, root->w(), root->vo(), dt);
        root->vo().noalias() = vo0 + root->dvo() * dt;
        root->w().noalias()  = w0  + root->dw()  * dt;

        vo  += r * root->vo();
        w   += r * root->w();
        dvo += r * root->dvo();
        dw  += r * root->dw();
    }

    int n = body->numLinks();
    for(int i=1; i < n; ++i){

        DyLink* link = body->link(i);

        link->q()  =  q0[i] + dt * link->dq();
        link->dq() = dq0[i] + dt * link->ddq();

        dq[i]  += r * link->dq();
        ddq[i] += r * link->ddq();
    }
}
开发者ID:fkanehiro,项目名称:choreonoid,代码行数:28,代码来源:ForwardDynamicsABM.cpp


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