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_CustomControl/AC_CustomControl.h
Views: 1798
#pragma once12/// @file AC_CustomControl.h3/// @brief ArduCopter custom control library45#include "AC_CustomControl_config.h"67#if AP_CUSTOMCONTROL_ENABLED89#include <AP_Common/AP_Common.h>10#include <AP_Param/AP_Param.h>11#include <AP_AHRS/AP_AHRS_View.h>12#include <AC_AttitudeControl/AC_AttitudeControl.h>13#include <AP_Motors/AP_MotorsMulticopter.h>1415#ifndef CUSTOMCONTROL_MAX_TYPES16#define CUSTOMCONTROL_MAX_TYPES 217#endif1819class AC_CustomControl_Backend;2021class AC_CustomControl {22public:23AC_CustomControl(AP_AHRS_View*& ahrs, AC_AttitudeControl*& _att_control, AP_MotorsMulticopter*& motors, float dt);2425CLASS_NO_COPY(AC_CustomControl); /* Do not allow copies */2627void init(void);28void update(void);29void motor_set(Vector3f motor_out);30void set_custom_controller(bool enabled);31void reset_main_att_controller(void);32bool is_safe_to_run(void);33void log_switch(void);3435// set the PID notch sample rates36void set_notch_sample_rate(float sample_rate);3738// zero index controller type param, only use it to access _backend or _backend_var_info array39uint8_t get_type() { return _controller_type > 0 ? (_controller_type - 1) : 0; };4041// User settable parameters42static const struct AP_Param::GroupInfo var_info[];43static const struct AP_Param::GroupInfo *_backend_var_info[CUSTOMCONTROL_MAX_TYPES];4445protected:46// add custom controller here47enum class CustomControlType : uint8_t {48CONT_NONE = 0,49CONT_EMPTY = 1,50CONT_PID = 2,51}; // controller that should be used5253enum class CustomControlOption {54ROLL = 1 << 0,55PITCH = 1 << 1,56YAW = 1 << 2,57};5859// Intersampling period in seconds60float _dt;61bool _custom_controller_active;6263// References to external libraries64AP_AHRS_View*& _ahrs;65AC_AttitudeControl*& _att_control;66AP_MotorsMulticopter*& _motors;6768AP_Enum<CustomControlType> _controller_type;69AP_Int8 _custom_controller_mask;7071private:72AC_CustomControl_Backend *_backend;73};7475#endif // AP_CUSTOMCONTROL_ENABLED767778