|
@@ -46,23 +46,23 @@ main(int argc, char **argv)
|
46
|
46
|
{
|
47
|
47
|
float voltage = 0;
|
48
|
48
|
|
49
|
|
- cout << "SmartDrive demo is starting. Please make sure drive is connected to board" << endl;
|
|
49
|
+ std::cout << "SmartDrive demo is starting. Please make sure drive is connected to board" << std::endl;
|
50
|
50
|
sleep(2); //Wait for 2 seconds in case you want to fix your h/w setup
|
51
|
51
|
|
52
|
52
|
// Instantiate a SmartDrive connected to /dev/i2c-0 bus, using DefaultAddress
|
53
|
53
|
drive = new upm::SmartDrive(0);
|
54
|
54
|
|
55
|
|
- cout << "Battery Voltage before motor run : " << drive.GetBattVoltage() << std::endl;
|
56
|
|
- //Set motor M1 to run for 300seconds, with speed of 15RPM, waith for it to finish and then Brake It
|
57
|
|
- drive->Run_Seconds(Motor_ID_M1, Dir_Forward, 15, 300, true, Action_Brake );
|
58
|
|
- std::cout << "Battery Voltage after motor run : " << drive.GetBattVoltage() << std::endl;
|
59
|
|
- //Rotate motor M2 2270 degrees, in reverse sens, with speed of 10RPM, return immediately from function call
|
60
|
|
- drive->Run_Degrees(Motor_ID_M2, Dir_Reverse, 10, 2270, false, Action_Float);
|
|
55
|
+ std::cout << "Battery Voltage before motor run : " << drive->GetBattVoltage() << std::endl;
|
|
56
|
+ //Set motor M1 to run for 120 seconds, with speed of 15RPM, waith for it to finish and then Brake It
|
|
57
|
+ drive->Run_Seconds(SmartDrive_Motor_ID_1, SmartDrive_Dir_Forward, 15, 120, true, SmartDrive_Action_Brake);
|
|
58
|
+ std::cout << "Battery Voltage after motor run : " << drive->GetBattVoltage() << std::endl;
|
|
59
|
+ //Rotate motor M2 2270 degrees, in reverse sense, with speed of 10RPM, return immediately from function call
|
|
60
|
+ drive->Run_Degrees(SmartDrive_Motor_ID_2, SmartDrive_Dir_Reverse, 10, 2270, false, SmartDrive_Action_Float);
|
61
|
61
|
//While motor is running, Display its status
|
62
|
|
- drive->PrintMotorStatus(Motor_ID_M2);
|
|
62
|
+ drive->PrintMotorStatus(SmartDrive_Motor_ID_2);
|
63
|
63
|
sleep(2); //Sleep for 2 seconds
|
64
|
64
|
//Stop motor M2 and then finish program
|
65
|
|
- drive->StopMotor(Motor_ID_M2, Action_BrakeHold );
|
|
65
|
+ drive->StopMotor(SmartDrive_Motor_ID_2, SmartDrive_Action_BrakeHold);
|
66
|
66
|
|
67
|
67
|
std::cout << "Demo complete. GoodBye" << std::endl;
|
68
|
68
|
|