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/AntennaTracker/mode.h
Views: 1798
#pragma once12#include <stdint.h>3#include <AP_Math/AP_Math.h>45class Mode {6public:7enum class Number {8MANUAL=0,9STOP=1,10SCAN=2,11SERVOTEST=3,12GUIDED=4,13AUTO=10,14INITIALISING=1615// Mode number 30 reserved for "offboard" for external/lua control.16};1718Mode() {}1920// do not allow copying21CLASS_NO_COPY(Mode);2223// returns a unique number specific to this mode24virtual Mode::Number number() const = 0;25virtual const char* name() const = 0;2627virtual bool requires_armed_servos() const = 0;2829virtual void update() = 0;3031protected:32void update_scan();33void update_auto();3435bool get_ef_yaw_direction();3637void calc_angle_error(float pitch, float yaw, bool direction_reversed);38void convert_ef_to_bf(float pitch, float yaw, float& bf_pitch, float& bf_yaw);39bool convert_bf_to_ef(float pitch, float yaw, float& ef_pitch, float& ef_yaw);40};4142class ModeAuto : public Mode {43public:44Mode::Number number() const override { return Mode::Number::AUTO; }45const char* name() const override { return "Auto"; }46bool requires_armed_servos() const override { return true; }47void update() override;48};4950class ModeGuided : public Mode {51public:52Mode::Number number() const override { return Mode::Number::GUIDED; }53const char* name() const override { return "Guided"; }54bool requires_armed_servos() const override { return true; }55void update() override;5657void set_angle(const Quaternion &target_att, bool use_yaw_rate, float yaw_rate_rads) {58_target_att = target_att;59_use_yaw_rate = use_yaw_rate;60_yaw_rate_rads = yaw_rate_rads;61}6263private:64Quaternion _target_att;65bool _use_yaw_rate;66float _yaw_rate_rads;67};6869class ModeInitialising : public Mode {70public:71Mode::Number number() const override { return Mode::Number::INITIALISING; }72const char* name() const override { return "Initialising"; }73bool requires_armed_servos() const override { return false; }74void update() override {};75};7677class ModeManual : public Mode {78public:79Mode::Number number() const override { return Mode::Number::MANUAL; }80const char* name() const override { return "Manual"; }81bool requires_armed_servos() const override { return true; }82void update() override;83};8485class ModeScan : public Mode {86public:87Mode::Number number() const override { return Mode::Number::SCAN; }88const char* name() const override { return "Scan"; }89bool requires_armed_servos() const override { return true; }90void update() override;91};9293class ModeServoTest : public Mode {94public:95Mode::Number number() const override { return Mode::Number::SERVOTEST; }96const char* name() const override { return "ServoTest"; }97bool requires_armed_servos() const override { return true; }98void update() override {};99100bool set_servo(uint8_t servo_num, uint16_t pwm);101};102103class ModeStop : public Mode {104public:105Mode::Number number() const override { return Mode::Number::STOP; }106const char* name() const override { return "Stop"; }107bool requires_armed_servos() const override { return false; }108void update() override {};109};110111112