LCOV - code coverage report
Current view: top level - home/pbarker/rc/ardupilot/ArduPlane - sensors.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 9 10 90.0 %
Date: 2026-09-09 11:02:08 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "Plane.h"
       2             : #include <AP_RSSI/AP_RSSI.h>
       3             : #include <AP_OpticalFlow/AP_OpticalFlow.h>
       4             : 
       5             : #if AP_RANGEFINDER_ENABLED
       6             : /*
       7             :   read the rangefinder and update height estimate
       8             :  */
       9     2736341 : void Plane::read_rangefinder(void)
      10             : {
      11             : 
      12             :     // notify the rangefinder of our approximate altitude above ground to allow it to power on
      13             :     // during low-altitude flight when configured to power down during higher-altitude flight
      14             :     float height;
      15             : #if AP_TERRAIN_AVAILABLE
      16     2736341 :     if (terrain.status() == AP_Terrain::TerrainStatusOK && terrain.height_above_terrain(height, true)) {
      17     2551411 :         rangefinder.set_estimated_terrain_height(height);
      18             :     } else
      19             : #endif
      20             :     {
      21             :         // use the best available alt estimate via baro above home
      22      184930 :         if (flight_stage == AP_FixedWing::FlightStage::LAND) {
      23             :             // ensure the rangefinder is powered-on when land alt is higher than home altitude.
      24             :             // This is done using the target alt which we know is below us and we are sinking to it
      25           0 :             height = height_above_target();
      26             :         } else {
      27             :             // otherwise just use the best available baro estimate above home.
      28      184930 :             height = relative_altitude;
      29             :         }
      30      184930 :         rangefinder.set_estimated_terrain_height(height);
      31             :     }
      32             : 
      33     2736341 :     rangefinder.update();
      34             : 
      35     2736341 :     rangefinder_height_update();
      36     2736341 : }
      37             : 
      38             : #endif  // AP_RANGEFINDER_ENABLED

Generated by: LCOV version 1.14