|
|
|
@ -28,6 +28,8 @@ extern const AP_HAL::HAL& hal;
@@ -28,6 +28,8 @@ extern const AP_HAL::HAL& hal;
|
|
|
|
|
#define TR_WHOAMI 0x01 |
|
|
|
|
#define TR_WHOAMI_VALUE 0xA1 |
|
|
|
|
|
|
|
|
|
#define TR_OUT_OF_RANGE_ADD_CM 100 //cm
|
|
|
|
|
|
|
|
|
|
AP_RangeFinder_TeraRangerI2C::AP_RangeFinder_TeraRangerI2C(RangeFinder::RangeFinder_State &_state, |
|
|
|
|
AP_RangeFinder_Params &_params, |
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> i2c_dev) |
|
|
|
@ -138,14 +140,15 @@ bool AP_RangeFinder_TeraRangerI2C::process_raw_measure(uint16_t raw_distance, ui
@@ -138,14 +140,15 @@ bool AP_RangeFinder_TeraRangerI2C::process_raw_measure(uint16_t raw_distance, ui
|
|
|
|
|
return false; |
|
|
|
|
} else if (raw_distance == 0x0000) { |
|
|
|
|
// Too close
|
|
|
|
|
return false; |
|
|
|
|
output_distance_cm = 0; |
|
|
|
|
} else if (raw_distance == 0x0001) { |
|
|
|
|
// Unable to measure
|
|
|
|
|
return false; |
|
|
|
|
// This can also include the sensor pointing to the horizon when used as a proximity sensor
|
|
|
|
|
output_distance_cm = max_distance_cm() + TR_OUT_OF_RANGE_ADD_CM; |
|
|
|
|
} else { |
|
|
|
|
output_distance_cm = raw_distance/10; // Conversion to centimeters
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|