2017-07-18 23:17:45 -03:00
|
|
|
#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-08-28 15:51:26 -03:00
|
|
|
// walking robots support roll, pitch and walking_height
|
|
|
|
float desired_roll, desired_pitch, desired_walking_height;
|
2020-07-22 10:42:56 -03:00
|
|
|
get_pilot_desired_roll_and_pitch(desired_roll, desired_pitch);
|
2020-08-28 15:51:26 -03:00
|
|
|
get_pilot_desired_walking_height(desired_walking_height);
|
2020-07-22 10:42:56 -03:00
|
|
|
g2.motors.set_roll(desired_roll);
|
|
|
|
g2.motors.set_pitch(desired_pitch);
|
2020-08-28 15:51:26 -03:00
|
|
|
g2.motors.set_walking_height(desired_walking_height);
|
2020-07-22 10:42:56 -03:00
|
|
|
|
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;
|
2021-04-27 16:50:36 -03:00
|
|
|
float desired_mast_rotation;
|
|
|
|
g2.sailboat.get_pilot_desired_mainsail(desired_mainsail, desired_wingsail, desired_mast_rotation);
|
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);
|
2021-04-27 16:50:36 -03:00
|
|
|
g2.motors.set_mast_rotation(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);
|
2022-07-05 15:21:10 -03:00
|
|
|
g2.motors.set_steering(desired_steering, (g2.manual_options & ManualOptions::SPEED_SCALING));
|
2018-05-10 04:10:34 -03:00
|
|
|
g2.motors.set_lateral(desired_lateral);
|
2017-07-18 23:17:45 -03:00
|
|
|
}
|