Hello, I’m testing creating a new mode by copying the Auto mode. Are the changes I made correct, and how do I compile and add it to Mission Planner?
-
Changes in mode.h:
- I added the
POYRAZ
mode among the autopilot modes. The new mode was added as follows:enum class Number { // ... POYRAZ = 27, // your new flight mode };
- I added the
-
ModePoyraz Class:
- I created the
ModePoyraz
class and customized it by copying the behavior of the Auto mode.class ModePoyraz : public Mode { public: friend class Plane; Number mode_number() const override { return Number::POYRAZ; } const char *name() const override { return "POYRAZ"; } const char *name4() const override { return "POYRAZ"; } bool does_automatic_thermal_switch() const override { return true; } void update() override; void navigate() override; bool allows_throttle_nudging() const override { return true; } bool does_auto_navigation() const override; bool does_auto_throttle() const override; bool mode_allows_autotuning() const override { return true; } bool is_landing() const override; void do_nav_delay(const AP_Mission::Mission_Command& cmd); bool verify_nav_delay(const AP_Mission::Mission_Command& cmd); bool verify_altitude_wait(const AP_Mission::Mission_Command& cmd); void run() override; protected: bool _enter() override; void _exit() override; bool _pre_arm_checks(size_t buflen, char *buffer) const override; private: struct { uint32_t time_max_ms; uint32_t time_start_ms; } nav_delay; void wiggle_servos(); struct { uint8_t stage; uint32_t last_ms; } wiggle; };
- I created the
-
mode_poyraz.cpp and mode_poyraz.h Files:
- I created the
mode_poyraz.cpp
andmode_poyraz.h
files by copying the functionality of the Auto mode.
- I created the
-
Changes in Plane.h:
- I created instances of
ModeAuto
andModePoyraz
and associated them as follows:ModeAuto mode_auto; ModePoyraz mode_poyraz; friend class ModeAuto; friend class ModePoyraz;
- I created instances of
-
Changes in control_modes.cpp:
- I added the necessary code to handle the
POYRAZ
mode:case Mode::Number::POYRAZ: ret = &mode_poyraz; break;
- I added the necessary code to handle the
-
Changes in Parameters.cpp:
- I changed the parameter to
FLIGHT_MODE_7
as follows:GSCALAR(FLIGHT_MODE_7, "POYRAZ_UAV", FLIGHT_MODE_7);
- Additionally, I defined the
FLIGHT_MODE_7
macro in theconfig.h
file as:#if !defined(FLIGHT_MODE_7) # define FLIGHT_MODE_7 Mode::Number::POYRAZ #endif
- I changed the parameter to