I have a state machine in which I might have to restart something when needed (Say restart a hardware). But after restarting, I need to run some tests on the thing. If the tests fail, I need to stop the thing and exit the state machine with a failure status.
In case of failure, how should I handle the 2nd stopping of the thing? The state machine diagram loses its readability if I do it the following way. And the implementation becomes ugly since I need to decide Stop thing
state's output based on the previous state (SUCCESS
the first time and ERROR
if the state was reached after failing the tests)
My other option is to create a 2nd instance of the Stop thing
state as follows. But then it makes the state machine bigger
Which one of these is the correct approach? Or is there another way to approach these kind of problems?
If it matters here, I am using ROS
and smach
for the state machine implementation