Callbacks are not terminated after state transition in SMACH

asked 2022-01-31 09:36:40 -0600

AlexandrosNic gravatar image

updated 2022-01-31 09:37:56 -0600

After a lot of research, I did not find any proper way to stop callbacks from being called from a state that has already been transitioned.

For example imagine two states:

  • "GO_FORWARD": Tells the robot to go forward until the front LIDAR measures distance less than 2m from the front wall.
  • "STOP": The robot stops.

The "scan" callback in the GO_FORWARD state takes the values of the front LIDAR. However, even when the state machine transitions from GO_FORWARD to STOP, the scan callback is still active.

The only walk-around solution I found so far to this is to have a boolean flag in an if statement at the beginning of the callback, that turns False when the condition of the 2m is met.

Is there a way to properly terminate a state (and all its callbacks), when the state machine shifts to another state?

edit retag flag offensive close merge delete