Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate state transitions where only one is expected #1

Open
ricmua opened this issue Feb 9, 2023 · 1 comment
Open

Duplicate state transitions where only one is expected #1

ricmua opened this issue Feb 9, 2023 · 1 comment

Comments

@ricmua
Copy link
Owner

ricmua commented Feb 9, 2023

During normal operation of the task, duplicate state transitions are being observed where only one is expected. The testing infrastructure ~is~~ was not set up to detect this.

An illustration of the repeated state from the console:

[INFO] [main-2]: process started with pid [NNNNNN]
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: start_block
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: State: intertrial
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: timeout
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: to_move_a
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: State: move_a
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: State: move_a
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: timeout
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: State: failure
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: timeout
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: end_trial
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: State: intertrial
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: State: intertrial
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: timeout
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: to_move_a
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: State: move_a
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: State: move_a
[node-1] [INFO] [NNNNNNNNNN.NNNNNNNNN] [machine.delay_out_center_task]: Event: timeout

Likely, this is actually an issue with the delay_out_center_task package. However, the testing infrastructure for this package is currently superior. The following code can be used to illustrate the issue:

from delay_out_center_task import Environment, Machine, Model
def timeout(self, *args, **kwargs):
    print('Timeout')
    self.cancel_timeout()
Model.timeout = timeout
environment = Environment()
model = Model(environment=environment)
machine = Machine(model=model)
model.trigger('start_block')
model.trigger('timeout')

Created the [ricmua/duplicate_state_transition_issue](https://github.com/ricmua/ros_delay_out_center_task/tree/ricmua/duplicate_state_transition_issue) branch to illustrate and deal with this issue.

@ricmua
Copy link
Owner Author

ricmua commented Feb 13, 2023

The issue is that automatic transitions are being triggered during the on_enter methods of the state machine model. Since the machine never actually enters the associated state, it is reported as the subsequent state. For example, the on_enter_trial_setup method triggers a transition to move_a (via self.to_move_a()), and so the trial_setup state is erroneously reported as move_a.

Two obvious options:

  • Leave the code as it is, and just account for the flawed reporting.
  • Replace automatic transitions with (nearly instantaneous) timeouts. Add the timeout transitions to the state machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant