2017-07-18 23:17:45 -03:00
|
|
|
#include "mode.h"
|
|
|
|
#include "Rover.h"
|
|
|
|
|
2018-05-10 04:10:34 -03:00
|
|
|
void ModeManual::_exit()
|
|
|
|
{
|
|
|
|
// clear lateral when exiting manual mode
|
|
|
|
g2.motors.set_lateral(0);
|
|
|
|
}
|
|
|
|
|
2017-07-18 23:17:45 -03:00
|
|
|
void ModeManual::update()
|
|
|
|
{
|
2018-05-10 04:10:34 -03:00
|
|
|
float desired_steering, desired_throttle, desired_lateral;
|
2017-11-29 03:12:13 -04:00
|
|
|
get_pilot_desired_steering_and_throttle(desired_steering, desired_throttle);
|
2018-05-10 04:10:34 -03:00
|
|
|
get_pilot_desired_lateral(desired_lateral);
|
2017-11-29 03:12:13 -04:00
|
|
|
|
2018-06-20 11:12:05 -03:00
|
|
|
// if vehicle is balance bot, calculate actual throttle required for balancing
|
2018-06-21 09:36:58 -03:00
|
|
|
if (rover.is_balancebot()) {
|
2018-08-04 04:25:07 -03:00
|
|
|
rover.balancebot_pitch_control(desired_throttle);
|
2018-06-20 11:12:05 -03:00
|
|
|
}
|
|
|
|
|
2018-09-25 10:09:47 -03:00
|
|
|
// set sailboat mainsail from throttle position
|
|
|
|
g2.motors.set_mainsail(desired_throttle);
|
|
|
|
|
2017-11-29 03:12:13 -04:00
|
|
|
// copy RC scaled inputs to outputs
|
|
|
|
g2.motors.set_throttle(desired_throttle);
|
2018-05-03 05:58:27 -03:00
|
|
|
g2.motors.set_steering(desired_steering, false);
|
2018-05-10 04:10:34 -03:00
|
|
|
g2.motors.set_lateral(desired_lateral);
|
2017-07-18 23:17:45 -03:00
|
|
|
}
|