LCOV - code coverage report
Current view: top level - AC_PrecLand - AC_PrecLand_Backend.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 11 14 78.6 %
Date: 2026-09-09 11:02:08 Functions: 5 8 62.5 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AC_PrecLand_config.h"
       4             : 
       5             : #if AC_PRECLAND_ENABLED
       6             : 
       7             : #include "AC_PrecLand.h"
       8             : #include <AP_Math/AP_Math.h>
       9             : #include <AC_PID/AC_PID.h>
      10             : 
      11             : 
      12             : class AC_PrecLand_Backend
      13             : {
      14             : public:
      15             :     // Constructor
      16          13 :     AC_PrecLand_Backend(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state) :
      17          13 :         _frontend(frontend),
      18          13 :         _state(state) {}
      19             : 
      20             :     // destructor
      21           0 :     virtual ~AC_PrecLand_Backend() {}
      22             : 
      23             :     // perform any required initialisation of backend
      24             :     virtual void init() = 0;
      25             : 
      26             :     // retrieve updates from sensor
      27             :     virtual void update() = 0;
      28             : 
      29             :     // provides a unit vector towards the target in body frame
      30             :     //  returns same as have_los_meas()
      31       26879 :     bool get_los_meas(Vector3f& vec_unit, AC_PrecLand::VectorFrame& frame) const {
      32       26879 :         if (!_los_meas.valid) {
      33           0 :             return false;
      34             :         }
      35       26879 :         vec_unit = _los_meas.vec_unit;
      36       26879 :         frame = _los_meas.frame;
      37       26879 :         return true;
      38             :     };
      39             : 
      40             :     // returns system time in milliseconds of last los measurement
      41      337744 :     uint32_t los_meas_time_ms() const { return _los_meas.time_ms; };
      42             : 
      43             :     // returns distance to target in meters (0 means distance is not known)
      44       42044 :     float distance_to_target() const { return _distance_to_target; };
      45             : 
      46             :     // parses a mavlink message from the companion computer
      47           0 :     virtual void handle_msg(const mavlink_landing_target_t &packet, uint32_t timestamp_ms) {};
      48             : 
      49             :     // get bus parameter
      50           2 :     int8_t get_bus(void) const { return _frontend._bus.get(); }
      51             :     
      52             : protected:
      53             :     const AC_PrecLand&  _frontend;          // reference to precision landing front end
      54             :     AC_PrecLand::precland_state &_state;    // reference to this instances state
      55             : 
      56             :     struct {
      57             :         Vector3f vec_unit;  // unit vector pointing towards target in earth or body frame (see frame)
      58             :         AC_PrecLand::VectorFrame frame;  // frame of vector pointing towards target
      59             :         uint32_t time_ms;   // system time in milliseconds when the vector was measured
      60             :         bool valid;         // true if there is a valid measurement from the sensor
      61             :     } _los_meas;
      62             :     float               _distance_to_target;    // distance from the sensor to landing target in meters
      63             : };
      64             : 
      65             : #endif // AC_PRECLAND_ENABLED

Generated by: LCOV version 1.14