LCOV - code coverage report
Current view: top level - home/pbarker/rc/ardupilot/ArduPlane - transition.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 12 14 85.7 %
Date: 2026-09-09 11:02:08 Functions: 12 14 85.7 %

          Line data    Source code
       1             : /*
       2             :    This program is free software: you can redistribute it and/or modify
       3             :    it under the terms of the GNU General Public License as published by
       4             :    the Free Software Foundation, either version 3 of the License, or
       5             :    (at your option) any later version.
       6             : 
       7             :    This program is distributed in the hope that it will be useful,
       8             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
       9             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      10             :    GNU General Public License for more details.
      11             : 
      12             :    You should have received a copy of the GNU General Public License
      13             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      14             :  */
      15             : #pragma once
      16             : #include <GCS_MAVLink/GCS_MAVLink.h>
      17             : 
      18             : class QuadPlane;
      19             : class AP_MotorsMulticopter;
      20             : // Transition empty base class
      21             : class Transition
      22             : {
      23             : public:
      24             : 
      25         201 :     Transition(QuadPlane& _quadplane, AP_MotorsMulticopter*& _motors):quadplane(_quadplane),motors(_motors) {};
      26             : 
      27             :     virtual void update() = 0;
      28             : 
      29             :     virtual void VTOL_update() = 0;
      30             : 
      31             :     virtual void force_transition_complete() = 0;
      32             : 
      33             :     virtual bool complete() const = 0;
      34             : 
      35             :     virtual void restart() = 0;
      36             : 
      37             :     virtual uint8_t get_log_transition_state() const = 0;
      38             : 
      39             :     virtual bool active_frwd() const = 0;
      40             : 
      41             :     virtual bool show_vtol_view() const = 0;
      42             : 
      43           0 :     virtual void set_FW_roll_pitch(int32_t& nav_pitch_cd, int32_t& nav_roll_cd) {};
      44             : 
      45       62356 :     virtual bool set_FW_roll_limit(int32_t& roll_limit_cd) { return false; }
      46             : 
      47       16654 :     virtual bool allow_update_throttle_mix() const { return true; }
      48             : 
      49      398350 :     virtual bool update_yaw_target(float& yaw_target_cd) { return false; }
      50             : 
      51             :     virtual MAV_VTOL_STATE get_mav_vtol_state() const = 0;
      52             : 
      53           0 :     virtual bool set_VTOL_roll_pitch_limit(int32_t& nav_roll_cd, int32_t& nav_pitch_cd) { return false; }
      54             : 
      55     1967164 :     virtual bool allow_weathervane() { return true; }
      56             : 
      57             :     // Return true if forward throttle should be allowed for position control, see Q_FWD_THR_USE
      58     5932057 :     virtual bool allow_vfwd() const { return true; }
      59             : 
      60           2 :     virtual void set_last_fw_pitch(void) {}
      61             : 
      62     2909102 :     virtual bool allow_stick_mixing() const { return true; }
      63             : 
      64      584764 :     virtual bool use_multirotor_control_in_fwd_transition() const { return false; }
      65             : 
      66             : protected:
      67             : 
      68             :     // references for convenience
      69             :     QuadPlane& quadplane;
      70             :     AP_MotorsMulticopter*& motors;
      71             : 
      72             : };
      73             : 
      74             : // Transition for separate lift thrust quadplanes
      75             : class SLT_Transition : public Transition
      76             : {
      77             : public:
      78             : 
      79             :     using Transition::Transition;
      80             : 
      81             :     void update() override;
      82             : 
      83             :     void VTOL_update() override;
      84             : 
      85             :     void force_transition_complete() override;
      86             : 
      87      154063 :     bool complete() const override { return transition_state == State::DONE; }
      88             : 
      89          42 :     void restart() override { transition_state = State::AIRSPEED_WAIT; }
      90             : 
      91      199456 :     uint8_t get_log_transition_state() const override { return static_cast<uint8_t>(transition_state); }
      92             : 
      93             :     bool active_frwd() const override;
      94             : 
      95             :     bool show_vtol_view() const override;
      96             : 
      97             :     void set_FW_roll_pitch(int32_t& nav_pitch_cd, int32_t& nav_roll_cd) override;
      98             : 
      99             :     bool set_FW_roll_limit(int32_t& roll_limit_cd) override;
     100             : 
     101             :     bool allow_update_throttle_mix() const override;
     102             : 
     103             :     MAV_VTOL_STATE get_mav_vtol_state() const override;
     104             : 
     105             :     bool set_VTOL_roll_pitch_limit(int32_t& nav_roll_cd, int32_t& nav_pitch_cd) override;
     106             : 
     107             :     void set_last_fw_pitch(void) override;
     108             : 
     109             : protected:
     110             : 
     111             :     enum class State {
     112             :         AIRSPEED_WAIT = 0,
     113             :         TIMER         = 1,
     114             :         DONE          = 2,
     115             :     } transition_state;
     116             : 
     117             :     // timer start for transition
     118             :     uint32_t transition_start_ms;
     119             :     uint32_t transition_low_airspeed_ms;
     120             : 
     121             :     // last throttle value when active
     122             :     float last_throttle;
     123             : 
     124             :     // time and pitch angle whe last in a vtol or FW control mode
     125             :     uint32_t last_fw_mode_ms;
     126             :     int32_t last_fw_nav_pitch_cd;
     127             : 
     128             :     // tiltrotor tilt angle when airspeed wait transition stage completes
     129             :     float airspeed_reached_tilt;
     130             : 
     131             :     bool in_forced_transition;
     132             : 
     133             : };
     134             : 

Generated by: LCOV version 1.14