本文整理汇总了C++中Motor::forward方法的典型用法代码示例。如果您正苦于以下问题:C++ Motor::forward方法的具体用法?C++ Motor::forward怎么用?C++ Motor::forward使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Motor
的用法示例。
在下文中一共展示了Motor::forward方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grabBasePosition
// Turn the Grabber in to an specific angle between -110 to 110 degree:
// Status: Untested
void grabBasePosition(int angle) {
if(angle > NUM_POTENTIOMETER_2_MAX_ANGLE || angle < NUM_POTENTIOMETER_2_MIN_ANGLE){ //Check if the input angle is posible
return;
}
int diff =angle - checkGrabAngle(); //calculate the difference
if(diff<5&&diff>-5){
Serial.println("Grab is not going to turn.");
Serial.print("Diff:");Serial.println(diff);
}
else if(diff<0){
m2.backward(200); //Here is Backward!!!!
}
else if(diff>0){
m2.forward(200);
}
while(diff>5||diff<-5){
diff =angle - checkGrabAngle();
}
m2.brake();
}
示例2: secondaryArmPosition
// Turn Secondary arm in to an specific angle between -110 to 110 degree:
// Status: Untested
void secondaryArmPosition(int angle){
if(angle > NUM_POTENTIOMETER_1_MAX_ANGLE || angle < NUM_POTENTIOMETER_1_MIN_ANGLE){ //Check if the input angle is posible
return;
}
int diff =angle - checkSecondaryArmAngle(); //calculate the difference
if(diff<5&&diff>-5){
Serial.println("Secondary Arm is not going to turn.");
Serial.print("Diff:");Serial.println(diff);
}
else if(diff>0){
m1.forward(255);
}
else if(diff<0){
m1.backward(255);
}
while(diff>5||diff<-5){
diff =angle - checkSecondaryArmAngle();
}
m1.brake();
}