mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-26 09:43:57 -04:00
AP_RangFinder: support various maxbotix serial sonar
This commit is contained in:
parent
09dac0cc8a
commit
051104a3f7
@ -24,6 +24,14 @@
|
|||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
|
AP_RangeFinder_MaxsonarSerialLV::AP_RangeFinder_MaxsonarSerialLV(
|
||||||
|
RangeFinder::RangeFinder_State &_state,
|
||||||
|
AP_RangeFinder_Params &_params):
|
||||||
|
AP_RangeFinder_Backend_Serial(_state, _params)
|
||||||
|
{
|
||||||
|
params.scaling.set_default(0.0254f);
|
||||||
|
}
|
||||||
|
|
||||||
// read - return last value measured by sensor
|
// read - return last value measured by sensor
|
||||||
bool AP_RangeFinder_MaxsonarSerialLV::get_reading(float &reading_m)
|
bool AP_RangeFinder_MaxsonarSerialLV::get_reading(float &reading_m)
|
||||||
{
|
{
|
||||||
@ -56,7 +64,7 @@ bool AP_RangeFinder_MaxsonarSerialLV::get_reading(float &reading_m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This sonar gives the metrics in inches, so we have to transform this to meters
|
// This sonar gives the metrics in inches, so we have to transform this to meters
|
||||||
reading_m = (2.54f * 0.01f) * (float(sum) / count);
|
reading_m = params.scaling * (float(sum) / count);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ class AP_RangeFinder_MaxsonarSerialLV : public AP_RangeFinder_Backend_Serial
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial;
|
AP_RangeFinder_MaxsonarSerialLV(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ const AP_Param::GroupInfo AP_RangeFinder_Params::var_info[] = {
|
|||||||
|
|
||||||
// @Param: SCALING
|
// @Param: SCALING
|
||||||
// @DisplayName: Rangefinder scaling
|
// @DisplayName: Rangefinder scaling
|
||||||
// @Description: Scaling factor between rangefinder reading and distance. For the linear and inverted functions this is in meters per volt. For the hyperbolic function the units are meterVolts.
|
// @Description: Scaling factor between rangefinder reading and distance. For the linear and inverted functions this is in meters per volt. For the hyperbolic function the units are meterVolts. For Maxbotix serial sonar this is unit conversion to meters.
|
||||||
// @Units: m/V
|
// @Units: m/V
|
||||||
// @Increment: 0.001
|
// @Increment: 0.001
|
||||||
// @User: Standard
|
// @User: Standard
|
||||||
|
Loading…
Reference in New Issue
Block a user