Repository for verBOT robot project, hopefully featuring two branches: Dev/Test and Prod.
Dependencies: PM2_Libary Eigen
Diff: main.cpp
- Revision:
- 31:1b2a1bd1bccb
- Parent:
- 30:1e8295770bc1
- Child:
- 36:8c75783c1eca
--- a/main.cpp Tue Mar 22 10:45:49 2022 +0100 +++ b/main.cpp Wed Mar 23 11:23:19 2022 +0100 @@ -90,9 +90,9 @@ pwm_M1.period(pwm_period_s); pwm_M1.write(0.5f); - // enable servos, you can also disable them at any point in your program if you don't want your servos to become warm - servo_S1.Enable(servo_S1_angle, servo_period_mus); - servo_S2.Enable(servo_S2_angle, servo_period_mus); + // set the soft pwm period for the servo objects + servo_S1.SetPeriod(servo_period_mus); + servo_S2.SetPeriod(servo_period_mus); while (true) { // this loop will run forever @@ -115,15 +115,15 @@ } // check if servos are enabled - if (!servo_S1.isEnabled()) servo_S1.Enable(servo_S1_angle, servo_period_mus); - if (!servo_S2.isEnabled()) servo_S2.Enable(servo_S2_angle, servo_period_mus); + if (!servo_S1.isEnabled()) servo_S1.Enable(); + if (!servo_S2.isEnabled()) servo_S2.Enable(); // command servo position, this needs to be calibrated servo_S1.SetPosition(servo_S1_angle); - if (servo_S1_angle <= 1.0f & servo_counter%loops_per_seconds == 0 & servo_counter != 0) { + if (servo_S1_angle < 1.0f & servo_counter%loops_per_seconds == 0 & servo_counter != 0) { servo_S1_angle += 0.01f; } servo_S2.SetPosition(servo_S2_angle); - if (servo_S2_angle <= 1.0f & servo_counter%loops_per_seconds == 0 & servo_counter != 0) { + if (servo_S2_angle < 1.0f & servo_counter%loops_per_seconds == 0 & servo_counter != 0) { servo_S2_angle += 0.01f; } servo_counter++;