2014-06-09 14:14:50 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-02-17 21:25:44 -04:00
|
|
|
#pragma once
|
2012-01-10 19:44:04 -04:00
|
|
|
|
2023-04-05 09:59:30 -03:00
|
|
|
#include "AP_RangeFinder_config.h"
|
|
|
|
|
2015-08-11 03:28:45 -03:00
|
|
|
#include <AP_Common/AP_Common.h>
|
2022-02-28 21:19:18 -04:00
|
|
|
#include <AP_HAL/AP_HAL_Boards.h>
|
|
|
|
#include <AP_HAL/Semaphores.h>
|
2015-08-11 03:28:45 -03:00
|
|
|
#include <AP_Param/AP_Param.h>
|
2022-02-25 01:06:30 -04:00
|
|
|
#include <GCS_MAVLink/GCS_MAVLink.h>
|
2020-08-04 17:42:19 -03:00
|
|
|
#include <AP_MSP/msp.h>
|
2018-07-04 11:22:17 -03:00
|
|
|
#include "AP_RangeFinder_Params.h"
|
2012-01-10 19:44:04 -04:00
|
|
|
|
2014-06-09 14:14:50 -03:00
|
|
|
// Maximum number of range finder instances available on this platform
|
2022-03-08 00:04:15 -04:00
|
|
|
#ifndef RANGEFINDER_MAX_INSTANCES
|
|
|
|
#if AP_RANGEFINDER_ENABLED
|
|
|
|
#define RANGEFINDER_MAX_INSTANCES 10
|
|
|
|
#else
|
|
|
|
#define RANGEFINDER_MAX_INSTANCES 1
|
|
|
|
#endif
|
2019-10-19 01:13:36 -03:00
|
|
|
#endif
|
|
|
|
|
2015-04-12 23:38:25 -03:00
|
|
|
#define RANGEFINDER_GROUND_CLEARANCE_CM_DEFAULT 10
|
2015-04-13 00:18:46 -03:00
|
|
|
#define RANGEFINDER_PREARM_ALT_MAX_CM 200
|
2018-10-02 20:43:50 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
|
|
|
#define RANGEFINDER_PREARM_REQUIRED_CHANGE_CM 0
|
|
|
|
#else
|
2015-04-13 00:18:46 -03:00
|
|
|
#define RANGEFINDER_PREARM_REQUIRED_CHANGE_CM 50
|
2018-10-02 20:43:50 -03:00
|
|
|
#endif
|
2014-06-26 23:56:50 -03:00
|
|
|
|
2017-08-25 14:20:18 -03:00
|
|
|
class AP_RangeFinder_Backend;
|
|
|
|
|
2012-01-10 19:44:04 -04:00
|
|
|
class RangeFinder
|
|
|
|
{
|
2015-02-21 06:55:21 -04:00
|
|
|
friend class AP_RangeFinder_Backend;
|
2019-04-08 06:42:46 -03:00
|
|
|
//UAVCAN drivers are initialised in the Backend, hence list of drivers is needed there.
|
2023-04-08 01:09:10 -03:00
|
|
|
friend class AP_RangeFinder_DroneCAN;
|
2017-08-25 14:20:18 -03:00
|
|
|
public:
|
2019-07-09 03:14:52 -03:00
|
|
|
RangeFinder();
|
2017-08-25 14:20:18 -03:00
|
|
|
|
|
|
|
/* Do not allow copies */
|
2022-09-30 06:50:43 -03:00
|
|
|
CLASS_NO_COPY(RangeFinder);
|
2014-06-09 14:14:50 -03:00
|
|
|
|
|
|
|
// RangeFinder driver types
|
2019-11-01 00:03:14 -03:00
|
|
|
enum class Type {
|
|
|
|
NONE = 0,
|
2023-09-09 06:53:57 -03:00
|
|
|
#if AP_RANGEFINDER_ANALOG_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
ANALOG = 1,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_MAXSONARI2CXL_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
MBI2C = 2,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_PULSEDLIGHTLRF_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
PLI2C = 3,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
2020-02-11 22:22:20 -04:00
|
|
|
// PX4 = 4, // no longer used, but may be in some user's parameters
|
2023-09-09 06:53:57 -03:00
|
|
|
#if AP_RANGEFINDER_PWM_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
PX4_PWM= 5,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_BBB_PRU_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
BBB_PRU= 6,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_LWI2C_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
LWI2C = 7,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_LIGHTWARE_SERIAL_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
LWSER = 8,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_BEBOP_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
BEBOP = 9,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_MAVLINK_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
MAVLink = 10,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_USD1_SERIAL_ENABLED
|
2021-10-18 00:47:20 -03:00
|
|
|
USD1_Serial = 11,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_LEDDARONE_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
LEDDARONE = 12,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_MAXBOTIX_SERIAL_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
MBSER = 13,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_TRI2C_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
TRI2C = 14,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_PULSEDLIGHTLRF_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
PLI2CV3= 15,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
2019-11-01 00:03:14 -03:00
|
|
|
VL53L0X = 16,
|
2023-09-09 06:53:57 -03:00
|
|
|
#if AP_RANGEFINDER_NMEA_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
NMEA = 17,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_WASP_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
WASP = 18,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_BENEWAKE_TF02_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
BenewakeTF02 = 19,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_BENEWAKE_TFMINI_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
BenewakeTFmini = 20,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_PULSEDLIGHTLRF_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
PLI2CV3HP = 21,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_PWM_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
PWM = 22,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_BLPING_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
BLPing = 23,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_DRONECAN_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
UAVCAN = 24,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_BENEWAKE_TFMINIPLUS_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
BenewakeTFminiPlus = 25,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_LANBAO_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
Lanbao = 26,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_BENEWAKE_TF03_ENABLED
|
2019-11-01 00:03:14 -03:00
|
|
|
BenewakeTF03 = 27,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
2019-12-10 23:10:02 -04:00
|
|
|
VL53L1X_Short = 28,
|
2023-09-09 06:53:57 -03:00
|
|
|
#if AP_RANGEFINDER_LEDDARVU8_ENABLED
|
2020-01-13 01:48:57 -04:00
|
|
|
LeddarVu8_Serial = 29,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_HC_SR04_ENABLED
|
2020-05-17 03:41:50 -03:00
|
|
|
HC_SR04 = 30,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_GYUS42V2_ENABLED
|
2020-06-14 03:11:25 -03:00
|
|
|
GYUS42v2 = 31,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if HAL_MSP_RANGEFINDER_ENABLED
|
2020-08-04 17:42:19 -03:00
|
|
|
MSP = 32,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_USD1_CAN_ENABLED
|
2020-12-31 20:10:39 -04:00
|
|
|
USD1_CAN = 33,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_BENEWAKE_CAN_ENABLED
|
2021-11-12 06:11:48 -04:00
|
|
|
Benewake_CAN = 34,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_TERARANGER_SERIAL_ENABLED
|
2022-08-01 20:44:01 -03:00
|
|
|
TeraRanger_Serial = 35,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_LUA_ENABLED
|
2023-02-15 03:12:26 -04:00
|
|
|
Lua_Scripting = 36,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_NOOPLOOP_ENABLED
|
2023-05-31 10:26:10 -03:00
|
|
|
NoopLoop_P = 37,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_TOFSENSEP_CAN_ENABLED
|
2023-06-19 14:09:46 -03:00
|
|
|
TOFSenseP_CAN = 38,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_NRA24_CAN_ENABLED
|
2023-06-29 14:55:12 -03:00
|
|
|
NRA24_CAN = 39,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_TOFSENSEF_I2C_ENABLED
|
2023-10-14 20:44:26 -03:00
|
|
|
TOFSenseF_I2C = 40,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
2023-11-08 20:45:22 -04:00
|
|
|
#if AP_RANGEFINDER_JRE_SERIAL_ENABLED
|
|
|
|
JRE_Serial = 41,
|
|
|
|
#endif
|
2024-03-15 18:48:14 -03:00
|
|
|
#if AP_RANGEFINDER_AINSTEIN_LR_D1_ENABLED
|
|
|
|
Ainstein_LR_D1 = 42,
|
|
|
|
#endif
|
2023-12-25 12:26:17 -04:00
|
|
|
#if AP_RANGEFINDER_RDS02UF_ENABLED
|
2023-05-09 13:06:56 -03:00
|
|
|
RDS02UF = 43,
|
2023-12-25 12:26:17 -04:00
|
|
|
#endif
|
|
|
|
#if AP_RANGEFINDER_SIM_ENABLED
|
2021-07-30 07:41:47 -03:00
|
|
|
SIM = 100,
|
2023-09-09 06:53:57 -03:00
|
|
|
#endif
|
2014-06-09 14:14:50 -03:00
|
|
|
};
|
|
|
|
|
2019-11-01 00:06:21 -03:00
|
|
|
enum class Function {
|
|
|
|
LINEAR = 0,
|
|
|
|
INVERTED = 1,
|
|
|
|
HYPERBOLA = 2
|
2014-06-09 14:14:50 -03:00
|
|
|
};
|
2014-06-26 23:56:50 -03:00
|
|
|
|
2019-11-01 02:10:52 -03:00
|
|
|
enum class Status {
|
|
|
|
NotConnected = 0,
|
|
|
|
NoData,
|
|
|
|
OutOfRangeLow,
|
|
|
|
OutOfRangeHigh,
|
|
|
|
Good
|
2015-04-13 03:03:19 -03:00
|
|
|
};
|
2014-06-26 23:56:50 -03:00
|
|
|
|
2023-11-15 00:07:34 -04:00
|
|
|
static constexpr int8_t SIGNAL_QUALITY_MIN = 0;
|
|
|
|
static constexpr int8_t SIGNAL_QUALITY_MAX = 100;
|
|
|
|
static constexpr int8_t SIGNAL_QUALITY_UNKNOWN = -1;
|
|
|
|
|
2014-06-09 14:14:50 -03:00
|
|
|
// The RangeFinder_State structure is filled in by the backend driver
|
|
|
|
struct RangeFinder_State {
|
2021-10-18 02:45:33 -03:00
|
|
|
float distance_m; // distance in meters
|
2023-11-15 00:07:34 -04:00
|
|
|
int8_t signal_quality_pct; // measurement quality in percent 0-100, -1 -> quality is unknown
|
2018-08-27 03:04:32 -03:00
|
|
|
uint16_t voltage_mv; // voltage in millivolts, if applicable, otherwise 0
|
2019-11-01 02:10:52 -03:00
|
|
|
enum RangeFinder::Status status; // sensor status
|
2018-08-27 03:04:32 -03:00
|
|
|
uint8_t range_valid_count; // number of consecutive valid readings (maxes out at 10)
|
AP_RangeFinder: support last_reading_ms
Benewake, LeddarOne, LightWareSerial, MAVLink, MaxsonarI2CXL, MaxsonarSerialLV, NMEA, PX4_PWM, uLanding and Wasp already stored the last read time so for these drivers, this change just moves that storage to the state structure
analog, BBB_PRU, Bebop, LightWareI2C, PulsedLightLRF, TeraRangerI2C, VL53L0X did not store the last read time so this was added
2018-08-27 04:02:51 -03:00
|
|
|
uint32_t last_reading_ms; // system time of last successful update from sensor
|
2017-08-07 00:04:56 -03:00
|
|
|
|
2018-05-16 20:05:50 -03:00
|
|
|
const struct AP_Param::GroupInfo *var_info;
|
2014-06-09 14:14:50 -03:00
|
|
|
};
|
2012-01-10 19:44:04 -04:00
|
|
|
|
2018-05-16 20:05:50 -03:00
|
|
|
static const struct AP_Param::GroupInfo *backend_var_info[RANGEFINDER_MAX_INSTANCES];
|
2014-06-26 23:56:50 -03:00
|
|
|
|
2017-08-07 00:04:56 -03:00
|
|
|
// parameters for each instance
|
2014-06-09 14:14:50 -03:00
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
2019-04-05 06:20:22 -03:00
|
|
|
|
|
|
|
void set_log_rfnd_bit(uint32_t log_rfnd_bit) { _log_rfnd_bit = log_rfnd_bit; }
|
|
|
|
|
2020-11-26 17:51:38 -04:00
|
|
|
/*
|
|
|
|
Return the number of range finder instances. Note that if users
|
|
|
|
sets up rangefinders with a gap in the types then this is the
|
|
|
|
index of the maximum sensor ID plus one, so this gives the value
|
|
|
|
that should be used when iterating over all sensors
|
|
|
|
*/
|
2014-06-09 14:14:50 -03:00
|
|
|
uint8_t num_sensors(void) const {
|
|
|
|
return num_instances;
|
2012-11-27 21:39:15 -04:00
|
|
|
}
|
2012-01-10 19:44:04 -04:00
|
|
|
|
2019-04-10 04:32:15 -03:00
|
|
|
// prearm checks
|
|
|
|
bool prearm_healthy(char *failure_msg, const uint8_t failure_msg_len) const;
|
|
|
|
|
2014-06-26 23:56:50 -03:00
|
|
|
// detect and initialise any available rangefinders
|
2019-04-05 06:13:42 -03:00
|
|
|
void init(enum Rotation orientation_default);
|
2014-06-26 23:56:50 -03:00
|
|
|
|
|
|
|
// update state of all rangefinders. Should be called at around
|
|
|
|
// 10Hz from main loop
|
2014-06-09 14:14:50 -03:00
|
|
|
void update(void);
|
2016-05-04 00:02:44 -03:00
|
|
|
|
2016-05-03 23:55:05 -03:00
|
|
|
// Handle an incoming DISTANCE_SENSOR message (from a MAVLink enabled range finder)
|
2019-04-30 07:22:49 -03:00
|
|
|
void handle_msg(const mavlink_message_t &msg);
|
2016-05-04 00:02:44 -03:00
|
|
|
|
2020-08-31 06:16:32 -03:00
|
|
|
#if HAL_MSP_RANGEFINDER_ENABLED
|
2020-08-04 17:42:19 -03:00
|
|
|
// Handle an incoming DISTANCE_SENSOR message (from a MSP enabled range finder)
|
2020-09-07 19:29:23 -03:00
|
|
|
void handle_msp(const MSP::msp_rangefinder_data_message_t &pkt);
|
2020-09-01 04:54:29 -03:00
|
|
|
#endif
|
2017-02-09 06:26:57 -04:00
|
|
|
// return true if we have a range finder with the specified orientation
|
|
|
|
bool has_orientation(enum Rotation orientation) const;
|
|
|
|
|
|
|
|
// find first range finder instance with the specified orientation
|
2017-08-08 02:54:09 -03:00
|
|
|
AP_RangeFinder_Backend *find_instance(enum Rotation orientation) const;
|
2017-02-09 06:26:57 -04:00
|
|
|
|
2017-08-08 02:54:09 -03:00
|
|
|
AP_RangeFinder_Backend *get_backend(uint8_t id) const;
|
2017-02-09 06:26:57 -04:00
|
|
|
|
2020-01-24 19:58:15 -04:00
|
|
|
// get rangefinder type for an ID
|
|
|
|
Type get_type(uint8_t id) const {
|
|
|
|
return id >= RANGEFINDER_MAX_INSTANCES? Type::NONE : Type(params[id].type.get());
|
|
|
|
}
|
|
|
|
|
2020-05-11 01:27:55 -03:00
|
|
|
// get rangefinder address (for AP_Periph CAN)
|
|
|
|
uint8_t get_address(uint8_t id) const {
|
|
|
|
return id >= RANGEFINDER_MAX_INSTANCES? 0 : uint8_t(params[id].address.get());
|
|
|
|
}
|
|
|
|
|
2017-08-08 02:54:09 -03:00
|
|
|
// methods to return a distance on a particular orientation from
|
|
|
|
// any sensor which can current supply it
|
2021-10-18 02:45:33 -03:00
|
|
|
float distance_orient(enum Rotation orientation) const;
|
2017-02-09 06:26:57 -04:00
|
|
|
uint16_t distance_cm_orient(enum Rotation orientation) const;
|
2023-11-15 00:07:34 -04:00
|
|
|
int8_t signal_quality_pct_orient(enum Rotation orientation) const;
|
2017-02-09 06:26:57 -04:00
|
|
|
int16_t max_distance_cm_orient(enum Rotation orientation) const;
|
|
|
|
int16_t min_distance_cm_orient(enum Rotation orientation) const;
|
|
|
|
int16_t ground_clearance_cm_orient(enum Rotation orientation) const;
|
2017-08-08 04:32:53 -03:00
|
|
|
MAV_DISTANCE_SENSOR get_mav_distance_sensor_type_orient(enum Rotation orientation) const;
|
2019-11-01 02:10:52 -03:00
|
|
|
RangeFinder::Status status_orient(enum Rotation orientation) const;
|
2017-02-09 06:26:57 -04:00
|
|
|
bool has_data_orient(enum Rotation orientation) const;
|
|
|
|
uint8_t range_valid_count_orient(enum Rotation orientation) const;
|
2017-08-08 02:54:09 -03:00
|
|
|
const Vector3f &get_pos_offset_orient(enum Rotation orientation) const;
|
AP_RangeFinder: support last_reading_ms
Benewake, LeddarOne, LightWareSerial, MAVLink, MaxsonarI2CXL, MaxsonarSerialLV, NMEA, PX4_PWM, uLanding and Wasp already stored the last read time so for these drivers, this change just moves that storage to the state structure
analog, BBB_PRU, Bebop, LightWareI2C, PulsedLightLRF, TeraRangerI2C, VL53L0X did not store the last read time so this was added
2018-08-27 04:02:51 -03:00
|
|
|
uint32_t last_reading_ms(enum Rotation orientation) const;
|
2015-02-21 06:55:21 -04:00
|
|
|
|
2021-04-13 05:07:06 -03:00
|
|
|
// get temperature reading in C. returns true on success and populates temp argument
|
2021-06-04 13:32:44 -03:00
|
|
|
bool get_temp(enum Rotation orientation, float &temp) const;
|
2021-04-13 05:07:06 -03:00
|
|
|
|
2015-02-21 06:55:21 -04:00
|
|
|
/*
|
|
|
|
set an externally estimated terrain height. Used to enable power
|
|
|
|
saving (where available) at high altitudes.
|
|
|
|
*/
|
|
|
|
void set_estimated_terrain_height(float height) {
|
|
|
|
estimated_terrain_height = height;
|
|
|
|
}
|
2015-04-13 00:18:46 -03:00
|
|
|
|
2018-05-09 04:45:26 -03:00
|
|
|
static RangeFinder *get_singleton(void) { return _singleton; }
|
|
|
|
|
2018-07-04 11:22:17 -03:00
|
|
|
protected:
|
|
|
|
AP_RangeFinder_Params params[RANGEFINDER_MAX_INSTANCES];
|
2016-10-07 19:29:42 -03:00
|
|
|
|
2014-06-09 14:14:50 -03:00
|
|
|
private:
|
2018-05-09 04:45:26 -03:00
|
|
|
static RangeFinder *_singleton;
|
|
|
|
|
2014-06-09 14:14:50 -03:00
|
|
|
RangeFinder_State state[RANGEFINDER_MAX_INSTANCES];
|
|
|
|
AP_RangeFinder_Backend *drivers[RANGEFINDER_MAX_INSTANCES];
|
2019-02-03 21:30:05 -04:00
|
|
|
uint8_t num_instances;
|
2020-04-30 19:09:27 -03:00
|
|
|
HAL_Semaphore detect_sem;
|
2015-02-21 06:55:21 -04:00
|
|
|
float estimated_terrain_height;
|
2017-02-09 06:26:57 -04:00
|
|
|
Vector3f pos_offset_zero; // allows returning position offsets of zero for invalid requests
|
2014-06-09 14:14:50 -03:00
|
|
|
|
2018-02-23 08:11:47 -04:00
|
|
|
void detect_instance(uint8_t instance, uint8_t& serial_instance);
|
2015-04-13 00:18:46 -03:00
|
|
|
|
2021-06-04 18:36:24 -03:00
|
|
|
bool _add_backend(AP_RangeFinder_Backend *driver, uint8_t instance, uint8_t serial_instance=0);
|
2019-04-05 06:20:22 -03:00
|
|
|
|
|
|
|
uint32_t _log_rfnd_bit = -1;
|
2021-02-01 12:26:33 -04:00
|
|
|
void Log_RFND() const;
|
2019-04-05 06:20:22 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace AP {
|
|
|
|
RangeFinder *rangefinder();
|
2012-01-10 19:44:04 -04:00
|
|
|
};
|