LCOV - code coverage report
Current view: top level - AP_IRLock - AP_IRLock.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 3 3 100.0 %
Date: 2026-09-09 11:02:08 Functions: 3 3 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             : /*
      17             :  * AP_IRLock.h - IRLock Base Class for Ardupilot
      18             :  *
      19             :  *  Created on: Nov 10, 2014
      20             :  *      Author: MLandes
      21             :  */
      22             : #pragma once
      23             : 
      24             : #include "AP_IRLock_config.h"
      25             : 
      26             : #if AP_IRLOCK_ENABLED
      27             : 
      28             : #include <AP_Math/AP_Math.h>
      29             : 
      30             : class AP_IRLock
      31             : {
      32             : public:
      33             :     // init - initialize sensor library
      34             :     // library won't be useable unless this is first called
      35             :     virtual void init(int8_t bus) = 0;
      36             : 
      37             :     // true if irlock sensor is online and healthy
      38       36450 :     bool healthy() const { return _flags.healthy; }
      39             : 
      40             :     // timestamp of most recent data read from the sensor
      41       15860 :     uint32_t last_update_ms() const { return _last_update_ms; }
      42             : 
      43             :     // returns the number of blocks in the current frame
      44       36450 :     size_t num_targets() const { return _flags.healthy?1:0; }
      45             : 
      46             :     // retrieve latest sensor data - returns true if new data is available
      47             :     virtual bool update() = 0;
      48             : 
      49             :     // retrieve body frame unit vector in direction of target
      50             :     // returns true if data is available
      51             :     bool get_unit_vector_body(Vector3f& ret) const;
      52             :     
      53             : 
      54             : protected:
      55             :     struct AP_IRLock_Flags {
      56             :         bool healthy; // true if sensor is healthy
      57             :     } _flags;
      58             : 
      59             :     // internals
      60             :     uint32_t _last_update_ms;
      61             : 
      62             :     // irlock_target_info is a duplicate of the PX4Firmware irlock_s structure
      63             :     typedef struct {
      64             :         uint32_t timestamp;   // milliseconds since system start
      65             :         float pos_x;          // x-axis distance from center of image to center of target in units of tan(theta)
      66             :         float pos_y;          // y-axis distance from center of image to center of target in units of tan(theta)
      67             :         float pos_z;
      68             :     } irlock_target_info;
      69             : 
      70             :     irlock_target_info _target_info;
      71             : };
      72             : 
      73             : #endif  // AP_IRLOCK_ENABLED

Generated by: LCOV version 1.14