本文整理汇总了C++中Gyro::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Gyro::set方法的具体用法?C++ Gyro::set怎么用?C++ Gyro::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gyro
的用法示例。
在下文中一共展示了Gyro::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void) {
int enc_now[2] = {},
enc_old[2] = {},
push_time[3] = {},
_build_mode = 0;
float yaw_now = 0,
yaw_old = 0;
bool Start = false;
//Initialise Systick
MillisecondTimer::initialise();
Nvic::initialise();
MainV3 mainBoard;
SpiMotor spimotor( *mainBoard.spi3v1, 1);
MillisecondTimer::delay(100);
PS3Con *ps3con = new PS3Con();
mainBoard.can.AddListenerNode(ps3con);
mainBoard.mpu6050.setTimeout(20);
debug<<"[INFO]Testing MPU6050...\r\n";
while(!mainBoard.mpu6050.test());
debug<<"[INFO]MPU6050 test passed.\r\n";
debug<<"[INFO]Setting up MPU6050...\r\n";
mainBoard.mpu6050.setup();
mainBoard.mpu6050.setGyrRange(mainBoard.mpu6050.GYR_RANGE_500DPS);
debug<<"[INFO]Setup complete!\r\n";
SensorTimer sensor_timer(&mainBoard);
Machine machine;
Gyro gyro;
Builder build(&mainBoard,&machine);
//Reset
build.Reset();
while (1) {
int rotation_gyro = 0,
rotation = 0,
D_out = 0,
SPI_out = 0,
X_100 = 0,
Y_100 = 0;
float A_out = 0,
B_out = 0,
C_out = 0;
mainBoard.can.Update();
mainBoard.buzzer.stop();
//Safety start
if (Start == false || ps3con->getButtonPress(CONNECTED) == 0) {
if (ps3con->getButtonPress(START)){
Start = true;
debug << "[INFO]Safety launch success!\r\n";
}else{
debug << "[WARN]Please push START button.\r\n";
}
if (Start == true) mainBoard.buzzer.set(-1, 6);
else mainBoard.buzzer.flash();
mainBoard.led.flash();
build.changeMode(NO_CAHNGE);
D_out = build.pwmArm((int)mainBoard.ad[2]->get());
SPI_out = build.pwmPlate((int)mainBoard.ad[3]->get());
setLimit(D_out,300);
setLimit(SPI_out,200);
mainBoard.motorD.setOutput((float) D_out / 500.0);
spimotor.setOutput((float) SPI_out / 500.0);
MillisecondTimer::delay(50);
continue;
}else if(Start == true && ps3con->getButtonPress(START)){//Emergency stop
mainBoard.buzzer.set(-1, 4);
debug << "[WARN]Emergency stop!!\r\n";
Start = false;
build.Reset();
//PWM output
mainBoard.motorA.setOutput(0 / 500.0);
mainBoard.motorB.setOutput(0 / 500.0);
mainBoard.motorC.setOutput(0 / 500.0);
mainBoard.motorD.setOutput(0 / 500.0);
spimotor.setOutput(0/500.0);
MillisecondTimer::delay(200);
continue;
//.........这里部分代码省略.........