2018-05-16 19:31:22 -03:00
|
|
|
#pragma once
|
|
|
|
|
2023-07-06 01:25:14 -03:00
|
|
|
#include "AP_RangeFinder_config.h"
|
2022-03-12 06:37:29 -04:00
|
|
|
|
|
|
|
#if AP_RANGEFINDER_WASP_ENABLED
|
|
|
|
|
2023-07-06 01:25:14 -03:00
|
|
|
#include "AP_RangeFinder.h"
|
|
|
|
#include "AP_RangeFinder_Backend_Serial.h"
|
|
|
|
|
2018-05-16 19:31:22 -03:00
|
|
|
// WASP 200 LRF
|
|
|
|
// http://www.attolloengineering.com/wasp-200-lrf.html
|
|
|
|
|
2019-11-01 07:23:16 -03:00
|
|
|
class AP_RangeFinder_Wasp : public AP_RangeFinder_Backend_Serial {
|
2018-05-16 19:31:22 -03:00
|
|
|
|
|
|
|
public:
|
2022-06-22 08:03:22 -03:00
|
|
|
|
|
|
|
static AP_RangeFinder_Backend_Serial *create(
|
|
|
|
RangeFinder::RangeFinder_State &_state,
|
|
|
|
AP_RangeFinder_Params &_params) {
|
|
|
|
return new AP_RangeFinder_Wasp(_state, _params);
|
|
|
|
}
|
2018-05-16 19:31:22 -03:00
|
|
|
|
|
|
|
void update(void) override;
|
|
|
|
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2019-11-01 07:23:16 -03:00
|
|
|
// Wasp is always 115200
|
|
|
|
uint32_t initial_baudrate(uint8_t serial_instance) const override {
|
|
|
|
return 115200;
|
|
|
|
}
|
|
|
|
|
2020-01-13 01:48:07 -04:00
|
|
|
MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
2018-05-16 19:31:22 -03:00
|
|
|
return MAV_DISTANCE_SENSOR_LASER;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-06-22 08:03:22 -03:00
|
|
|
AP_RangeFinder_Wasp(RangeFinder::RangeFinder_State &_state,
|
|
|
|
AP_RangeFinder_Params &_params);
|
|
|
|
|
2018-05-16 19:31:22 -03:00
|
|
|
enum wasp_configuration_stage {
|
|
|
|
WASP_CFG_RATE, // set the baudrate
|
|
|
|
WASP_CFG_ENCODING, // set the encoding to LBE
|
|
|
|
WASP_CFG_PROTOCOL, // set the protocol type used
|
|
|
|
WASP_CFG_FRQ, // set the update frequency
|
|
|
|
WASP_CFG_GO, // start/resume readings
|
|
|
|
WASP_CFG_AUT, // set the auto sensitivity threshold
|
|
|
|
WASP_CFG_THR, // set the sensitivity threshold
|
|
|
|
WASP_CFG_MAVG, // set the moving average filter
|
|
|
|
WASP_CFG_MEDF, // set the median filter windows size
|
|
|
|
WASP_CFG_AVG, // set the multi-pulse averages
|
|
|
|
WASP_CFG_AUV, // enforce auto voltage
|
|
|
|
WASP_CFG_DONE // done configuring
|
|
|
|
};
|
|
|
|
|
2019-11-01 07:23:16 -03:00
|
|
|
wasp_configuration_stage configuration_state = WASP_CFG_PROTOCOL;
|
2018-05-16 19:31:22 -03:00
|
|
|
|
2021-10-18 02:45:33 -03:00
|
|
|
bool get_reading(float &reading_m) override;
|
2018-05-16 19:31:22 -03:00
|
|
|
|
|
|
|
void parse_response(void);
|
|
|
|
|
|
|
|
char linebuf[10];
|
|
|
|
uint8_t linebuf_len;
|
|
|
|
AP_Int16 mavg;
|
|
|
|
AP_Int16 medf;
|
|
|
|
AP_Int16 frq;
|
|
|
|
AP_Int16 avg;
|
|
|
|
AP_Int16 thr;
|
|
|
|
AP_Int8 baud;
|
|
|
|
};
|
2022-03-12 06:37:29 -04:00
|
|
|
|
|
|
|
#endif
|