Closed atinfinity closed 2 months ago
getPath
probably already completed, so there's no action to cancel when your cancel subscription is triggered. cancelTask
cancels on-going tasks, but getting a path is a sub-200ms (usually) task so it doesn't do anything. goToPose
is a long-running task the length of your navigation run so that would still be on-going in order to be cancelable.
I don't know what " In this case, cancelTask() does not work." could mean in that context since there is no task happening to cancel (unless you timed your cancel really well with a cancelable, long-duration planning action)
Thank you for your comment. In this case, I expected that the goToPose()
cancell.
The simple navigator assumes one action is called at a time and stores the future for that to use in cancellations / getting feedback. It looks like your application calls multiple actions, so you may need to handle your own futures / cancelations. The Simple Navigator is not meant to be a catch all for advanced applications, but a simple to use and understand baseline for students, prototypers, researchers, or creating proof of concepts.
I wouldn't be opposed to a PR that would maintain a dict of different running actions statuses that you could cancelTask(taskid='my_curr_task')
with the particular current running action you'd like to cancel, but that was explicitly a non-requirement for the simple navigator's original design. Most applications do not require calling multiple actions simultaneously from the python script.
If you're not interested in creating a generalized solution, you can most easily get around this by creating your own client / handling for getPath
yourself and leave the goToPose
to the navigator
object so that you don't call multiple actions using the navigator to override the navigation task's processing state (getPath
is also a trivial and short action, so that's easy enough). Let the navigator handle navigation and any other actions you call are handled by your script separately. If its just getPath
, that's probably easiest. If you plan to call even more things, I suggest working on a PR to manage multiple futures/states for actions to contribute back to the simple navigator (and then it'll be less-simple!)
Thank you for your advice. I understood. I'll consider it. So, I closed this issue.
Bug report
Required Info:
Steps to reproduce issue
I used https://github.com/atinfinity/megarover_samples_ros2.
And, I launched Gazebo and navigation2.
I launched the following node using BasicNavigator(https://docs.nav2.org/commander_api/index.html).
And, I run the following command.
I called
getPath()
to debug in timer callback. In this case,cancelTask()
does not work.Expected behavior
In the running of
goToPose()
,cancelTask()
works.Actual behavior
When I called
getPath()
in timer callback. In this case,cancelTask()
does not work.