AP_RangeFinder: add quality to Blue Robotics Ping1D driver

This commit is contained in:
Willian Galvani 2023-07-27 23:46:53 -03:00 committed by Peter Barker
parent fd4da61067
commit 494b3076ac
2 changed files with 16 additions and 0 deletions

View File

@ -83,6 +83,15 @@ bool AP_RangeFinder_BLPing::get_reading(float &reading_m)
return false;
}
bool AP_RangeFinder_BLPing::get_signal_quality_pct(int8_t &quality_pct) const
{
if (status() != RangeFinder::Status::Good) {
return false;
}
quality_pct = protocol.get_confidence();
return true;
}
uint8_t PingProtocol::get_confidence() const
{
return msg.payload[4];

View File

@ -133,6 +133,13 @@ public:
*/
void update(void) override;
/**
* @brief Get the reading confidence
* 100 is best quality, 0 is worst
*
*/
bool get_signal_quality_pct(int8_t &quality_pct) const override WARN_IF_UNUSED;
protected:
/**
* @brief Return the sensor type