mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 11:23:34 +08:00
distance_sensor: added distance_sensor to sdlog2
This commit is contained in:
+11
-10
@@ -61,8 +61,6 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <drivers/drv_range_finder.h>
|
|
||||||
|
|
||||||
#include <uORB/uORB.h>
|
#include <uORB/uORB.h>
|
||||||
#include <uORB/topics/vehicle_status.h>
|
#include <uORB/topics/vehicle_status.h>
|
||||||
#include <uORB/topics/sensor_combined.h>
|
#include <uORB/topics/sensor_combined.h>
|
||||||
@@ -92,6 +90,7 @@
|
|||||||
#include <uORB/topics/rc_channels.h>
|
#include <uORB/topics/rc_channels.h>
|
||||||
#include <uORB/topics/esc_status.h>
|
#include <uORB/topics/esc_status.h>
|
||||||
#include <uORB/topics/telemetry_status.h>
|
#include <uORB/topics/telemetry_status.h>
|
||||||
|
#include <uORB/topics/distance_sensor.h>
|
||||||
#include <uORB/topics/estimator_status.h>
|
#include <uORB/topics/estimator_status.h>
|
||||||
#include <uORB/topics/tecs_status.h>
|
#include <uORB/topics/tecs_status.h>
|
||||||
#include <uORB/topics/system_power.h>
|
#include <uORB/topics/system_power.h>
|
||||||
@@ -1084,7 +1083,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
struct vehicle_global_velocity_setpoint_s global_vel_sp;
|
struct vehicle_global_velocity_setpoint_s global_vel_sp;
|
||||||
struct battery_status_s battery;
|
struct battery_status_s battery;
|
||||||
struct telemetry_status_s telemetry;
|
struct telemetry_status_s telemetry;
|
||||||
struct range_finder_report range_finder;
|
struct distance_sensor_s distance_sensor;
|
||||||
struct estimator_status_report estimator_status;
|
struct estimator_status_report estimator_status;
|
||||||
struct tecs_status_s tecs_status;
|
struct tecs_status_s tecs_status;
|
||||||
struct system_power_s system_power;
|
struct system_power_s system_power;
|
||||||
@@ -1174,7 +1173,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
int global_vel_sp_sub;
|
int global_vel_sp_sub;
|
||||||
int battery_sub;
|
int battery_sub;
|
||||||
int telemetry_subs[TELEMETRY_STATUS_ORB_ID_NUM];
|
int telemetry_subs[TELEMETRY_STATUS_ORB_ID_NUM];
|
||||||
int range_finder_sub;
|
int distance_sensor_sub;
|
||||||
int estimator_status_sub;
|
int estimator_status_sub;
|
||||||
int tecs_status_sub;
|
int tecs_status_sub;
|
||||||
int system_power_sub;
|
int system_power_sub;
|
||||||
@@ -1208,7 +1207,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
subs.esc_sub = -1;
|
subs.esc_sub = -1;
|
||||||
subs.global_vel_sp_sub = -1;
|
subs.global_vel_sp_sub = -1;
|
||||||
subs.battery_sub = -1;
|
subs.battery_sub = -1;
|
||||||
subs.range_finder_sub = -1;
|
subs.distance_sensor_sub = -1;
|
||||||
subs.estimator_status_sub = -1;
|
subs.estimator_status_sub = -1;
|
||||||
subs.tecs_status_sub = -1;
|
subs.tecs_status_sub = -1;
|
||||||
subs.system_power_sub = -1;
|
subs.system_power_sub = -1;
|
||||||
@@ -1820,12 +1819,14 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- BOTTOM DISTANCE --- */
|
/* --- DISTANCE SENSOR --- */
|
||||||
if (copy_if_updated(ORB_ID(sensor_range_finder), &subs.range_finder_sub, &buf.range_finder)) {
|
if (copy_if_updated(ORB_ID(distance_sensor), &subs.distance_sensor_sub, &buf.distance_sensor)) {
|
||||||
log_msg.msg_type = LOG_DIST_MSG;
|
log_msg.msg_type = LOG_DIST_MSG;
|
||||||
log_msg.body.log_DIST.bottom = buf.range_finder.distance;
|
log_msg.body.log_DIST.id = buf.distance_sensor.id;
|
||||||
log_msg.body.log_DIST.bottom_rate = 0.0f;
|
log_msg.body.log_DIST.type = buf.distance_sensor.type;
|
||||||
log_msg.body.log_DIST.flags = (buf.range_finder.valid ? 1 : 0);
|
log_msg.body.log_DIST.orientation = buf.distance_sensor.orientation;
|
||||||
|
log_msg.body.log_DIST.current_distance = buf.distance_sensor.current_distance;
|
||||||
|
log_msg.body.log_DIST.covariance = buf.distance_sensor.covariance;
|
||||||
LOGBUFFER_WRITE_AND_COUNT(DIST);
|
LOGBUFFER_WRITE_AND_COUNT(DIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -295,12 +295,14 @@ struct log_BATT_s {
|
|||||||
float discharged;
|
float discharged;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* --- DIST - DISTANCE TO SURFACE --- */
|
/* --- DIST - RANGE SENSOR DISTANCE --- */
|
||||||
#define LOG_DIST_MSG 21
|
#define LOG_DIST_MSG 21
|
||||||
struct log_DIST_s {
|
struct log_DIST_s {
|
||||||
float bottom;
|
uint8_t id;
|
||||||
float bottom_rate;
|
uint8_t type;
|
||||||
uint8_t flags;
|
uint8_t orientation;
|
||||||
|
uint16_t current_distance;
|
||||||
|
uint8_t covariance;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* LOG IMU1 and IMU2 MSGs consume IDs 22 and 23 */
|
/* LOG IMU1 and IMU2 MSGs consume IDs 22 and 23 */
|
||||||
|
|||||||
Reference in New Issue
Block a user