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/libraries/AC_Autorotation/AC_Autorotation.h
Views: 1798
#pragma once12#include <AP_Common/AP_Common.h>3#include <AP_Param/AP_Param.h>4#include <AP_Math/AP_Math.h>5#include <AP_Motors/AP_Motors.h>6#include <AP_Motors/AP_MotorsHeli_RSC.h>7#include <Filter/Filter.h>8#include <Filter/LowPassFilter.h>9#include <AC_PID/AC_P.h>101112class AC_Autorotation13{14public:1516//Constructor17AC_Autorotation();1819//--------Functions--------20void init_hs_controller(void); // Initialise head speed controller21void init_fwd_spd_controller(void); // Initialise forward speed controller22bool update_hs_glide_controller(float dt); // Update head speed controller23float get_rpm(void) const { return _current_rpm; } // Function just returns the rpm as last read in this library24float get_rpm(bool update_counter); // Function fetches fresh rpm update and continues sensor health monitoring25void set_target_head_speed(float ths) { _target_head_speed = ths; } // Sets the normalised target head speed26void set_col_cutoff_freq(float freq) { _col_cutoff_freq = freq; } // Sets the collective low pass filter cut off frequency27int16_t get_hs_set_point(void) { return _param_head_speed_set_point; }28float get_col_entry_freq(void) { return _param_col_entry_cutoff_freq; }29float get_col_glide_freq(void) { return _param_col_glide_cutoff_freq; }30float get_last_collective() const { return _collective_out; }31bool is_enable(void) { return _param_enable; }32void Log_Write_Autorotation(void) const;33void update_forward_speed_controller(void); // Update forward speed controller34void set_desired_fwd_speed(void) { _vel_target = _param_target_speed; } // Overloaded: Set desired speed for forward controller to parameter value35void set_desired_fwd_speed(float speed) { _vel_target = speed; } // Overloaded: Set desired speed to argument value36int32_t get_pitch(void) const { return _pitch_target; } // Get pitch target37float calc_speed_forward(void); // Calculates the forward speed in the horizontal plane38void set_dt(float delta_sec);3940// User Settable Parameters41static const struct AP_Param::GroupInfo var_info[];4243private:4445//--------Internal Variables--------46float _current_rpm;47float _collective_out;48float _head_speed_error; // Error between target head speed and current head speed. Normalised by head speed set point RPM.49float _col_cutoff_freq; // Lowpass filter cutoff frequency (Hz) for collective.50uint8_t _unhealthy_rpm_counter; // Counter used to track RPM sensor unhealthy signal.51uint8_t _healthy_rpm_counter; // Counter used to track RPM sensor healthy signal.52float _target_head_speed; // Normalised target head speed. Normalised by head speed set point RPM.53float _p_term_hs; // Proportional contribution to collective setting.54float _ff_term_hs; // Following trim feed forward contribution to collective setting.5556float _vel_target; // Forward velocity target.57float _pitch_target; // Pitch angle target.58float _accel_max; // Maximum acceleration limit.59int16_t _speed_forward_last; // The forward speed calculated in the previous cycle.60bool _flag_limit_accel; // Maximum acceleration limit reached flag.61float _accel_out_last; // Acceleration value used to calculate pitch target in previous cycle.62float _cmd_vel; // Command velocity, used to get PID values for acceleration calculation.63float _accel_target; // Acceleration target, calculated from PID.64float _delta_speed_fwd; // Change in forward speed between computation cycles.65float _dt; // Time step.66int16_t _speed_forward; // Measured forward speed.67float _vel_p; // Forward velocity P term.68float _vel_ff; // Forward velocity Feed Forward term.69float _accel_out; // Acceleration value used to calculate pitch target.7071LowPassFilterFloat _accel_target_filter; // acceleration target filter7273//--------Parameter Values--------74AP_Int8 _param_enable;75AC_P _p_hs;76AC_P _p_fw_vel;77AP_Int16 _param_head_speed_set_point;78AP_Int16 _param_target_speed;79AP_Float _param_col_entry_cutoff_freq;80AP_Float _param_col_glide_cutoff_freq;81AP_Int16 _param_accel_max;82AP_Int8 _param_rpm_instance;83AP_Float _param_fwd_k_ff;8485//--------Internal Flags--------86struct controller_flags {87bool bad_rpm : 1;88bool bad_rpm_warning : 1;89} _flags;9091//--------Internal Functions--------92void set_collective(float _collective_filter_cutoff) const;9394// low pass filter for collective trim95LowPassFilterFloat col_trim_lpf;96};979899