本文整理汇总了C++中Arm::GetTilt方法的典型用法代码示例。如果您正苦于以下问题:C++ Arm::GetTilt方法的具体用法?C++ Arm::GetTilt怎么用?C++ Arm::GetTilt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arm
的用法示例。
在下文中一共展示了Arm::GetTilt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: control_arm_motor
/**
* This function runs in the control thread, and continually sets the motors to the correct speed.
* The speed is determined by the difference in angle divided by a constant.
*/
void Arm::control_arm_motor( void *object )
{
Arm *instance = (Arm *) object;
instance->upperArmAngle = instance->GetTilt();
// Runs when the difference in angles is large enough
//TODO: fix kCloseEnough with real value
while ( fabs( instance->upperArmAngle - instance->arm_control_angle ) > kCloseEnough )
{
instance->upperArmAngle = instance->GetTilt();
if (((instance->upperArmAngle-instance->arm_control_angle ) / 700 < 0.5) && ((instance->upperArmAngle-instance->arm_control_angle ) / 2000 > 0) )
{
instance->armMotor.Set(0.5);
}
else if (((instance->upperArmAngle-instance->arm_control_angle ) / 700 > -0.5) && ((instance->upperArmAngle-instance->arm_control_angle ) / 2000 < 0) )
{
instance->armMotor.Set(-0.5);
}
else if ((instance->upperArmAngle-instance->arm_control_angle ) / 700 >= 1.0 )
{
instance->armMotor.Set(1.0);
}
else if ((instance->upperArmAngle-instance->arm_control_angle ) / 700 <= -1.0 )
{
instance->armMotor.Set(-1.0);
}
else
{
instance->armMotor.Set( ( instance->upperArmAngle-instance->arm_control_angle ) / 700 );
}
Wait( 0.05 );
}
instance->armMotor.Set( 0.0 );
}