LCOV - code coverage report
Current view: top level - AP_Vehicle - AP_Vehicle.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 21 66 31.8 %
Date: 2026-09-09 11:02:08 Functions: 9 52 17.3 %

          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             : 
      17             : #include "AP_Vehicle_config.h"
      18             : 
      19             : #if AP_VEHICLE_ENABLED
      20             : 
      21             : /*
      22             :   this header holds a parameter structure for each vehicle type for
      23             :   parameters needed by multiple libraries
      24             :  */
      25             : 
      26             : #include "ModeReason.h" // reasons can't be defined in this header due to circular loops
      27             : 
      28             : #include <AP_AHRS/AP_AHRS.h>
      29             : #include <AP_AccelCal/AP_AccelCal.h>
      30             : #include <AP_Airspeed/AP_Airspeed.h>
      31             : #include <AP_Baro/AP_Baro.h>
      32             : #include <AP_BoardConfig/AP_BoardConfig.h>     // board configuration library
      33             : #include <AP_CANManager/AP_CANManager.h>
      34             : #include <AP_Button/AP_Button.h>
      35             : #include <AP_Compass/AP_Compass.h>
      36             : #include <AP_EFI/AP_EFI.h>
      37             : #include <AP_ExternalControl/AP_ExternalControl_config.h>
      38             : #include <AP_GPS/AP_GPS.h>
      39             : #include <AP_Generator/AP_Generator.h>
      40             : #include <AP_Logger/AP_Logger.h>
      41             : #include <AP_InertialSensor/AP_InertialSensor.h>
      42             : #include <AP_Notify/AP_Notify.h>                    // Notify library
      43             : #include <AP_Param/AP_Param.h>
      44             : #include <AP_RangeFinder/AP_RangeFinder.h>
      45             : #include <AP_Relay/AP_Relay.h>                      // APM relay
      46             : #include <AP_RSSI/AP_RSSI.h>                        // RSSI Library
      47             : #include <AP_Scheduler/AP_Scheduler.h>
      48             : #include <AP_SerialManager/AP_SerialManager.h>      // Serial manager library
      49             : #include <AP_ServoRelayEvents/AP_ServoRelayEvents.h>
      50             : #include <AP_OpenDroneID/AP_OpenDroneID.h>
      51             : #include <AP_Hott_Telem/AP_Hott_Telem.h>
      52             : #include <AP_ESC_Telem/AP_ESC_Telem.h>
      53             : #include <AP_Servo_Telem/AP_Servo_Telem.h>
      54             : #include <AP_GyroFFT/AP_GyroFFT.h>
      55             : #include <AP_Networking/AP_Networking.h>
      56             : #include <AP_VisualOdom/AP_VisualOdom.h>
      57             : #include <AP_VideoTX/AP_VideoTX.h>
      58             : #include <AP_MSP/AP_MSP.h>
      59             : #include <AP_Frsky_Telem/AP_Frsky_Parameters.h>
      60             : #include <AP_ExternalAHRS/AP_ExternalAHRS.h>
      61             : #include <AP_VideoTX/AP_SmartAudio.h>
      62             : #include <AP_VideoTX/AP_Tramp.h>
      63             : #include <AP_TemperatureSensor/AP_TemperatureSensor.h>
      64             : #include <SITL/SITL.h>
      65             : #include <AP_CustomRotations/AP_CustomRotations.h>
      66             : #include <AP_AIS/AP_AIS.h>
      67             : #include <AP_NMEA_Output/AP_NMEA_Output.h>
      68             : #include <AC_Fence/AC_Fence.h>
      69             : #include <AP_CheckFirmware/AP_CheckFirmware.h>
      70             : #include <Filter/LowPassFilter.h>
      71             : #include <AP_KDECAN/AP_KDECAN.h>
      72             : #include <Filter/AP_Filter.h>
      73             : #include <AP_Stats/AP_Stats.h>              // statistics library
      74             : #include <AP_DDS/AP_DDS_config.h>
      75             : #if AP_SCRIPTING_ENABLED
      76             : #include <AP_Scripting/AP_Scripting.h>
      77             : #endif
      78             : 
      79             : #include <AP_Gripper/AP_Gripper_config.h>
      80             : #if AP_GRIPPER_ENABLED
      81             : #include <AP_Gripper/AP_Gripper.h>
      82             : #endif
      83             : 
      84             : #include <AP_Beacon/AP_Beacon_config.h>
      85             : #if AP_BEACON_ENABLED
      86             : #include <AP_Beacon/AP_Beacon.h>
      87             : #endif  // AP_BEACON_ENABLED
      88             : 
      89             : #include <AP_RPM/AP_RPM_config.h>
      90             : #if AP_RPM_ENABLED
      91             : #include <AP_RPM/AP_RPM.h>
      92             : #endif
      93             : 
      94             : #include <AP_IBus_Telem/AP_IBus_Telem.h>
      95             : 
      96             : class AP_DDS_Client;
      97             : 
      98             : class AP_Vehicle : public AP_HAL::HAL::Callbacks {
      99             : 
     100             : public:
     101             : 
     102       69170 :     AP_Vehicle() {
     103        2098 :         if (_singleton) {
     104           0 :             AP_HAL::panic("Too many Vehicles");
     105             :         }
     106        2098 :         AP_Param::setup_object_defaults(this, var_info);
     107        2098 :         _singleton = this;
     108        2098 :     }
     109             : 
     110             :     /* Do not allow copies */
     111             :     CLASS_NO_COPY(AP_Vehicle);
     112             : 
     113             :     static AP_Vehicle *get_singleton();
     114             : 
     115             :     // setup() is called once during vehicle startup to initialise the
     116             :     // vehicle object and the objects it contains.  The
     117             :     // AP_HAL_MAIN_CALLBACKS pragma creates a main(...) function
     118             :     // referencing an object containing setup() and loop() functions.
     119             :     // A vehicle is not expected to override setup(), but
     120             :     // subclass-specific initialisation can be done in init_ardupilot
     121             :     // which is called from setup().
     122             :     void setup(void) override final;
     123             : 
     124             :     // HAL::Callbacks implementation.
     125             :     void loop() override final;
     126             : 
     127             :     // set_mode *must* set control_mode_reason
     128             :     virtual bool set_mode(const uint8_t new_mode, const ModeReason reason) = 0;
     129             :     virtual uint8_t get_mode() const = 0;
     130             : 
     131           0 :     ModeReason get_control_mode_reason() const {
     132           0 :         return control_mode_reason;
     133             :     }
     134             : 
     135       58465 :     virtual bool current_mode_requires_mission() const { return false; }
     136             : 
     137             :     // perform any notifications required to indicate a mode change
     138             :     // failed due to a bad mode number being supplied.  This can
     139             :     // happen for many reasons - bad mavlink packet and bad mode
     140             :     // parameters for example.
     141             :     void notify_no_such_mode(uint8_t mode_number);
     142             : 
     143             : #if AP_SCHEDULER_ENABLED
     144             :     void get_common_scheduler_tasks(const AP_Scheduler::Task*& tasks, uint8_t& num_tasks);
     145             :     // implementations *MUST* fill in all passed-in fields or we get
     146             :     // Valgrind errors
     147             :     virtual void get_scheduler_tasks(const AP_Scheduler::Task *&tasks, uint8_t &task_count, uint32_t &log_bit) = 0;
     148             : #endif
     149             : 
     150             :     /*
     151             :       set the "likely flying" flag. This is not guaranteed to be
     152             :       accurate, but is the vehicle codes best guess as to the whether
     153             :       the vehicle is currently flying
     154             :     */
     155      294970 :     void set_likely_flying(bool b) {
     156      294970 :         if (b && !likely_flying) {
     157         931 :             _last_flying_ms = AP_HAL::millis();
     158             :         }
     159      294970 :         likely_flying = b;
     160      294970 :     }
     161             : 
     162             :     /*
     163             :       get the likely flying status. Returns true if the vehicle code
     164             :       thinks we are flying at the moment. Not guaranteed to be
     165             :       accurate
     166             :     */
     167       19899 :     bool get_likely_flying(void) const {
     168       19899 :         return likely_flying;
     169             :     }
     170             : 
     171             :     /*
     172             :       return time in milliseconds since likely_flying was set
     173             :       true. Returns zero if likely_flying is currently false
     174             :     */
     175    41156769 :     uint32_t get_time_flying_ms(void) const {
     176    41156769 :         if (!likely_flying) {
     177    15064623 :             return 0;
     178             :         }
     179    26092146 :         return AP_HAL::millis() - _last_flying_ms;
     180             :     }
     181             : 
     182             :     // returns true if the vehicle has crashed
     183             :     virtual bool is_crashed() const;
     184             : 
     185             : #if AP_SCRIPTING_ENABLED || AP_EXTERNAL_CONTROL_ENABLED
     186             :     // Method to takeoff for use by external control
     187           0 :     virtual bool start_takeoff(const float alt_m) { return false; }
     188             :     // Method to control vehicle position for use by external control
     189           0 :     virtual bool set_target_location(const Location& target_loc) { return false; }
     190             :     // Get target location for use by external control
     191           0 :     virtual bool get_target_location(Location& target_loc) { return false; }
     192             : #endif // AP_SCRIPTING_ENABLED || AP_EXTERNAL_CONTROL_ENABLED
     193             : #if AP_SCRIPTING_ENABLED
     194             :     /*
     195             :       methods to control vehicle for use by scripting
     196             :     */
     197           0 :     virtual bool set_target_pos_NED(const Vector3f& target_pos_ned_m, bool use_yaw, float yaw_deg, bool use_yaw_rate, float yaw_rate_degs, bool yaw_relative, bool is_terrain_alt) { return false; }
     198           0 :     virtual bool set_target_posvel_NED(const Vector3f& target_pos_ned_m, const Vector3f& target_vel_ned_ms) { return false; }
     199           0 :     virtual bool set_target_posvelaccel_NED(const Vector3f& target_pos_ned_m, const Vector3f& target_vel_ned_ms, const Vector3f& target_accel_ned_mss, bool use_yaw, float yaw_deg, bool use_yaw_rate, float yaw_rate_degs, bool yaw_relative) { return false; }
     200           0 :     virtual bool set_target_velocity_NED(const Vector3f& vel_ned_ms, bool align_yaw_to_target = false) { return false; }
     201           0 :     virtual bool set_target_velaccel_NED(const Vector3f& target_vel_ned_ms, const Vector3f& target_accel_ned_mss, bool use_yaw, float yaw_deg, bool use_yaw_rate, float yaw_rate_degs, bool yaw_relative) { return false; }
     202           0 :     virtual bool set_target_angle_and_climbrate(float roll_deg, float pitch_deg, float yaw_deg, float climb_rate_ms, bool use_yaw_rate, float yaw_rate_degs) { return false; }
     203           0 :     virtual bool set_target_rate_and_throttle(float roll_rate_dps, float pitch_rate_dps, float yaw_rate_dps, float throttle) { return false; }
     204           0 :     virtual bool set_target_angle_and_rate_and_throttle(float roll_deg, float pitch_deg, float yaw_deg, float roll_rate_degs, float pitch_rate_degs, float yaw_rate_degs, float throttle) { return false; }
     205             : 
     206             :     // command throttle percentage and roll, pitch, yaw target
     207             :     // rates. For use with scripting controllers
     208           0 :     virtual void set_target_throttle_rate_rpy(float throttle_pct, float roll_rate_dps, float pitch_rate_dps, float yaw_rate_dps) {}
     209           0 :     virtual void set_rudder_offset(float rudder_pct, bool run_yaw_rate_controller) {}
     210           0 :     virtual bool nav_scripting_enable(uint8_t mode) {return false;}
     211             : 
     212           0 :     virtual bool update_target_location(const Location &old_loc, const Location &new_loc) { return false; }
     213             : 
     214             :     // circle mode controls (only used by scripting with Copter)
     215           0 :     virtual bool get_circle_radius(float &radius_m) { return false; }
     216           0 :     virtual bool set_circle_rate(float rate_dps) { return false; }
     217             : 
     218             :     // get or set steering and throttle (-1 to +1) (for use by scripting with Rover)
     219           0 :     virtual bool set_steering_and_throttle(float steering, float throttle) { return false; }
     220           0 :     virtual bool get_steering_and_throttle(float& steering, float& throttle) { return false; }
     221             : 
     222             :     // set turn rate in deg/sec and speed in meters/sec (for use by scripting with Rover)
     223           0 :     virtual bool set_desired_turn_rate_and_speed(float turn_rate_degs, float speed_ms) { return false; }
     224             : 
     225             :    // set auto mode speed in meters/sec (for use by scripting with Copter/Rover)
     226           0 :     virtual bool set_desired_speed(float speed_ms) { return false; }
     227             : 
     228             :     // support for NAV_SCRIPT_TIME mission command
     229           0 :     virtual bool nav_script_time(uint16_t &id, uint8_t &cmd, float &arg1, float &arg2, int16_t &arg3, int16_t &arg4) { return false; }
     230           0 :     virtual void nav_script_time_done(uint16_t id) {}
     231             : 
     232             :     // allow for VTOL velocity matching of a target
     233           0 :     virtual bool set_velocity_match(const Vector2f &velocity_ne_ms) { return false; }
     234             : 
     235             :     // returns true if the EKF failsafe has triggered
     236           0 :     virtual bool has_ekf_failsafed() const { return false; }
     237             : 
     238             :     // allow for landing descent rate to be overridden by a script, may be -ve to climb
     239           0 :     virtual bool set_land_descent_rate(float descent_rate_ms) { return false; }
     240             : 
     241             :     // Allow for scripting to have control over the crosstracking when exiting and resuming missions or guided flight
     242             :     // It's up to the Lua script to ensure the provided location makes sense
     243           0 :     virtual bool set_crosstrack_start(const Location &new_start_location) { return false; }
     244             : 
     245             :     // control outputs enumeration
     246             :     enum class ControlOutput {
     247             :         Roll = 1,
     248             :         Pitch = 2,
     249             :         Throttle = 3,
     250             :         Yaw = 4,
     251             :         Lateral = 5,
     252             :         MainSail = 6,
     253             :         WingSail = 7,
     254             :         Walking_Height = 8,
     255             :         Last_ControlOutput  // place new values before this
     256             :     };
     257             : 
     258             :     // get control output (for use in scripting)
     259             :     // returns true on success and control_value is set to a value in the range -1 to +1
     260           0 :     virtual bool get_control_output(AP_Vehicle::ControlOutput control_output, float &control_value) { return false; }
     261             : 
     262             :     // Register a custom mode with given number and names, return a structure which the script can edit
     263             :     struct custom_mode_state {
     264             :         bool allow_entry;
     265             :     };
     266           0 :     virtual custom_mode_state* register_custom_mode(const uint8_t number, const char* full_name, const char* short_name) { return nullptr; }
     267             : 
     268             : #endif // AP_SCRIPTING_ENABLED
     269             : 
     270             :     // returns true if vehicle is in the process of landing
     271           0 :     virtual bool is_landing() const { return false; }
     272             : 
     273             :     // returns true if vehicle is in the process of taking off
     274           0 :     virtual bool is_taking_off() const { return false; }
     275             : 
     276             :     // zeroing the RC outputs can prevent unwanted motor movement:
     277        1570 :     virtual bool should_zero_rc_outputs_on_reboot() const { return false; }
     278             : 
     279             :     // reboot the vehicle in an orderly manner, doing various cleanups
     280             :     // and flashing LEDs as appropriate
     281             :     void reboot(bool hold_in_bootloader);
     282             : 
     283             :     /*
     284             :       get the distance to next wp in meters
     285             :       return false if failed or n/a
     286             :      */
     287           0 :     virtual bool get_wp_distance_m(float &distance) const { return false; }
     288             : 
     289             : #if AP_MOUNT_ROI_WPNEXT_OFFSET_ENABLED
     290             :     // return the lat/lon/alt etc of waypoint location:
     291           0 :     virtual bool get_wp_location(Location &loc) const { return false; }
     292             : #endif  // AP_MOUNT_ROI_WPNEXT_OFFSET_ENABLED
     293             : 
     294             :     /*
     295             :       get the current wp bearing in degrees
     296             :       return false if failed or n/a
     297             :      */
     298           0 :     virtual bool get_wp_bearing_deg(float &bearing) const { return false; }
     299             : 
     300             :     /*
     301             :       get the current wp crosstrack error in meters
     302             :       return false if failed or n/a
     303             :      */
     304           0 :     virtual bool get_wp_crosstrack_error_m(float &xtrack_error) const { return false; }
     305             : 
     306             : #if HAL_WITH_FRSKY_TELEM_BIDIRECTIONAL
     307             :     AP_Frsky_Parameters frsky_parameters;
     308             : #endif
     309             : 
     310             :     /*
     311             :       Returns the pan and tilt for use by onvif camera in scripting
     312             :      */
     313           0 :     virtual bool get_pan_tilt_norm(float &pan_norm, float &tilt_norm) const { return false; }
     314             : 
     315             :     // Returns roll, pitch, and yaw for OSD Horizon, Plane overrides to correct for VTOL view and fixed wing PTCH_TRIM_DEG
     316             :     virtual void get_osd_attitude_rad(float &roll, float &pitch, float &yaw);
     317             : 
     318             :     /*
     319             :      get the target earth-frame angular velocities in rad/s (Z-axis component used by some gimbals)
     320             :      */
     321           0 :     virtual bool get_rate_ef_targets(Vector3f& rate_ef_targets_rads) const { return false; }
     322             : 
     323             : #if AP_AHRS_ENABLED
     324           0 :     virtual bool set_home_to_current_location(bool lock) WARN_IF_UNUSED { return false; }
     325           0 :     virtual bool set_home(const Location& loc, bool lock) WARN_IF_UNUSED { return false; }
     326             : #endif
     327             : 
     328             : protected:
     329             : 
     330             :     virtual void init_ardupilot() = 0;
     331             :     virtual void load_parameters() = 0;
     332             :     void load_parameters(AP_Int16 &format_version, const uint16_t expected_format_version);
     333             : 
     334        1117 :     virtual void set_control_channels() {}
     335             : 
     336             :     // board specific config
     337             :     AP_BoardConfig BoardConfig;
     338             : 
     339             : #if HAL_CANMANAGER_ENABLED
     340             :     // board specific config for CAN bus
     341             :     AP_CANManager can_mgr;
     342             : #endif
     343             : 
     344             : #if AP_SCHEDULER_ENABLED
     345             :     // main loop scheduler
     346             :     AP_Scheduler scheduler;
     347             : #endif
     348             : 
     349             :     // IMU variables
     350             :     // Integration time; time last loop took to run
     351             :     float G_Dt;
     352             : 
     353             :     // sensor drivers
     354             : #if AP_GPS_ENABLED
     355             :     AP_GPS gps;
     356             : #endif
     357             :     AP_Baro barometer;
     358             : #if AP_COMPASS_ENABLED
     359             :     Compass compass;
     360             : #endif
     361             : #if AP_INERTIALSENSOR_ENABLED
     362             :     AP_InertialSensor ins;
     363             : #endif
     364             : #if HAL_BUTTON_ENABLED
     365             :     AP_Button button;
     366             : #endif
     367             : #if AP_RANGEFINDER_ENABLED
     368             :     RangeFinder rangefinder;
     369             : #endif
     370             : 
     371             : #if HAL_LOGGING_ENABLED
     372             :     AP_Logger logger;
     373             :     AP_Int32 bitmask_unused;
     374             :     // method supplied by vehicle to provide log bitmask:
     375           0 :     virtual const AP_Int32 &get_log_bitmask() { return bitmask_unused; }
     376           0 :     virtual const struct LogStructure *get_log_structures() const { return nullptr; }
     377           0 :     virtual uint8_t get_num_log_structures() const { return 0; }
     378             : #endif
     379             : 
     380             : #if AP_GRIPPER_ENABLED
     381             :     AP_Gripper gripper;
     382             : #endif
     383             : 
     384             : #if AP_BEACON_ENABLED
     385             :     // beacon (non-GPS positioning) library
     386             :     AP_Beacon beacon;
     387             : #endif  // AP_BEACON_ENABLED
     388             : 
     389             : #if AP_IBUS_TELEM_ENABLED
     390             :     AP_IBus_Telem ibus_telem;
     391             : #endif
     392             : 
     393             : #if AP_RSSI_ENABLED
     394             :     AP_RSSI rssi;
     395             : #endif
     396             : 
     397             : #if HAL_GYROFFT_ENABLED
     398             :     AP_GyroFFT gyro_fft;
     399             : #endif
     400             : #if AP_VIDEOTX_ENABLED
     401             :     AP_VideoTX vtx;
     402             : #endif
     403             : 
     404             : #if AP_SERIALMANAGER_ENABLED
     405             :     AP_SerialManager serial_manager;
     406             : #endif
     407             : 
     408             : #if AP_RELAY_ENABLED
     409             :     AP_Relay relay;
     410             : #endif
     411             : 
     412             : #if AP_SERVORELAYEVENTS_ENABLED
     413             :     AP_ServoRelayEvents ServoRelayEvents;
     414             : #endif
     415             : 
     416             :     // notification object for LEDs, buzzers etc (parameter set to
     417             :     // false disables external leds)
     418             :     AP_Notify notify;
     419             : 
     420             : #if AP_AHRS_ENABLED
     421             :     // Inertial Navigation EKF
     422             :     AP_AHRS ahrs;
     423             : #endif
     424             : 
     425             : #if HAL_HOTT_TELEM_ENABLED
     426             :     AP_Hott_Telem hott_telem;
     427             : #endif
     428             : 
     429             : #if HAL_VISUALODOM_ENABLED
     430             :     AP_VisualOdom visual_odom;
     431             : #endif
     432             : 
     433             : #if HAL_WITH_ESC_TELEM
     434             :     AP_ESC_Telem esc_telem;
     435             : #endif
     436             : 
     437             : #if AP_SERVO_TELEM_ENABLED
     438             :     AP_Servo_Telem servo_telem;
     439             : #endif
     440             : 
     441             : #if AP_OPENDRONEID_ENABLED
     442             :     AP_OpenDroneID opendroneid;
     443             : #endif
     444             : 
     445             : #if HAL_MSP_ENABLED
     446             :     AP_MSP msp;
     447             : #endif
     448             : 
     449             : #if HAL_GENERATOR_ENABLED
     450             :     AP_Generator generator;
     451             : #endif
     452             : 
     453             : #if AP_EXTERNAL_AHRS_ENABLED
     454             :     AP_ExternalAHRS externalAHRS;
     455             : #endif
     456             : 
     457             : #if AP_SMARTAUDIO_ENABLED
     458             :     AP_SmartAudio smartaudio;
     459             : #endif
     460             : 
     461             : #if AP_TRAMP_ENABLED
     462             :     AP_Tramp tramp;
     463             : #endif
     464             : 
     465             : #if AP_NETWORKING_ENABLED
     466             :     AP_Networking networking;
     467             : #endif
     468             : 
     469             : #if HAL_EFI_ENABLED
     470             :     // EFI Engine Monitor
     471             :     AP_EFI efi;
     472             : #endif
     473             : 
     474             : #if AP_AIRSPEED_ENABLED
     475             :     AP_Airspeed airspeed;
     476             : #endif
     477             : 
     478             : #if AP_STATS_ENABLED
     479             :     // vehicle statistics
     480             :     AP_Stats stats;
     481             : #endif
     482             : 
     483             : #if AP_AIS_ENABLED
     484             :     // Automatic Identification System - for tracking sea-going vehicles
     485             :     AP_AIS ais;
     486             : #endif
     487             : 
     488             : #if HAL_NMEA_OUTPUT_ENABLED
     489             :     AP_NMEA_Output nmea;
     490             : #endif
     491             : 
     492             : #if AP_KDECAN_ENABLED
     493             :     AP_KDECAN kdecan;
     494             : #endif
     495             : 
     496             : #if AP_FENCE_ENABLED
     497             :     AC_Fence fence;
     498             :     struct {
     499             :         bool have_updates;      // true if new breache statuses have been captured but not actioned
     500             :         uint8_t new_breaches;   // the new breaches that are available
     501             :         uint32_t last_check_ms; // last time the fence check was run
     502             :     } fence_breaches;
     503             : 
     504             :     void fence_init();
     505     2329699 :     virtual void fence_checks_async() {};
     506             : #endif
     507             : 
     508             : #if AP_TEMPERATURE_SENSOR_ENABLED
     509             :     AP_TemperatureSensor temperature_sensor;
     510             : #endif
     511             : 
     512             : #if AP_SCRIPTING_ENABLED
     513             :     AP_Scripting scripting;
     514             : #endif
     515             : 
     516             : #if AP_RPM_ENABLED
     517             :     AP_RPM rpm_sensor;
     518             : #endif
     519             : 
     520             :     static const struct AP_Param::GroupInfo var_info[];
     521             : #if AP_SCHEDULER_ENABLED
     522             :     static const struct AP_Scheduler::Task scheduler_tasks[];
     523             : #endif
     524             : 
     525             : #if OSD_ENABLED
     526             :     void publish_osd_info();
     527             : #endif
     528             : 
     529             : #if HAL_INS_ACCELCAL_ENABLED
     530             :     // update accel calibration
     531             :     void accel_cal_update();
     532             : #endif
     533             : 
     534             :     // call the arming library's update function
     535             :     void update_arming();
     536             : 
     537             :     // check for motor noise at a particular frequency
     538             :     void check_motor_noise();
     539             : 
     540             : #if HAL_WITH_ESC_TELEM
     541             :     // code common to multiple vehicles which ensures ESC telemetry is
     542             :     // reporting that all motors are performing.
     543             :     bool motors_takeoff_check(float rpm_min, float rpm_max);
     544             :     // state for takeoff_check:
     545             :     struct {
     546             :         uint32_t warning_ms;
     547             :     } takeoff_check_state;
     548             : 
     549             : #endif
     550             : 
     551             :     ModeReason control_mode_reason = ModeReason::UNKNOWN;
     552             : 
     553             : #if AP_SIM_ENABLED
     554             :     SITL::SIM sitl;
     555             : #endif
     556             : 
     557             : #if AP_DDS_ENABLED
     558             :     // Declare the dds client for communication with ROS2 and DDS(common for all vehicles)
     559             :     AP_DDS_Client *dds_client;
     560             :     bool init_dds_client() WARN_IF_UNUSED;
     561             : #endif
     562             : 
     563             :     // Check if this mode can be entered from the GCS
     564             :     bool block_GCS_mode_change(uint8_t mode_num, const uint8_t *mode_list, uint8_t mode_list_length) const;
     565             : 
     566             : #if HAL_GCS_ENABLED
     567             :     // Return mask of enabled modes, order does not matter, its just for tracking changes
     568        7111 :     virtual uint32_t get_available_mode_enabled_mask() const { return 0; };
     569             :     uint32_t last_available_mode_enabled_mask;
     570             : #endif
     571             : 
     572             : #if AP_INERTIALSENSOR_HARMONICNOTCH_ENABLED
     573             :     // update the harmonic notch
     574             :     void update_dynamic_notch(AP_InertialSensor::HarmonicNotch &notch);
     575             :     // run notch update at either loop rate or 200Hz
     576             :     void update_dynamic_notch_at_specified_rate();
     577             : #endif // AP_INERTIALSENSOR_HARMONICNOTCH_ENABLED
     578             : 
     579             :     // Bitmask of modes to disable from gcs
     580             :     AP_Int32 flight_mode_GCS_block;
     581             : 
     582             : private:
     583             : 
     584             : #if AP_SCHEDULER_ENABLED
     585             :     // delay() callback that processing MAVLink packets
     586             :     static void scheduler_delay_callback();
     587             : #endif
     588             : 
     589             :     // if there's been a watchdog reset, notify the world via a
     590             :     // statustext:
     591             :     void send_watchdog_reset_statustext();
     592             : 
     593             : #if AP_INERTIALSENSOR_HARMONICNOTCH_ENABLED
     594             :     // update the harmonic notch for throttle based notch
     595             :     void update_throttle_notch(AP_InertialSensor::HarmonicNotch &notch);
     596             : #endif // AP_INERTIALSENSOR_HARMONICNOTCH_ENABLED
     597             : 
     598             :     // decimation for 1Hz update
     599             :     uint8_t one_Hz_counter;
     600             :     void one_Hz_update();
     601             : 
     602             :     bool likely_flying;         // true if vehicle is probably flying
     603             :     uint32_t _last_flying_ms;   // time when likely_flying last went true
     604             : #if AP_INERTIALSENSOR_HARMONICNOTCH_ENABLED
     605             :     uint32_t _last_notch_update_ms[HAL_INS_NUM_HARMONIC_NOTCH_FILTERS]; // last time update_dynamic_notch() was run
     606             : #endif
     607             : 
     608             :     static AP_Vehicle *_singleton;
     609             : 
     610             : #if HAL_GYROFFT_ENABLED && HAL_WITH_ESC_TELEM
     611             :     LowPassFilterFloat esc_noise[ESC_TELEM_MAX_ESCS];
     612             :     uint32_t last_motor_noise_ms;
     613             : #endif
     614             : 
     615             :     bool done_safety_init;
     616             : 
     617             : 
     618             :     uint32_t _last_internal_errors;  // backup of AP_InternalError::internal_errors bitmask
     619             : 
     620             : #if AP_CUSTOMROTATIONS_ENABLED
     621             :     AP_CustomRotations custom_rotations;
     622             : #endif
     623             : 
     624             : #if AP_FILTER_ENABLED
     625             :     AP_Filters filters;
     626             : #endif
     627             : 
     628             : };
     629             : 
     630             : namespace AP {
     631             :     AP_Vehicle *vehicle();
     632             : };
     633             : 
     634             : extern const AP_HAL::HAL& hal;
     635             : 
     636             : extern const AP_Param::Info vehicle_var_info[];
     637             : 
     638             : #include "AP_Vehicle_Type.h"
     639             : 
     640             : #endif  // AP_VEHICLE_ENABLED

Generated by: LCOV version 1.14