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/ArduSub/mode_acro.cpp
Views: 1798
#include "Sub.h"1234#include "Sub.h"567bool ModeAcro::init(bool ignore_checks) {8// set target altitude to zero for reporting9position_control->set_pos_desired_z_cm(0);1011// attitude hold inputs become thrust inputs in acro mode12// set to neutral to prevent chaotic behavior (esp. roll/pitch)13sub.set_neutral_controls();1415return true;16}1718void ModeAcro::run()19{20float target_roll, target_pitch, target_yaw;2122// if not armed set throttle to zero and exit immediately23if (!motors.armed()) {24motors.set_desired_spool_state(AP_Motors::DesiredSpoolState::GROUND_IDLE);25attitude_control->set_throttle_out(0,true,g.throttle_filt);26attitude_control->relax_attitude_controllers();27return;28}2930motors.set_desired_spool_state(AP_Motors::DesiredSpoolState::THROTTLE_UNLIMITED);3132// convert the input to the desired body frame rate33get_pilot_desired_angle_rates(channel_roll->get_control_in(), channel_pitch->get_control_in(), channel_yaw->get_control_in(), target_roll, target_pitch, target_yaw);3435// run attitude controller36attitude_control->input_rate_bf_roll_pitch_yaw(target_roll, target_pitch, target_yaw);3738// output pilot's throttle without angle boost39attitude_control->set_throttle_out(channel_throttle->norm_input(), false, g.throttle_filt);4041//control_in is range 0-100042//radio_in is raw pwm value43motors.set_forward(channel_forward->norm_input());44motors.set_lateral(channel_lateral->norm_input());45}464748