commander: take main_state out of vehicle_status

This state is only commander internal. Therefore it doesn't need to be
in vehicle_status. Instead it is now in the commander_state message.
This commit is contained in:
Julian Oes
2016-04-11 18:01:48 +02:00
parent 1ad0ee0fae
commit 5ca5af5fcd
9 changed files with 214 additions and 164 deletions
+14 -3
View File
@@ -114,6 +114,7 @@
#include <uORB/topics/camera_trigger.h>
#include <uORB/topics/ekf2_replay.h>
#include <uORB/topics/vehicle_land_detected.h>
#include <uORB/topics/commander_state.h>
#include <systemlib/systemlib.h>
#include <systemlib/param/param.h>
@@ -1159,6 +1160,7 @@ int sdlog2_thread_main(int argc, char *argv[])
struct camera_trigger_s camera_trigger;
struct ekf2_replay_s replay;
struct vehicle_land_detected_s land_detected;
struct commander_state_s commander_state;
} buf;
memset(&buf, 0, sizeof(buf));
@@ -1265,6 +1267,7 @@ int sdlog2_thread_main(int argc, char *argv[])
int cam_trig_sub;
int replay_sub;
int land_detected_sub;
int commander_state_sub;
} subs;
subs.cmd_sub = -1;
@@ -1305,6 +1308,7 @@ int sdlog2_thread_main(int argc, char *argv[])
subs.cam_trig_sub = -1;
subs.replay_sub = -1;
subs.land_detected_sub = -1;
subs.commander_state_sub = -1;
/* add new topics HERE */
@@ -1424,6 +1428,10 @@ int sdlog2_thread_main(int argc, char *argv[])
/* --- VEHICLE STATUS - LOG MANAGEMENT --- */
bool status_updated = copy_if_updated(ORB_ID(vehicle_status), &subs.status_sub, &buf_status);
/* --- VEHICLE STATUS - LOG MANAGEMENT --- */
bool commander_state_updated = copy_if_updated(ORB_ID(commander_state), &subs.commander_state_sub,
&buf.commander_state);
if (status_updated) {
if (log_when_armed) {
handle_status(&buf_status);
@@ -1447,10 +1455,13 @@ int sdlog2_thread_main(int argc, char *argv[])
log_msg.body.log_TIME.t = hrt_absolute_time();
LOGBUFFER_WRITE_AND_COUNT(TIME);
/* --- VEHICLE STATUS --- */
if (status_updated) {
/* --- VEHICLE STATUS / COMMANDER DEBUGGING --- */
if (status_updated || commander_state_updated) {
log_msg.msg_type = LOG_STAT_MSG;
log_msg.body.log_STAT.main_state = buf_status.main_state;
// TODO: This field should get DEPRECATED in favor of nav_state. main_state is only for
// commander debugging.
log_msg.body.log_STAT.main_state = buf.commander_state.main_state;
log_msg.body.log_STAT.nav_state = buf_status.nav_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.load = buf_status.load;
+3 -2
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2013-2015 PX4 Development Team. All rights reserved.
* Copyright (c) 2013-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
@@ -178,6 +178,7 @@ struct log_ATTC_s {
#define LOG_STAT_MSG 10
struct log_STAT_s {
uint8_t main_state;
uint8_t nav_state;
uint8_t arming_state;
uint8_t failsafe;
float load;
@@ -627,7 +628,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, "BBBf", "MainState,ArmS,Failsafe,Load"),
LOG_FORMAT(STAT, "BBBBf", "MainState,NavState,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"),