Skip to content

Commit a08abf8

Browse files
author
dillon@dillon
committed
fix: if forceTransition, then consider it a legal transition and allow super to transition
1 parent 64a9a90 commit a08abf8

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

include/am_super/super_node_mediator.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ class SuperNodeMediator
281281
*/
282282
bool transitionIsValid(const StateTransition&);
283283

284+
/**
285+
* @returns true - if we are allowed to transition to this state regardless of the state we are currently in
286+
*/
287+
bool forceTransition(const SuperState& to_state);
288+
284289
private:
285290
/** name of supervisor node */
286291
const std::string SUPER_NODE_NAME;
@@ -295,7 +300,7 @@ class SuperNodeMediator
295300
/** @brief temporary hack to allow manifested nodes to not halt transitions.*/
296301
bool lifeCycleNotYetImplemented(string node_name);
297302

298-
bool forceTransition(StateTransition transition);
303+
299304
};
300305
}
301306

src/am_super/am_super.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,9 @@ class AMSuper : AMLifeCycle
606606
{
607607
ROS_INFO_STREAM(state_mediator_.stateToString(supervisor_.system_state) << " --> "
608608
<< state_mediator_.stateToString(state));
609-
610-
bool legal = state_mediator_.allowsTransition(supervisor_.system_state, state);
609+
bool legal = true;
610+
if(!node_mediator_.forceTransition(state))
611+
legal = state_mediator_.allowsTransition(supervisor_.system_state, state);
611612

612613
if (!legal)
613614
{

src/am_super/super_node_mediator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ SuperNodeMediator::TransitionInstructions SuperNodeMediator::transitionReady(Sup
170170

171171
//transition to new state if checks passed or forced
172172
bool checks_passed = check_results.first;
173-
if (checks_passed || forceTransition(transition))
173+
if (checks_passed || forceTransition(transition.to_state))
174174
{
175175
transition_instructions.ready_for_transition = true;
176176
transition_instructions.new_state = transition.to_state;
@@ -196,9 +196,9 @@ SuperNodeMediator::TransitionInstructions SuperNodeMediator::transitionReady(Sup
196196
}
197197

198198

199-
bool SuperNodeMediator::forceTransition(StateTransition transition)
199+
bool SuperNodeMediator::forceTransition(const SuperState& to_state)
200200
{
201-
return transition.to_state == SuperState::MANUAL || transition.to_state == SuperState::SHUTDOWN;
201+
return to_state == SuperState::MANUAL || to_state == SuperState::SHUTDOWN;
202202
}
203203

204204
bool SuperNodeMediator::lifeCycleNotYetImplemented(string node_name)

0 commit comments

Comments
 (0)