AP_Proximity: use rangefinder singleton

This commit is contained in:
Peter Barker 2019-09-27 19:04:30 +10:00 committed by Andrew Tridgell
parent 28dbfa7860
commit c3263b4d17
2 changed files with 3 additions and 8 deletions

View File

@ -18,7 +18,7 @@
#include <AP_HAL/AP_HAL.h>
#include <AP_Param/AP_Param.h>
#include <AP_Math/AP_Math.h>
#include <AP_RangeFinder/AP_RangeFinder.h>
#include <GCS_MAVLink/GCS_MAVLink.h>
#define PROXIMITY_MAX_INSTANCES 1 // Maximum number of proximity sensor instances available on this platform
#define PROXIMITY_MAX_IGNORE 6 // up to six areas can be ignored
@ -71,10 +71,6 @@ public:
// update state of all proximity sensors. Should be called at high rate from main loop
void update(void);
// set pointer to rangefinder object
void set_rangefinder(const class RangeFinder *rangefinder) { _rangefinder = rangefinder; }
const RangeFinder *get_rangefinder() const { return _rangefinder; }
// return sensor orientation and yaw correction
uint8_t get_orientation(uint8_t instance) const;
int16_t get_yaw_correction(uint8_t instance) const;
@ -147,7 +143,6 @@ private:
static AP_Proximity *_singleton;
Proximity_State state[PROXIMITY_MAX_INSTANCES];
AP_Proximity_Backend *drivers[PROXIMITY_MAX_INSTANCES];
const RangeFinder *_rangefinder;
uint8_t primary_instance;
uint8_t num_instances;

View File

@ -15,9 +15,9 @@
#include <AP_HAL/AP_HAL.h>
#include "AP_Proximity_RangeFinder.h"
#include <AP_SerialManager/AP_SerialManager.h>
#include <ctype.h>
#include <stdio.h>
#include <AP_RangeFinder/AP_RangeFinder.h>
#include <AP_RangeFinder/RangeFinder_Backend.h>
extern const AP_HAL::HAL& hal;
@ -33,7 +33,7 @@ AP_Proximity_RangeFinder::AP_Proximity_RangeFinder(AP_Proximity &_frontend,
void AP_Proximity_RangeFinder::update(void)
{
// exit immediately if no rangefinder object
const RangeFinder *rngfnd = frontend.get_rangefinder();
const RangeFinder *rngfnd = AP::rangefinder();
if (rngfnd == nullptr) {
set_status(AP_Proximity::Status::NoData);
return;