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
|
|
|
}
|
|
|
|
|
2020-07-22 10:42:56 -03:00
|
|
|
// walking robots support roll and pitch
|
|
|
|
float desired_roll, desired_pitch;
|
|
|
|
get_pilot_desired_roll_and_pitch(desired_roll, desired_pitch);
|
|
|
|
g2.motors.set_roll(desired_roll);
|
|
|
|
g2.motors.set_pitch(desired_pitch);
|
|
|
|
|
2019-09-27 16:33:33 -03:00
|
|
|
// set sailboat sails
|
2019-05-25 15:42:18 -03:00
|
|
|
float desired_mainsail;
|
2019-09-27 16:33:33 -03:00
|
|
|
float desired_wingsail;
|
|
|
|
g2.sailboat.get_pilot_desired_mainsail(desired_mainsail, desired_wingsail);
|
2019-05-25 15:42:18 -03:00
|
|
|
g2.motors.set_mainsail(desired_mainsail);
|
2019-09-27 16:33:33 -03:00
|
|
|
g2.motors.set_wingsail(desired_wingsail);
|
2018-09-25 10:09:47 -03:00
|
|
|
|
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
|
|
|
}
|