Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Rover/mode_acro.cpp
Views: 1798
#include "Rover.h"12void ModeAcro::update()3{4// get speed forward5float speed, desired_steering;6if (!attitude_control.get_forward_speed(speed)) {7float desired_throttle;8// convert pilot stick input into desired steering and throttle9get_pilot_desired_steering_and_throttle(desired_steering, desired_throttle);1011// if vehicle is balance bot, calculate actual throttle required for balancing12if (rover.is_balancebot()) {13rover.balancebot_pitch_control(desired_throttle);14}1516// no valid speed, just use the provided throttle17g2.motors.set_throttle(desired_throttle);18} else {19float desired_speed;20// convert pilot stick input into desired steering and speed21get_pilot_desired_steering_and_speed(desired_steering, desired_speed);22calc_throttle(desired_speed, true);23}2425float steering_out;2627// handle sailboats28if (!is_zero(desired_steering)) {29// steering input return control to user30g2.sailboat.clear_tack();31}32if (g2.sailboat.tacking()) {33// call heading controller during tacking3435steering_out = attitude_control.get_steering_out_heading(g2.sailboat.get_tack_heading_rad(),36g2.wp_nav.get_pivot_rate(),37g2.motors.limit.steer_left,38g2.motors.limit.steer_right,39rover.G_Dt);40} else {41// convert pilot steering input to desired turn rate in radians/sec42const float target_turn_rate = (desired_steering / 4500.0f) * radians(g2.acro_turn_rate);4344// run steering turn rate controller and throttle controller45steering_out = attitude_control.get_steering_out_rate(target_turn_rate,46g2.motors.limit.steer_left,47g2.motors.limit.steer_right,48rover.G_Dt);49}5051set_steering(steering_out * 4500.0f);52}5354bool ModeAcro::requires_velocity() const55{56return !g2.motors.have_skid_steering();57}5859// sailboats in acro mode support user manually initiating tacking from transmitter60void ModeAcro::handle_tack_request()61{62g2.sailboat.handle_tack_request_acro();63}646566