mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
drivers/distance_sensor replace std::vector usage with px4::Array
This commit is contained in:
committed by
Lorenz Meier
parent
edeb59a8c3
commit
7008558fac
@@ -31,16 +31,16 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
add_subdirectory(cm8jl65)
|
||||
#add_subdirectory(hc_sr04) # not currently supported
|
||||
add_subdirectory(leddar_one)
|
||||
add_subdirectory(ll40ls)
|
||||
add_subdirectory(mb12xx)
|
||||
add_subdirectory(pga460)
|
||||
add_subdirectory(sf0x)
|
||||
add_subdirectory(sf1xx)
|
||||
add_subdirectory(srf02)
|
||||
add_subdirectory(teraranger)
|
||||
add_subdirectory(tfmini)
|
||||
add_subdirectory(ulanding)
|
||||
add_subdirectory(leddar_one)
|
||||
add_subdirectory(vl53lxx)
|
||||
add_subdirectory(pga460)
|
||||
add_subdirectory(cm8jl65)
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <px4_workqueue.h>
|
||||
#include <drivers/device/device.h>
|
||||
#include <px4_defines.h>
|
||||
#include <containers/Array.hpp>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
@@ -54,7 +55,6 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#include <perf/perf_counter.h>
|
||||
#include <systemlib/err.h>
|
||||
@@ -86,7 +86,7 @@
|
||||
class HC_SR04 : public cdev::CDev
|
||||
{
|
||||
public:
|
||||
HC_SR04(unsigned sonars = 6);
|
||||
HC_SR04();
|
||||
virtual ~HC_SR04();
|
||||
|
||||
virtual int init();
|
||||
@@ -123,9 +123,9 @@ private:
|
||||
int _cycling_rate; /* */
|
||||
uint8_t _index_counter; /* temporary sonar i2c address */
|
||||
|
||||
std::vector<float>
|
||||
px4::Array<float, 6>
|
||||
_latest_sonar_measurements; /* vector to store latest sonar measurements in before writing to report */
|
||||
unsigned _sonars;
|
||||
unsigned _sonars{6};
|
||||
struct GPIOConfig {
|
||||
uint32_t trig_port;
|
||||
uint32_t echo_port;
|
||||
@@ -200,7 +200,7 @@ const HC_SR04::GPIOConfig HC_SR04::_gpio_tab[] = {
|
||||
extern "C" __EXPORT int hc_sr04_main(int argc, char *argv[]);
|
||||
static int sonar_isr(int irq, void *context);
|
||||
|
||||
HC_SR04::HC_SR04(unsigned sonars) :
|
||||
HC_SR04::HC_SR04() :
|
||||
CDev(SR04_DEVICE_PATH, 0),
|
||||
_min_distance(SR04_MIN_DISTANCE),
|
||||
_max_distance(SR04_MAX_DISTANCE),
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <px4_config.h>
|
||||
#include <px4_getopt.h>
|
||||
#include <px4_workqueue.h>
|
||||
#include <containers/Array.hpp>
|
||||
|
||||
#include <drivers/device/i2c.h>
|
||||
|
||||
@@ -56,7 +57,6 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#include <perf/perf_counter.h>
|
||||
|
||||
@@ -131,10 +131,7 @@ private:
|
||||
uint8_t _cycle_counter; /* counter in cycle to change i2c adresses */
|
||||
int _cycling_rate; /* */
|
||||
uint8_t _index_counter; /* temporary sonar i2c address */
|
||||
std::vector<uint8_t> addr_ind; /* temp sonar i2c address vector */
|
||||
std::vector<float>
|
||||
_latest_sonar_measurements; /* vector to store latest sonar measurements in before writing to report */
|
||||
|
||||
px4::Array<uint8_t, MB12XX_MAX_RANGEFINDERS> addr_ind; /* temp sonar i2c address vector */
|
||||
|
||||
/**
|
||||
* Test whether the device supported by the driver is present at a
|
||||
@@ -277,7 +274,6 @@ MB12XX::init()
|
||||
if (ret2 == 0) { /* sonar is present -> store address_index in array */
|
||||
addr_ind.push_back(_index_counter);
|
||||
PX4_DEBUG("sonar added");
|
||||
_latest_sonar_measurements.push_back(200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#include <perf/perf_counter.h>
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <px4_defines.h>
|
||||
#include <px4_getopt.h>
|
||||
#include <px4_workqueue.h>
|
||||
#include <containers/Array.hpp>
|
||||
|
||||
#include <drivers/device/i2c.h>
|
||||
|
||||
@@ -55,7 +56,6 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#include <perf/perf_counter.h>
|
||||
|
||||
@@ -131,10 +131,7 @@ private:
|
||||
uint8_t _cycle_counter; /* counter in cycle to change i2c adresses */
|
||||
int _cycling_rate; /* */
|
||||
uint8_t _index_counter; /* temporary sonar i2c address */
|
||||
std::vector<uint8_t> addr_ind; /* temp sonar i2c address vector */
|
||||
std::vector<float>
|
||||
_latest_sonar_measurements; /* vector to store latest sonar measurements in before writing to report */
|
||||
|
||||
px4::Array<uint8_t, MB12XX_MAX_RANGEFINDERS> addr_ind; /* temp sonar i2c address vector */
|
||||
|
||||
/**
|
||||
* Test whether the device supported by the driver is present at a
|
||||
@@ -277,7 +274,6 @@ SRF02::init()
|
||||
if (ret2 == 0) { /* sonar is present -> store address_index in array */
|
||||
addr_ind.push_back(_index_counter);
|
||||
PX4_DEBUG("sonar added");
|
||||
_latest_sonar_measurements.push_back(200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <drivers/device/ringbuffer.h>
|
||||
|
||||
Reference in New Issue
Block a user