Custom Flight Mode - Help

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?

  1. 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
      };
      
  2. 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;
      };
      
  3. mode_poyraz.cpp and mode_poyraz.h Files:

    • I created the mode_poyraz.cpp and mode_poyraz.h files by copying the functionality of the Auto mode.
  4. Changes in Plane.h:

    • I created instances of ModeAuto and ModePoyraz and associated them as follows:
      ModeAuto mode_auto;
      ModePoyraz mode_poyraz;
      
      friend class ModeAuto;
      friend class ModePoyraz;
      
  5. Changes in control_modes.cpp:

    • I added the necessary code to handle the POYRAZ mode:
      case Mode::Number::POYRAZ:
          ret = &mode_poyraz;
          break;
      
  6. 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 the config.h file as:
      #if !defined(FLIGHT_MODE_7)
      # define FLIGHT_MODE_7                  Mode::Number::POYRAZ
      #endif