mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-08 08:53:56 -04:00
AP_Proximity: use rangefinder singleton
This commit is contained in:
parent
730257fe26
commit
8bd7841c6e
@ -18,7 +18,7 @@
|
|||||||
#include <AP_HAL/AP_HAL.h>
|
#include <AP_HAL/AP_HAL.h>
|
||||||
#include <AP_Param/AP_Param.h>
|
#include <AP_Param/AP_Param.h>
|
||||||
#include <AP_Math/AP_Math.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_INSTANCES 1 // Maximum number of proximity sensor instances available on this platform
|
||||||
#define PROXIMITY_MAX_IGNORE 6 // up to six areas can be ignored
|
#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
|
// update state of all proximity sensors. Should be called at high rate from main loop
|
||||||
void update(void);
|
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
|
// return sensor orientation and yaw correction
|
||||||
uint8_t get_orientation(uint8_t instance) const;
|
uint8_t get_orientation(uint8_t instance) const;
|
||||||
int16_t get_yaw_correction(uint8_t instance) const;
|
int16_t get_yaw_correction(uint8_t instance) const;
|
||||||
@ -147,7 +143,6 @@ private:
|
|||||||
static AP_Proximity *_singleton;
|
static AP_Proximity *_singleton;
|
||||||
Proximity_State state[PROXIMITY_MAX_INSTANCES];
|
Proximity_State state[PROXIMITY_MAX_INSTANCES];
|
||||||
AP_Proximity_Backend *drivers[PROXIMITY_MAX_INSTANCES];
|
AP_Proximity_Backend *drivers[PROXIMITY_MAX_INSTANCES];
|
||||||
const RangeFinder *_rangefinder;
|
|
||||||
uint8_t primary_instance;
|
uint8_t primary_instance;
|
||||||
uint8_t num_instances;
|
uint8_t num_instances;
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
#include <AP_HAL/AP_HAL.h>
|
#include <AP_HAL/AP_HAL.h>
|
||||||
#include "AP_Proximity_RangeFinder.h"
|
#include "AP_Proximity_RangeFinder.h"
|
||||||
#include <AP_SerialManager/AP_SerialManager.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <AP_RangeFinder/AP_RangeFinder.h>
|
||||||
#include <AP_RangeFinder/RangeFinder_Backend.h>
|
#include <AP_RangeFinder/RangeFinder_Backend.h>
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
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)
|
void AP_Proximity_RangeFinder::update(void)
|
||||||
{
|
{
|
||||||
// exit immediately if no rangefinder object
|
// exit immediately if no rangefinder object
|
||||||
const RangeFinder *rngfnd = frontend.get_rangefinder();
|
const RangeFinder *rngfnd = AP::rangefinder();
|
||||||
if (rngfnd == nullptr) {
|
if (rngfnd == nullptr) {
|
||||||
set_status(AP_Proximity::Status::NoData);
|
set_status(AP_Proximity::Status::NoData);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user