mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-06 16:20:35 +08:00
commander: internalize system status bools
Most condition bools in the commander are not used anywhere but in the commander. It therefore makes sense to move them to a different internal struct and remove them from the vehicle_status message. Also, the land_detected should be used by all the modules instead of getting it through the commander and system_status.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012-2016 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -40,6 +40,7 @@
|
||||
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||
* @author Anton Babushkin <anton.babushkin@me.com>
|
||||
* @author Ban Siesta <bansiesta@gmail.com>
|
||||
* @author Julian Oes <julian@oes.ch>
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
@@ -112,6 +113,7 @@
|
||||
#include <uORB/topics/ekf2_innovations.h>
|
||||
#include <uORB/topics/camera_trigger.h>
|
||||
#include <uORB/topics/ekf2_replay.h>
|
||||
#include <uORB/topics/vehicle_land_detected.h>
|
||||
|
||||
#include <systemlib/systemlib.h>
|
||||
#include <systemlib/param/param.h>
|
||||
@@ -1156,6 +1158,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
struct ekf2_innovations_s innovations;
|
||||
struct camera_trigger_s camera_trigger;
|
||||
struct ekf2_replay_s replay;
|
||||
struct vehicle_land_detected_s land_detected;
|
||||
} buf;
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
@@ -1213,6 +1216,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
struct log_EST6_s log_INO3;
|
||||
struct log_RPL3_s log_RPL3;
|
||||
struct log_RPL4_s log_RPL4;
|
||||
struct log_LAND_s log_LAND;
|
||||
} body;
|
||||
} log_msg = {
|
||||
LOG_PACKET_HEADER_INIT(0)
|
||||
@@ -1260,6 +1264,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
int innov_sub;
|
||||
int cam_trig_sub;
|
||||
int replay_sub;
|
||||
int land_detected_sub;
|
||||
} subs;
|
||||
|
||||
subs.cmd_sub = -1;
|
||||
@@ -1299,6 +1304,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
subs.innov_sub = -1;
|
||||
subs.cam_trig_sub = -1;
|
||||
subs.replay_sub = -1;
|
||||
subs.land_detected_sub = -1;
|
||||
|
||||
/* add new topics HERE */
|
||||
|
||||
@@ -1447,7 +1453,6 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
log_msg.body.log_STAT.main_state = buf_status.main_state;
|
||||
log_msg.body.log_STAT.arming_state = buf_status.arming_state;
|
||||
log_msg.body.log_STAT.failsafe = (uint8_t) buf_status.failsafe;
|
||||
log_msg.body.log_STAT.landed = (uint8_t) buf_status.condition_landed;
|
||||
log_msg.body.log_STAT.load = buf_status.load;
|
||||
LOGBUFFER_WRITE_AND_COUNT(STAT);
|
||||
}
|
||||
@@ -2135,6 +2140,13 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
LOGBUFFER_WRITE_AND_COUNT(CAMT);
|
||||
}
|
||||
|
||||
/* --- LAND DETECTED --- */
|
||||
if (copy_if_updated(ORB_ID(vehicle_land_detected), &subs.land_detected_sub, &buf.land_detected)) {
|
||||
log_msg.msg_type = LOG_LAND_MSG;
|
||||
log_msg.body.log_LAND.landed = buf.land_detected.landed;
|
||||
LOGBUFFER_WRITE_AND_COUNT(CTS);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&logbuffer_mutex);
|
||||
|
||||
/* signal the other thread new data, but not yet unlock */
|
||||
|
||||
@@ -180,7 +180,6 @@ struct log_STAT_s {
|
||||
uint8_t main_state;
|
||||
uint8_t arming_state;
|
||||
uint8_t failsafe;
|
||||
uint8_t landed;
|
||||
float load;
|
||||
};
|
||||
|
||||
@@ -582,6 +581,11 @@ struct log_CAMT_s {
|
||||
uint32_t seq;
|
||||
};
|
||||
|
||||
#define LOG_LAND_MSG 56
|
||||
struct log_LAND_s {
|
||||
uint8_t landed;
|
||||
};
|
||||
|
||||
/********** SYSTEM MESSAGES, ID > 0x80 **********/
|
||||
|
||||
/* --- TIME - TIME STAMP --- */
|
||||
@@ -623,7 +627,7 @@ static const struct log_format_s log_formats[] = {
|
||||
LOG_FORMAT(GPS, "QBffLLfffffBHHH", "GPSTime,Fix,EPH,EPV,Lat,Lon,Alt,VelN,VelE,VelD,Cog,nSat,SNR,N,J"),
|
||||
LOG_FORMAT_S(ATTC, ATTC, "ffff", "Roll,Pitch,Yaw,Thrust"),
|
||||
LOG_FORMAT_S(ATC1, ATTC, "ffff", "Roll,Pitch,Yaw,Thrust"),
|
||||
LOG_FORMAT(STAT, "BBBBf", "MainState,ArmS,Failsafe,Landed,Load"),
|
||||
LOG_FORMAT(STAT, "BBBf", "MainState,ArmS,Failsafe,Load"),
|
||||
LOG_FORMAT(VTOL, "fBBB", "Arsp,RwMode,TransMode,Failsafe"),
|
||||
LOG_FORMAT(CTS, "fffffff", "Vx_b,Vy_b,Vz_b,Vinf,P,Q,R"),
|
||||
LOG_FORMAT(RC, "ffffffffffffBBBL", "C0,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,RSSI,CNT,Lost,Drop"),
|
||||
@@ -666,6 +670,7 @@ static const struct log_format_s log_formats[] = {
|
||||
LOG_FORMAT(RPL2, "QQLLiMMfffffffM", "Tpos,Tvel,lat,lon,alt,fix,nsats,eph,epv,sacc,v,vN,vE,vD,v_val"),
|
||||
LOG_FORMAT(RPL3, "QffffIB", "Tflow,fx,fy,gx,gy,delT,qual"),
|
||||
LOG_FORMAT(RPL4, "Qf", "Trng,rng"),
|
||||
LOG_FORMAT(LAND, "B", "Landed"),
|
||||
/* system-level messages, ID >= 0x80 */
|
||||
/* FMT: don't write format of format message, it's useless */
|
||||
LOG_FORMAT(TIME, "Q", "StartTime"),
|
||||
|
||||
Reference in New Issue
Block a user