Line data Source code
1 : #pragma once 2 : 3 : #include "AP_RangeFinder_config.h" 4 : 5 : #if AP_RANGEFINDER_LIGHTWARE_GRF_ENABLED 6 : 7 : #include "AP_RangeFinder_Backend_Serial.h" 8 : #include "AP_RangeFinder_LightWare_GRF_Common.h" 9 : #include <AP_LightWareSerial/AP_LightWareSerial.h> 10 : 11 : class AP_RangeFinder_LightWareGRF : public AP_RangeFinder_Backend_Serial, 12 : public AP_LightWareSerial, 13 : public AP_RangeFinder_LightWare_GRF_Common 14 : { 15 : public: 16 1 : static AP_RangeFinder_Backend_Serial *create( 17 : RangeFinder::RangeFinder_State &_state, 18 : AP_RangeFinder_Params &_params) 19 : { 20 1 : return NEW_NOTHROW AP_RangeFinder_LightWareGRF(_state, _params); 21 : } 22 : 23 : static const struct AP_Param::GroupInfo var_info[]; 24 : 25 : protected: 26 : 27 : // Returns the MAVLink distance sensor type 28 339 : MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override { return MAV_DISTANCE_SENSOR_LASER; } 29 : 30 : // Called periodically to fetch a new range reading 31 : bool get_reading(float &reading_m) override; 32 : 33 : // Returns read timeout in milliseconds 34 15 : uint16_t read_timeout_ms() const override { return 500; } 35 : 36 : private: 37 : // Constructor 38 : AP_RangeFinder_LightWareGRF(RangeFinder::RangeFinder_State &_state, 39 : AP_RangeFinder_Params &_params); 40 : 41 : // Send configuration messages to the rangefinder 42 : void configure_rangefinder(); 43 : 44 : // Parses config responses and advances setup step 45 : void check_config(const MessageID &resp_cmd_id, const uint8_t* response_buf, const uint16_t& response_len); 46 : 47 : // Processes the latest message held in the _msg structure 48 : void process_message(float &sum_m, uint8_t &count); 49 : 50 : uint32_t last_config_message_ms; // last time we sent a config message 51 : ConfigStep config_step; // current configuration step 52 : }; 53 : 54 : #endif // AP_RANGEFINDER_LIGHTWARE_GRF_ENABLED