mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-07 01:11:36 +08:00
px4flow: removed flow report in driver, just use uORB topic
This commit is contained in:
@@ -46,37 +46,6 @@
|
|||||||
|
|
||||||
#define PX4FLOW_DEVICE_PATH "/dev/px4flow"
|
#define PX4FLOW_DEVICE_PATH "/dev/px4flow"
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup topics
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optical flow in NED body frame in SI units.
|
|
||||||
*
|
|
||||||
* @see http://en.wikipedia.org/wiki/International_System_of_Units
|
|
||||||
*
|
|
||||||
* @warning If possible the usage of the raw flow and performing rotation-compensation
|
|
||||||
* using the autopilot angular rate estimate is recommended.
|
|
||||||
*/
|
|
||||||
struct px4flow_report {
|
|
||||||
|
|
||||||
uint64_t timestamp; /**< in microseconds since system start */
|
|
||||||
|
|
||||||
int16_t flow_raw_x; /**< flow in pixels in X direction, not rotation-compensated */
|
|
||||||
int16_t flow_raw_y; /**< flow in pixels in Y direction, not rotation-compensated */
|
|
||||||
float flow_comp_x_m; /**< speed over ground in meters per second, rotation-compensated */
|
|
||||||
float flow_comp_y_m; /**< speed over ground in meters per second, rotation-compensated */
|
|
||||||
float ground_distance_m; /**< Altitude / distance to ground in meters */
|
|
||||||
uint8_t quality; /**< Quality of the measurement, 0: bad quality, 255: maximum quality */
|
|
||||||
uint8_t sensor_id; /**< id of the sensor emitting the flow value */
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ObjDev tag for px4flow data.
|
* ObjDev tag for px4flow data.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
#include <uORB/uORB.h>
|
#include <uORB/uORB.h>
|
||||||
#include <uORB/topics/subsystem_info.h>
|
#include <uORB/topics/subsystem_info.h>
|
||||||
//#include <uORB/topics/optical_flow.h>
|
#include <uORB/topics/optical_flow.h>
|
||||||
|
|
||||||
#include <board_config.h>
|
#include <board_config.h>
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
/* PX4FLOW Registers addresses */
|
/* PX4FLOW Registers addresses */
|
||||||
#define PX4FLOW_REG 0x00 /* Measure Register */
|
#define PX4FLOW_REG 0x00 /* Measure Register */
|
||||||
|
|
||||||
#define PX4FLOW_CONVERSION_INTERVAL 8000 /* 8ms 125Hz
|
#define PX4FLOW_CONVERSION_INTERVAL 8000 /* 8ms 125Hz */
|
||||||
|
|
||||||
/* oddly, ERROR is not defined for c++ */
|
/* oddly, ERROR is not defined for c++ */
|
||||||
#ifdef ERROR
|
#ifdef ERROR
|
||||||
@@ -226,13 +226,13 @@ PX4FLOW::init()
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* allocate basic report buffers */
|
/* allocate basic report buffers */
|
||||||
_reports = new RingBuffer(2, sizeof(px4flow_report));
|
_reports = new RingBuffer(2, sizeof(struct optical_flow_s));
|
||||||
|
|
||||||
if (_reports == nullptr)
|
if (_reports == nullptr)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* get a publish handle on the px4flow topic */
|
/* get a publish handle on the px4flow topic */
|
||||||
struct px4flow_report zero_report;
|
struct optical_flow_s zero_report;
|
||||||
memset(&zero_report, 0, sizeof(zero_report));
|
memset(&zero_report, 0, sizeof(zero_report));
|
||||||
_px4flow_topic = orb_advertise(ORB_ID(optical_flow), &zero_report);
|
_px4flow_topic = orb_advertise(ORB_ID(optical_flow), &zero_report);
|
||||||
|
|
||||||
@@ -350,8 +350,8 @@ PX4FLOW::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
ssize_t
|
ssize_t
|
||||||
PX4FLOW::read(struct file *filp, char *buffer, size_t buflen)
|
PX4FLOW::read(struct file *filp, char *buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
unsigned count = buflen / sizeof(struct px4flow_report);
|
unsigned count = buflen / sizeof(struct optical_flow_s);
|
||||||
struct px4flow_report *rbuf = reinterpret_cast<struct px4flow_report *>(buffer);
|
struct optical_flow_s *rbuf = reinterpret_cast<struct optical_flow_s *>(buffer);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* buffer must be large enough */
|
/* buffer must be large enough */
|
||||||
@@ -466,7 +466,7 @@ PX4FLOW::collect()
|
|||||||
int16_t flowcy = val[9] << 8 | val[8];
|
int16_t flowcy = val[9] << 8 | val[8];
|
||||||
int16_t gdist = val[21] << 8 | val[20];
|
int16_t gdist = val[21] << 8 | val[20];
|
||||||
|
|
||||||
struct px4flow_report report;
|
struct optical_flow_s report;
|
||||||
report.flow_comp_x_m = float(flowcx)/1000.0f;
|
report.flow_comp_x_m = float(flowcx)/1000.0f;
|
||||||
report.flow_comp_y_m = float(flowcy)/1000.0f;
|
report.flow_comp_y_m = float(flowcy)/1000.0f;
|
||||||
report.flow_raw_x= val[3] << 8 | val[2];
|
report.flow_raw_x= val[3] << 8 | val[2];
|
||||||
@@ -678,7 +678,7 @@ void stop()
|
|||||||
void
|
void
|
||||||
test()
|
test()
|
||||||
{
|
{
|
||||||
struct px4flow_report report;
|
struct optical_flow_s report;
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|||||||
@@ -1396,7 +1396,7 @@ Mavlink::task_main(int argc, char *argv[])
|
|||||||
configure_stream("POSITION_TARGET_GLOBAL_INT", 3.0f);
|
configure_stream("POSITION_TARGET_GLOBAL_INT", 3.0f);
|
||||||
configure_stream("ATTITUDE_TARGET", 3.0f);
|
configure_stream("ATTITUDE_TARGET", 3.0f);
|
||||||
configure_stream("DISTANCE_SENSOR", 0.5f);
|
configure_stream("DISTANCE_SENSOR", 0.5f);
|
||||||
configure_stream("OPTICAL_FLOW", 0.5f);
|
configure_stream("OPTICAL_FLOW", 20.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MAVLINK_MODE_ONBOARD:
|
case MAVLINK_MODE_ONBOARD:
|
||||||
|
|||||||
Reference in New Issue
Block a user