Skip to content

Commit 8851676

Browse files
author
Aaron Roller
authored
Merge pull request #154 from AutoModality/AM-777/station_topic
feat: added system state replacing vxstate summary AM-777/station_topic
2 parents b6cb560 + a76f768 commit 8851676

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

include/super_lib/am_super_topics.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class am_super_topics
1919
static constexpr char SUPER_STATE[] = "/vstate/summary";
2020

2121
static constexpr char LIFECYCLE_STATE[] = "/node_state";
22+
23+
static constexpr char SUPER_STATUS[] = "/super/status";
24+
25+
static constexpr char NODE_LIFECYCLE[] = "/node_lifecycle";
26+
2227
};
2328

2429
}

src/am_super/am_super.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <brain_box_msgs/StampedAltimeter.h>
2121
#include <brain_box_msgs/Super2Status.h>
2222
#include <brain_box_msgs/VxState.h>
23+
#include <brain_box_msgs/SystemState.h>
2324
#include <brain_box_msgs/ControllerState.h>
2425

2526
#include <am_super/controller_state.h>
@@ -64,6 +65,7 @@ class AMSuper : AMLifeCycle
6465
*/
6566
ros::Publisher lifecycle_pub_;
6667
ros::Publisher vstate_summary_pub_;
68+
ros::Publisher system_state_pub_;
6769
ros::Publisher super_status_pub_;
6870
ros::Publisher led_pub_;
6971
ros::Subscriber node_state_sub_;
@@ -182,19 +184,20 @@ class AMSuper : AMLifeCycle
182184
/**
183185
* system status pub
184186
*/
185-
vstate_summary_pub_ = nh_.advertise<brain_box_msgs::VxState>("/vstate/summary", 1000);
186-
/**
187+
vstate_summary_pub_ = nh_.advertise<brain_box_msgs::VxState>(am_super_topics::SUPER_STATE, 1000);
188+
system_state_pub_ = nh_.advertise<brain_box_msgs::SystemState>(am_topics::SYSTEM_STATE, 1000);
189+
/**Super
187190
* node lifecycle state pub. used to tell nodes to change their lifecycle state.
188191
*/
189-
lifecycle_pub_ = nh_.advertise<brain_box_msgs::LifeCycleCommand>("/node_lifecycle", 100);
192+
lifecycle_pub_ = nh_.advertise<brain_box_msgs::LifeCycleCommand>(am_super_topics::NODE_LIFECYCLE, 100);
190193
/**
191194
* led control pub
192195
*/
193196
led_pub_ = nh_.advertise<brain_box_msgs::BlinkMCommand>(am::am_topics::LED_BLINK, 1000);
194197
/**
195198
* super status contains online naode list for gcs_comms
196199
*/
197-
super_status_pub_ = nh_.advertise<brain_box_msgs::Super2Status>("/super/status", 1000);
200+
super_status_pub_ = nh_.advertise<brain_box_msgs::Super2Status>(am_super_topics::SUPER_STATUS, 1000);
198201

199202
supervisor_.system_state = SuperState::BOOTING;
200203
supervisor_.flt_ctrl_state = SuperNodeMediator::SuperFltCtrlState::INIT;
@@ -214,7 +217,7 @@ class AMSuper : AMLifeCycle
214217
/**
215218
* node status via LifeCycle
216219
*/
217-
node_state_sub_ = nh_.subscribe("/node_state", 100, &AMSuper::nodeStateCB, this);
220+
node_state_sub_ = nh_.subscribe(am_super_topics::LIFECYCLE_STATE, 100, &AMSuper::nodeStateCB, this);
218221

219222
/**
220223
* commands from operator
@@ -260,7 +263,7 @@ class AMSuper : AMLifeCycle
260263
rmsg->value, rmsg->process_id, event.getReceiptTime());
261264

262265
// TODO: topic name should come from vb_util_lib::topics.h
263-
LOG_MSG("/node_state", rmsg, SU_LOG_LEVEL);
266+
LOG_MSG(am_super_topics::LIFECYCLE_STATE, rmsg, SU_LOG_LEVEL);
264267
}
265268

266269
void controllerStateCB(const ros::MessageEvent<brain_box_msgs::ControllerState const>& event)
@@ -400,9 +403,21 @@ class AMSuper : AMLifeCycle
400403
#if CUDA_FLAG
401404
gpu_info_->display();
402405
#endif
403-
brain_box_msgs::VxState state_msg;
404-
state_msg.state = (uint8_t)supervisor_.system_state;
405-
vstate_summary_pub_.publish(state_msg);
406+
407+
//publish deprecated topic
408+
{
409+
brain_box_msgs::VxState state_msg;
410+
state_msg.state = (uint8_t)supervisor_.system_state;
411+
vstate_summary_pub_.publish(state_msg);
412+
}
413+
414+
//publish the system state
415+
{
416+
brain_box_msgs::SystemState system_state_msg;
417+
system_state_msg.state = (uint8_t)supervisor_.system_state;
418+
system_state_msg.state_string = state_mediator_.stateToString(supervisor_.system_state);
419+
system_state_pub_.publish(system_state_msg);
420+
}
406421

407422
// cycle thru all the nodes in the list to look for a timeout
408423
ros::Time now = ros::Time().now();

0 commit comments

Comments
 (0)