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


C++ Arm::startMotion方法代码示例

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


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

示例1: updateArm

void ArmMotionEngine::updateArm(Arm& arm, ArmMotionEngineOutputBH& armMotionEngineOutput)
{
  // assume arm should not be moved.
  armMotionEngineOutput.arms[arm.id].move = false;

  // make sure to not interfere with other motion engines
  if(theFallDownStateBH.state == FallDownStateBH::onGround ||
    theMotionInfoBH.motion == MotionInfoBH::getUp)
  {
    arm.isMotionActive = false;
    return;
  }

  if(newMotionPossible(arm))
  {
    // no motion is active, so decide what to do.
    // behavior overrides contact triggered motions
    if(theArmMotionRequestBH.motion[arm.id] != ArmMotionRequestBH::useDefault)
    {
      ArmMotion nextMotion = allMotions[theArmMotionRequestBH.motion[arm.id]];
      arm.contactTriggered = false;
      arm.startMotion(nextMotion,
        theArmMotionRequestBH.fast[arm.id],
        theArmMotionRequestBH.autoReverse[arm.id],
        theArmMotionRequestBH.autoReverseTime[arm.id],
        theFilteredJointDataBH);

    } else if(theFrameInfoBH.getTimeSince(arm.lastContactAction) > actionDelay &&
      (arm.id == ArmMotionRequestBH::left ? theArmContactModelBH.contactLeft : theArmContactModelBH.contactRight))
    {
#ifdef TARGET_ROBOT
      // check for armcontact
      ArmContactModelBH::PushDirection dir = (arm.id == ArmMotionRequestBH::left)
        ? theArmContactModelBH.pushDirectionLeft
        : theArmContactModelBH.pushDirectionRight;

      switch(dir)
      {
      case ArmContactModelBH::S:
      case ArmContactModelBH::SW:
      case ArmContactModelBH::SE:
        arm.lastContactAction = theFrameInfoBH.time;
        arm.contactTriggered = true;
        arm.startMotion(allMotions[ArmMotionRequestBH::back], false, true, targetTime, theFilteredJointDataBH);
        break;
      default:
        break;
      }
#endif
    }
  }

  // when falling, try to set emergency mode fast
  if(theFallDownStateBH.state == FallDownStateBH::falling && arm.isMotionActive && arm.currentMotion.id != ArmMotionRequestBH::falling)
  {
    arm.startMotion(allMotions[ArmMotionRequestBH::falling], true, false, 0, theFilteredJointDataBH);
  }
  else if((theFallDownStateBH.state == FallDownStateBH::falling || theFallDownStateBH.state == FallDownStateBH::onGround || !theGroundContactStateBH.contact) &&
    !arm.isMotionActive)
  {
    // fallen
    return;
  }
  else if(theMotionInfoBH.motion == MotionInfoBH::bike && arm.isMotionActive && arm.currentMotion.id != ArmMotionRequestBH::useDefault)
  {
    arm.startMotion(allMotions[ArmMotionRequestBH::useDefault], true, false, 0, theFilteredJointDataBH);
  }

  // test whether a motion is active now
  if(arm.isMotionActive)
  {
    // a motion is active, so decide what to do

    if(arm.stateIndex == arm.currentMotion.states.size())
    {
      // arm reached its motion target
      ++arm.targetTime;

      if(arm.currentMotion.id == ArmMotionRequestBH::useDefault)
      {
        // arm is in default position, so ARME won't output any angles
        armMotionEngineOutput.arms[arm.id].move = false;
        arm.isMotionActive = false;
      }
      else if((arm.autoReverse && arm.targetTime == arm.autoReverseTime) || // target time ran out
        (!theGroundContactStateBH.contact) ||  // ground contact lost
        (theArmMotionRequestBH.motion[arm.id] != arm.currentMotion.id && !arm.contactTriggered))  // different motion requested
      {
        // start a reversed motion to reach the default position
        arm.startMotion(arm.currentMotion.reverse(defaultPos),
          theArmMotionRequestBH.fast[arm.id], false, 0, theFilteredJointDataBH);
      }
      else
      {
        // stay in target position
        updateOutput(arm, armMotionEngineOutput, arm.currentMotion.getTargetState());
      }
    }
    else
    {
//.........这里部分代码省略.........
开发者ID:CheddarB,项目名称:nbites,代码行数:101,代码来源:ArmMotionEngine.cpp


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