AP_Proximity: Revert an excessive scan introduced in #8375

Also removes 2 unneeded initilizers, and removes an unneeded runtime
check
This commit is contained in:
Michael du Breuil 2018-05-13 00:31:37 -07:00 committed by Randy Mackay
parent c92554001f
commit 636782375e
2 changed files with 3 additions and 5 deletions

View File

@ -175,8 +175,6 @@ const AP_Param::GroupInfo AP_Proximity::var_info[] = {
}; };
AP_Proximity::AP_Proximity(AP_SerialManager &_serial_manager) : AP_Proximity::AP_Proximity(AP_SerialManager &_serial_manager) :
primary_instance(0),
num_instances(0),
serial_manager(_serial_manager) serial_manager(_serial_manager)
{ {
AP_Param::setup_object_defaults(this, var_info); AP_Param::setup_object_defaults(this, var_info);

View File

@ -24,6 +24,7 @@ extern const AP_HAL::HAL& hal;
AP_Proximity_RangeFinder::AP_Proximity_RangeFinder(AP_Proximity &_frontend, AP_Proximity_RangeFinder::AP_Proximity_RangeFinder(AP_Proximity &_frontend,
AP_Proximity::Proximity_State &_state) : AP_Proximity::Proximity_State &_state) :
_distance_upward(-1),
AP_Proximity_Backend(_frontend, _state) AP_Proximity_Backend(_frontend, _state)
{ {
} }
@ -41,7 +42,7 @@ void AP_Proximity_RangeFinder::update(void)
uint32_t now = AP_HAL::millis(); uint32_t now = AP_HAL::millis();
// look through all rangefinders // look through all rangefinders
for (uint8_t i=0; i < RANGEFINDER_MAX_INSTANCES; i++) { for (uint8_t i=0; i < rngfnd->num_sensors(); i++) {
AP_RangeFinder_Backend *sensor = rngfnd->get_backend(i); AP_RangeFinder_Backend *sensor = rngfnd->get_backend(i);
if (sensor == nullptr) { if (sensor == nullptr) {
continue; continue;
@ -84,8 +85,7 @@ void AP_Proximity_RangeFinder::update(void)
// get distance upwards in meters. returns true on success // get distance upwards in meters. returns true on success
bool AP_Proximity_RangeFinder::get_upward_distance(float &distance) const bool AP_Proximity_RangeFinder::get_upward_distance(float &distance) const
{ {
if ((_last_upward_update_ms != 0) && if ((AP_HAL::millis() - _last_upward_update_ms <= PROXIMITY_RANGEFIDER_TIMEOUT_MS) &&
(AP_HAL::millis() - _last_upward_update_ms <= PROXIMITY_RANGEFIDER_TIMEOUT_MS) &&
is_positive(_distance_upward)) { is_positive(_distance_upward)) {
distance = _distance_upward; distance = _distance_upward;
return true; return true;