LCOV - code coverage report
Current view: top level - AP_Mount - AP_Mount_Scripting.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 6 6 100.0 %
Date: 2026-09-09 11:02:08 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :   Scripting mount/gimbal driver
       3             :  */
       4             : 
       5             : #pragma once
       6             : 
       7             : #include "AP_Mount_config.h"
       8             : 
       9             : #if HAL_MOUNT_SCRIPTING_ENABLED
      10             : 
      11             : #include "AP_Mount_Backend.h"
      12             : 
      13             : #include <AP_HAL/AP_HAL.h>
      14             : #include <AP_Math/AP_Math.h>
      15             : #include <AP_Common/AP_Common.h>
      16             : 
      17             : class AP_Mount_Scripting : public AP_Mount_Backend
      18             : {
      19             : 
      20             : public:
      21             :     // Constructor
      22             :     using AP_Mount_Backend::AP_Mount_Backend;
      23             : 
      24             :     /* Do not allow copies */
      25             :     CLASS_NO_COPY(AP_Mount_Scripting);
      26             : 
      27             :     // update mount position - should be called periodically
      28             :     void update() override;
      29             : 
      30             :     // return true if healthy
      31             :     bool healthy() const override;
      32             : 
      33             :     // has_pan_control - returns true if this mount can control its pan (required for multicopters)
      34           4 :     bool has_pan_control() const override { return yaw_range_valid(); };
      35             : 
      36             :     // accessors for scripting backends
      37             :     void set_attitude_euler(float roll_deg, float pitch_deg, float yaw_bf_deg) override;
      38             : 
      39             :     // get target rate in deg/sec. returns true on success
      40             :     bool get_rate_target(float& roll_degs, float& pitch_degs, float& yaw_degs, bool& yaw_is_earth_frame) override;
      41             : 
      42             :     // get target angle in deg. returns true on success
      43             :     bool get_angle_target(float& roll_deg, float& pitch_deg, float& yaw_deg, bool& yaw_is_earth_frame) override;
      44             : 
      45             : protected:
      46             : 
      47           1 :     void set_natively_supported_mount_target_types(uint8_t types_mask) override {
      48           1 :         supported_target_types_mask = types_mask;
      49           1 :     }
      50             : 
      51             :     // Scripting doesn't actually send anything (the script polls the
      52             :     // library for the targets)
      53       14055 :     uint8_t natively_supported_mount_target_types() const override {
      54       14055 :         return supported_target_types_mask;
      55             :     };
      56             :     void send_target_angles(const MountAngleTarget &angle_rad) override;
      57             :     void send_target_rates(const MountRateTarget &rate_rads) override;
      58             : 
      59             :     // get attitude as a quaternion.  returns true on success
      60             :     bool get_attitude_quaternion(Quaternion& att_quat) override;
      61             : 
      62             : private:
      63             : 
      64             :     enum class ScriptTargetType : uint8_t {
      65             :         NONE  = 0,
      66             :         ANGLE = 1,
      67             :         RATE  = 2,
      68             :     };
      69             : 
      70             :     // internal variables
      71             :     uint32_t last_update_ms;            // system time of last call to one of the get_ methods.  Used for health reporting
      72             :     Vector3f current_angle_deg;         // current gimbal angles in degrees (x=roll, y=pitch, z=yaw)
      73             :     ScriptTargetType _script_target_type {ScriptTargetType::NONE};
      74             :     MountAngleTarget _angle_target {};  // last angle target pushed by send_target_angles()
      75             :     MountRateTarget  _rate_target {};   // last rate target pushed by send_target_rates()
      76             : 
      77             :     uint8_t supported_target_types_mask = NATIVE_ANGLES_AND_RATES_ONLY;
      78             : };
      79             : 
      80             : #endif // HAL_MOUNT_SCRIPTING_ENABLED

Generated by: LCOV version 1.14