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/VTOL_Assist.h
Views: 1798
#pragma once12// VTOL assistance in a forward flight mode34class QuadPlane;5class VTOL_Assist {6public:7VTOL_Assist(QuadPlane& _quadplane):quadplane(_quadplane) {};89// check for assistance needed10bool should_assist(float aspeed, bool have_airspeed);1112// Assistance not needed, reset any state13void reset();1415// speed below which quad assistance is given16AP_Float speed;1718// angular error at which quad assistance is given19AP_Int8 angle;2021// altitude to trigger assistance22AP_Int16 alt;2324// Time hysteresis for triggering of assistance25AP_Float delay;2627// State from pilot28enum class STATE {29ASSIST_DISABLED,30ASSIST_ENABLED,31FORCE_ENABLED,32};33void set_state(STATE _state) { state = _state; }3435// Logging getters for assist types36bool in_force_assist() const { return force_assist; }37bool in_speed_assist() const { return speed_assist; }38bool in_alt_assist() const { return alt_error.is_active(); }39bool in_angle_assist() const { return angle_error.is_active(); }4041private:4243// Default to enabled44STATE state = STATE::ASSIST_ENABLED;4546class Assist_Hysteresis {47public:48// Reset state49void reset();5051// Update state, return true when first triggered52bool update(const bool trigger, const uint32_t &now_ms, const uint32_t &trigger_delay_ms, const uint32_t &clear_delay_ms);5354// Return true if the output is active55bool is_active() const { return active; }5657private:58uint32_t start_ms;59uint32_t last_ms;60bool active;61};62Assist_Hysteresis angle_error;63Assist_Hysteresis alt_error;6465// Force and speed assist have no hysteresis66bool force_assist;67bool speed_assist;6869// Reference to access quadplane70QuadPlane& quadplane;71};727374