本文整理汇总了C++中Drive::clearFault方法的典型用法代码示例。如果您正苦于以下问题:C++ Drive::clearFault方法的具体用法?C++ Drive::clearFault怎么用?C++ Drive::clearFault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drive
的用法示例。
在下文中一共展示了Drive::clearFault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: motor_wiring
/**
Tests that the motors are wired up correctly.
When running, verify that the motor and direction printed over serial is what
is observed on the robot.
Also prints the change in encoder values after each movement - expect the
readings to positive, and correspond with the motor that moved
*/
void tests::motor_wiring() {
Drive md;
md.resetEncoders();
if(md.faulted()) {
Serial.println("Motor driver has a fault");
md.clearFault();
if(md.faulted()) {
Serial.println("Motor driver still has a fault");
return;
}
}
else
Serial.println("Motors are ok");
{
Serial.print("Motor R, forward: ");
uint32_t encr = md.getMREncoder();
uint32_t encl = md.getMLEncoder();
Serial.flush();
md.setMRSpeed(100);
delay(2e3);
md.setMRSpeed(0);
int32_t diffr = md.getMREncoder() - encr;
int32_t diffl = md.getMLEncoder() - encl;
Serial.print("dr =");
Serial.print(diffr);
Serial.print(", dl =");
Serial.println(diffl);
}
if(md.faulted())
Serial.println("Motor driver has a fault");
{
Serial.print("Motor L, forward: ");
uint32_t encr = md.getMREncoder();
uint32_t encl = md.getMLEncoder();
Serial.flush();
md.setMLSpeed(100);
delay(2e3);
md.setMLSpeed(0);
int32_t diffr = md.getMREncoder() - encr;
int32_t diffl = md.getMLEncoder() - encl;
Serial.print("dr =");
Serial.print(diffr);
Serial.print(", dl =");
Serial.println(diffl);
}
if(md.faulted())
Serial.println("Motor driver has a fault");
}
示例2: motor_feedback
/**
Tests that the PID controllers work
*/
void tests::motor_feedback() {
Drive md;
MotorController cont(md);
EncoderMeasurement measure(md);
uint32_t prevTime;
int i =0;
while(true) {
uint32_t currTime = micros();
if (currTime - prevTime >= PERIOD_MICROS) {
prevTime = currTime;
measure.update();
cont.controlMR(0.1, measure.mVR); // right motor PI control
cont.controlML(-0.1, measure.mVL); //left motor PI control
i++;
if(i % 100 == 0) {
Serial.print(measure.encoderRCount);
Serial.print(", ");
Serial.println(measure.encoderLCount);
Serial.print(": ");
Serial.print(measure.mVR, 4);
Serial.print(", ");
Serial.println(measure.mVL, 4);
}
if(md.faulted()) {
Serial.println("Motor fault");
md.setMLSpeed(0);
md.setMRSpeed(0);
delay(100);
md.clearFault();
}
}
}
}