Open WZHwerk5 opened 6 months ago
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?
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
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()
Hey @WZHwerk5, how is this going?
Hi, it worked, thanks.
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?
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()
Could you give an example of where to insert sm.cancel_state()
for an
event to trigger the state cancellation while in that state please? I'm not
too sure where to put it inside the ActionState
On Thu, Oct 10, 2024, 22:54 Miguel Ángel González Santamarta < @.***> wrote:
Hi @jonyktan https://github.com/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 https://github.com/uleroboticsgroup/yasmin/blob/main/yasmin_demo/yasmin_demo/action_client_demo.py. Thus, to cancel the FSM sm, you can use the following code:
sm.cancel_state()
— Reply to this email directly, view it on GitHub https://github.com/uleroboticsgroup/yasmin/issues/18#issuecomment-2405351455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJYCWNNXRYHFEJI36HBQUOLZ22IJ3AVCNFSM6AAAAABHV5ZGW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBVGM2TCNBVGU . You are receiving this because you were mentioned.Message ID: @.***>
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.
Hi, I just wonder how to pause/resume an action state with a ROS2 service. Thanks!