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/ArduPlane/mode_fbwa.cpp
Views: 1798
#include "mode.h"1#include "Plane.h"23void ModeFBWA::update()4{5// set nav_roll and nav_pitch using sticks6plane.nav_roll_cd = plane.channel_roll->norm_input() * plane.roll_limit_cd;7plane.update_load_factor();8float pitch_input = plane.channel_pitch->norm_input();9if (pitch_input > 0) {10plane.nav_pitch_cd = pitch_input * plane.aparm.pitch_limit_max*100;11} else {12plane.nav_pitch_cd = -(pitch_input * plane.pitch_limit_min*100);13}14plane.adjust_nav_pitch_throttle();15plane.nav_pitch_cd = constrain_int32(plane.nav_pitch_cd, plane.pitch_limit_min*100, plane.aparm.pitch_limit_max.get()*100);16if (plane.fly_inverted()) {17plane.nav_pitch_cd = -plane.nav_pitch_cd;18}19if (plane.failsafe.rc_failsafe && plane.g.fs_action_short == FS_ACTION_SHORT_FBWA) {20// FBWA failsafe glide21plane.nav_roll_cd = 0;22plane.nav_pitch_cd = 0;23SRV_Channels::set_output_limit(SRV_Channel::k_throttle, SRV_Channel::Limit::MIN);24}25RC_Channel *chan = rc().find_channel_for_option(RC_Channel::AUX_FUNC::FBWA_TAILDRAGGER);26if (chan != nullptr) {27// check for the user enabling FBWA taildrag takeoff mode28bool tdrag_mode = chan->get_aux_switch_pos() == RC_Channel::AuxSwitchPos::HIGH;29if (tdrag_mode && !plane.auto_state.fbwa_tdrag_takeoff_mode) {30if (plane.auto_state.highest_airspeed < plane.g.takeoff_tdrag_speed1) {31plane.auto_state.fbwa_tdrag_takeoff_mode = true;32plane.gcs().send_text(MAV_SEVERITY_WARNING, "FBWA tdrag mode");33}34}35}36}3738void ModeFBWA::run()39{40// Run base class function and then output throttle41Mode::run();4243output_pilot_throttle();44}454647