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

Pause and resume an action state #18

Open
WZHwerk5 opened this issue May 14, 2024 · 9 comments
Open

Pause and resume an action state #18

WZHwerk5 opened this issue May 14, 2024 · 9 comments

Comments

@WZHwerk5
Copy link

Hi, I just wonder how to pause/resume an action state with a ROS2 service. Thanks!

@mgonzs13
Copy link
Collaborator

Hey @WZHwerk5, the action state involves using ROS 2 actions which, as far as I know, cannot be paused/resumed. However, pausing/resuming a state could be a good feature. Do you have any suggestions?

@WZHwerk5
Copy link
Author

Ok I see, thanks for quick reply! Let's step back a bit, how to cancel a running action state by a service (e.g. a Trigger)? Could you give me an example? Thanks in advance

@mgonzs13
Copy link
Collaborator

In YASMIN, all states can be implemented to be canceled. In the case of the action states, canceling a state means canceling the action server. An example of action state is shown here. Thus, to cancel the FSM sm, you can use the following code:

sm.cancel_state()

@mgonzs13
Copy link
Collaborator

mgonzs13 commented Jun 3, 2024

Hey @WZHwerk5, how is this going?

@WZHwerk5
Copy link
Author

WZHwerk5 commented Jun 3, 2024

Hi, it worked, thanks.

@mgonzs13 mgonzs13 closed this as completed Jun 3, 2024
@jonyktan
Copy link

Hi, can I get some advice on how to cancel actions please? Given that the ActionState outcomes are (SUCCEED, ABORT, CANCEL), how can I trigger ABORT or CANCEL?

@mgonzs13
Copy link
Collaborator

Hi @jonyktan, you have how to cancel an action in the previous comments.

In YASMIN, all states can be implemented to be canceled. In the case of the action states, canceling a state means canceling the action server. An example of action state is shown here. Thus, to cancel the FSM sm, you can use the following code:

sm.cancel_state()

@mgonzs13 mgonzs13 reopened this Oct 10, 2024
@jonyktan
Copy link

jonyktan commented Oct 10, 2024 via email

@mgonzs13
Copy link
Collaborator

Let us consider the action_client_demo.py. In this example, a FSM is created with an ActionState. Then, the FSM is executed inside the main thread of the program.

To overview an example of canceling a FSM we can execute the FSM of the demo in a new thread as follows:

    import threading
    t = threading.Thread(target=sm, args=(blackboard,))
    t.start()
    t.join()

This way, we can attempt to cancel the FSM while executing. Here you have the code modified canceling the FSM, for instance after 2 seconds of starting the execution:

    import time
    import threading
    t = threading.Thread(target=sm, args=(blackboard,))
    t.start()
    time.sleep(2)
    sm.cancel_state()
    t.join()

I hope this is helpful to you. I'll add an example to the demo pkg.

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

3 participants