AP_RangeFinder: have two instances on all platforms

rover needs two sonars for obstacle avoidance
This commit is contained in:
Andrew Tridgell 2014-06-27 13:18:54 +10:00
parent bfe705a14d
commit 22b9059647

View File

@ -22,11 +22,7 @@
#include <AP_Param.h> #include <AP_Param.h>
// Maximum number of range finder instances available on this platform // Maximum number of range finder instances available on this platform
#if HAL_CPU_CLASS >= HAL_CPU_CLASS_75
#define RANGEFINDER_MAX_INSTANCES 2 #define RANGEFINDER_MAX_INSTANCES 2
#else
#define RANGEFINDER_MAX_INSTANCES 1
#endif
class AP_RangeFinder_Backend; class AP_RangeFinder_Backend;
@ -91,11 +87,7 @@ public:
// 10Hz from main loop // 10Hz from main loop
void update(void); void update(void);
#if RANGEFINDER_MAX_INSTANCES == 1 #define _RangeFinder_STATE(instance) state[instance]
# define _RangeFinder_STATE(instance) state[0]
#else
# define _RangeFinder_STATE(instance) state[instance]
#endif
uint16_t distance_cm(uint8_t instance) const { uint16_t distance_cm(uint8_t instance) const {
return _RangeFinder_STATE(instance).distance_cm; return _RangeFinder_STATE(instance).distance_cm;
@ -126,7 +118,7 @@ public:
} }
bool healthy(uint8_t instance) const { bool healthy(uint8_t instance) const {
return _RangeFinder_STATE(instance).healthy; return instance < num_instances && _RangeFinder_STATE(instance).healthy;
} }
bool healthy() const { bool healthy() const {
return healthy(primary_instance); return healthy(primary_instance);