LCOV - code coverage report
Current view: top level - AP_RangeFinder - AP_RangeFinder_Wasp.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             : #pragma once
       2             : 
       3             : #include "AP_RangeFinder_config.h"
       4             : 
       5             : #if AP_RANGEFINDER_WASP_ENABLED
       6             : 
       7             : #include "AP_RangeFinder.h"
       8             : #include "AP_RangeFinder_Backend_Serial.h"
       9             : 
      10             : // WASP 200 LRF
      11             : // http://www.attolloengineering.com/wasp-200-lrf.html
      12             : 
      13             : class AP_RangeFinder_Wasp : public AP_RangeFinder_Backend_Serial {
      14             : 
      15             : public:
      16             : 
      17           1 :     static AP_RangeFinder_Backend_Serial *create(
      18             :         RangeFinder::RangeFinder_State &_state,
      19             :         AP_RangeFinder_Params &_params) {
      20           1 :         return NEW_NOTHROW AP_RangeFinder_Wasp(_state, _params);
      21             :     }
      22             : 
      23             :     void update(void) override;
      24             : 
      25             :     static const struct AP_Param::GroupInfo var_info[];
      26             : 
      27             : protected:
      28             : 
      29             :     // Wasp is always 115200
      30           1 :     uint32_t initial_baudrate(uint8_t serial_instance) const override {
      31           1 :         return 115200;
      32             :     }
      33             : 
      34         338 :     MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
      35         338 :         return MAV_DISTANCE_SENSOR_LASER;
      36             :     }
      37             : 
      38             : private:
      39             : 
      40             :     AP_RangeFinder_Wasp(RangeFinder::RangeFinder_State &_state,
      41             :                         AP_RangeFinder_Params &_params);
      42             : 
      43             :     enum wasp_configuration_stage {
      44             :         WASP_CFG_RATE,     // set the baudrate
      45             :         WASP_CFG_ENCODING, // set the encoding to LBE
      46             :         WASP_CFG_PROTOCOL, // set the protocol type used
      47             :         WASP_CFG_FRQ,      // set the update frequency
      48             :         WASP_CFG_GO,       // start/resume readings
      49             :         WASP_CFG_AUT,      // set the auto sensitivity threshold
      50             :         WASP_CFG_THR,      // set the sensitivity threshold
      51             :         WASP_CFG_MAVG,     // set the moving average filter
      52             :         WASP_CFG_MEDF,     // set the median filter windows size
      53             :         WASP_CFG_AVG,      // set the multi-pulse averages
      54             :         WASP_CFG_AUV,      // enforce auto voltage
      55             :         WASP_CFG_DONE      // done configuring
      56             :     };
      57             : 
      58             :     wasp_configuration_stage configuration_state = WASP_CFG_PROTOCOL;
      59             : 
      60             :     bool get_reading(float &reading_m) override;
      61             : 
      62             :     void parse_response(void);
      63             : 
      64             :     char linebuf[10];
      65             :     uint8_t linebuf_len;
      66             :     AP_Int16 mavg;
      67             :     AP_Int16 medf;
      68             :     AP_Int16 frq;
      69             :     AP_Int16 avg;
      70             :     AP_Int16 thr;
      71             :     AP_Int8  baud;
      72             : };
      73             : 
      74             : #endif

Generated by: LCOV version 1.14