@@ -103,7 +103,7 @@ void AMLifeCycle::lifecycleCB(const brain_box_msgs::LifeCycleCommand::ConstPtr m
103103 configure ();
104104 break ;
105105 case LifeCycleCommand::CREATE:
106- ROS_WARN_STREAM (" illegal command " << life_cycle_mediator_.commandToString (LifeCycleCommand::CREATE));
106+ ROS_WARN_STREAM (" illegal command " << life_cycle_mediator_.commandToString (LifeCycleCommand::CREATE) << " [7YT8] " );
107107 break ;
108108 case LifeCycleCommand::DEACTIVATE:
109109 transition (" deactivate" , LifeCycleState::ACTIVE, LifeCycleState::DEACTIVATING, LifeCycleState::INACTIVE,
@@ -124,17 +124,17 @@ void AMLifeCycle::transition(std::string transition_name, LifeCycleState initial
124124{
125125 if (life_cycle_info_.state == initial_state)
126126 {
127- ROS_INFO_STREAM (transition_name << " , current state: " << life_cycle_mediator_.stateToString (life_cycle_info_.state ));
127+ ROS_INFO_STREAM (transition_name << " , current state: " << life_cycle_mediator_.stateToString (life_cycle_info_.state ) << " [ASWU] " );
128128 setState (transition_state);
129129 on_function ();
130130 }
131131 else if (life_cycle_info_.state == transition_state || life_cycle_info_.state == final_state)
132132 {
133- ROS_DEBUG_STREAM (" ignoring redundant " << transition_name);
133+ ROS_DEBUG_STREAM (" ignoring redundant " << transition_name << " [0393] " );
134134 }
135135 else
136136 {
137- ROS_WARN_STREAM (" received illegal " << transition_name << " in state " << life_cycle_mediator_.stateToString (life_cycle_info_.state ));
137+ ROS_WARN_STREAM (" received illegal " << transition_name << " in state " << life_cycle_mediator_.stateToString (life_cycle_info_.state ) << " [JGV5] " );
138138 }
139139}
140140
@@ -237,12 +237,12 @@ void AMLifeCycle::destroy()
237237{
238238 if (life_cycle_mediator_.illegalDestroy (life_cycle_info_))
239239 {
240- ROS_INFO_STREAM (" received illegal activate in state " << life_cycle_mediator_.stateToString (life_cycle_info_.state ));
240+ ROS_INFO_STREAM (" received illegal activate in state " << life_cycle_mediator_.stateToString (life_cycle_info_.state ) << " [45RT] " );
241241 }
242242 /* This condition is hit only if state equals FINALIZED. Checking SHUTTING_DOWN is redundant */
243243 else
244244 {
245- ROS_INFO_STREAM (" current state: " << life_cycle_mediator_.stateToString (life_cycle_info_.state ));
245+ ROS_INFO_STREAM (" current state: " << life_cycle_mediator_.stateToString (life_cycle_info_.state ) << " [RE45] " );
246246 onDestroy ();
247247 }
248248}
@@ -273,27 +273,50 @@ bool AMLifeCycle::withinConfigureTolerance()
273273 }
274274 return tolerated;
275275}
276+
276277void AMLifeCycle::error (std::string error_code, bool forced)
277278{
278- std::string error_code_message=" [" + error_code + " ] " ;
279- if (!forced && life_cycle_mediator_.redundantError (life_cycle_info_))
280- {
281- ROS_WARN_STREAM (" Error called again, but previously reported." << error_code_message);
282- }
283- else if (!forced && withinConfigureTolerance ())
279+ error (" [GSHY]" ,error_code,forced);
280+ }
281+
282+ void AMLifeCycle::error (std::string message, std::string error_code, bool forced)
283+ {
284+ std::string error_code_message = " Error[" + error_code + " ] " ;
285+ if (withinConfigureTolerance () && !forced)
284286 {
285- ROS_WARN_STREAM_THROTTLE (throttle_info_.warn_throttle_s ," Ignoring error" << error_code_message << " during configure tolerance of " << configure_tolerance_s << " seconds [GFRT]" );
287+ ROS_WARN_STREAM_THROTTLE (throttle_info_.warn_throttle_s ," Ignoring tolerant error for ( " << configure_tolerance_s << " s) ` " << message << " ` " << error_code_message << " [GFRT]" );
286288 }
287289 else
288290 {
289- std::string forced_prefix = forced?" Forced " :" " ;
290- ROS_ERROR_STREAM (forced_prefix << " Error" << error_code_message << " called while in: " << life_cycle_mediator_.stateToString (life_cycle_info_.state ) << " [R45Y]" );
291- setState (LifeCycleState::ERROR_PROCESSING);
292- setStatus (LifeCycleStatus::ERROR);
293- onError ();
291+ std::string forced_prefix = forced?" Terminal " :" " ;
292+ std::string repeat_prefix = " " ;
293+ // only change the state if
294+ if (!life_cycle_mediator_.redundantError (life_cycle_info_))
295+ {
296+ setState (LifeCycleState::ERROR_PROCESSING);
297+ setStatus (LifeCycleStatus::ERROR);
298+ onError ();
299+ }
300+ else
301+ {
302+ repeat_prefix = " Repeated " ;
303+ }
304+ std::string error_explanation=forced_prefix + repeat_prefix + error_code_message;
305+ ROS_ERROR_STREAM (message << " -> " << error_explanation << " [R45Y]" );
294306 }
295307}
296308
309+
310+ void AMLifeCycle::errorTerminal (std::string message, std::string error_code)
311+ {
312+ error (message,error_code,true );
313+ }
314+
315+ void AMLifeCycle::errorTolerant (std::string message, std::string error_code)
316+ {
317+ error (message,error_code,false );
318+ }
319+
297320void AMLifeCycle::onError ()
298321{
299322 logState ();
@@ -350,11 +373,15 @@ void AMLifeCycle::addStatistics(diagnostic_updater::DiagnosticStatusWrapper& dsw
350373 LifeCycleStatus status = stats_list_.process (throttle_info_.warn_throttle_s , throttle_info_.error_throttle_s );
351374 if (life_cycle_mediator_.statusError (status))
352375 {
353- error ( " PQAE" );
376+ errorTolerant ( " Stats reporting error " , " PQAE" );
354377 }
355378 else
356379 {
357- setStatus (status);
380+ // only report status if not already errored
381+ if (!life_cycle_mediator_.redundantError (life_cycle_info_))
382+ {
383+ setStatus (status);
384+ }
358385
359386 // configuring is a special case where tolerance for errors is allowed
360387 if (getState () == LifeCycleState::CONFIGURING)
@@ -478,9 +505,8 @@ bool AMLifeCycle::setStatus(const LifeCycleStatus status)
478505 // if we are in error and want to leave it
479506 if (life_cycle_info_.status == LifeCycleStatus::ERROR && status != LifeCycleStatus::ERROR)
480507 {
481- ROS_WARN_STREAM_THROTTLE (getThrottle (), " requested to change status from ERROR to " << life_cycle_mediator_.statusToString (status));
508+ ROS_WARN_STREAM_THROTTLE (getThrottle (), " requested to change status from ERROR to " << life_cycle_mediator_.statusToString (status) << " [DFRE] " );
482509 }
483-
484510 else if (life_cycle_mediator_.setStatus (status, life_cycle_info_))
485511 {
486512 sendNodeUpdate ();
0 commit comments