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


C++ Drive::clearFault方法代码示例

本文整理汇总了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");
}
开发者ID:eric-wieser,项目名称:2.12-robot,代码行数:61,代码来源:tests.cpp

示例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();
			}
		}
	}

}
开发者ID:eric-wieser,项目名称:2.12-robot,代码行数:42,代码来源:tests.cpp


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