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

          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             : 
      16             : #pragma once
      17             : #include "stdint.h"
      18             : #include <AP_Param/AP_Param.h>
      19             : #include <AP_Math/AP_Math.h>
      20             : #include <AP_Common/Location.h>
      21             : 
      22             : namespace SITL {
      23             : 
      24             : class SIM_Precland {
      25             : public:
      26        2096 :     SIM_Precland() {
      27        2096 :         AP_Param::setup_object_defaults(this, var_info);
      28        2096 :     };
      29             : 
      30             :     // update precland state
      31             :     void update(const Location &loc);
      32             : 
      33             :     // true if precland sensor is online and healthy
      34      241469 :     bool healthy() const { return _healthy; }
      35             : 
      36             :     // timestamp of most recent data read from the sensor
      37      102406 :     uint32_t last_update_ms() const { return _last_update_ms; }
      38             : 
      39       26218 :     const Vector3d &get_target_position() const { return _target_pos; }
      40   178759942 :     bool is_enabled() const {return static_cast<bool>(_enable);}
      41             :     void set_default_location(float lat, float lon, int16_t yaw);
      42             :     static const struct AP_Param::GroupInfo var_info[];
      43             : 
      44             :     // enum for SIM_PLD_OPTIONS parameter
      45             :     enum class Option : uint8_t {
      46             :         ENABLE_TARGET_DISTANCE   = (1U << 0),
      47             :     };
      48             : 
      49             :     AP_Int8 _enable;
      50             :     AP_Float _device_lat;
      51             :     AP_Float _device_lon;
      52             :     AP_Float _device_height;
      53             :     AP_Int16 _orient_yaw;
      54             :     AP_Int8 _type;
      55             :     AP_Int32 _rate;
      56             :     AP_Float _alt_limit;
      57             :     AP_Float _dist_limit;
      58             :     AP_Int8 _orient;
      59             :     AP_Int8 _ship;
      60             :     AP_Enum<Option> _options;
      61             : 
      62             :     bool _over_precland_base;
      63             : 
      64             :     enum PreclandType {
      65             :         PRECLAND_TYPE_CYLINDER = 0,
      66             :         PRECLAND_TYPE_CONE = 1,
      67             :         PRECLAND_TYPE_SPHERE = 2,
      68             :     };
      69             : 
      70       23046 :     bool option_enabled(Option option) const {
      71       23046 :         return (_options & uint8_t(option)) != 0;
      72             :     }
      73             : private:
      74             :     uint32_t _last_update_ms;
      75             :     bool _healthy;
      76             :     Vector3d _target_pos;
      77             : 
      78             :     // last time we warned user about needed to et lat/lng/alt:
      79             :     uint32_t last_set_parameters_warning_ms;
      80             : };
      81             : 
      82             : }

Generated by: LCOV version 1.14