0
$\begingroup$

I’m currently implementing my global planner using ROS2 and Nav2. I’ve written a planner plugin in Nav2 following the tutorial at https://navigation.ros.org/plugin_tutorials/docs/writing_new_nav2planner_plugin.html. I intend to use it with Turtlebot3. While everything is working correctly, my planner only works once the robot reaches the goal. I need to relaunch Gazebo and Rviz2 repeatedly. I’ve identified that my planner fails to reset certain variables, such as flags or memory variables. I’m struggling to check when the robot reaches the goal and reset these variables. Does anyone have any suggestions to assist me in achieving this?

$\endgroup$

1 Answer 1

0
$\begingroup$

I’m struggling to check when the robot reaches the goal and reset these variables.

Generally speaking, the planner should not be responsible for checking if the robot is at the goal or not. The main task a planner has, is to generate a path, which in this case is a list of poses (${x, y, \theta}$) values from the current state of the robot to the desired state. This list will then be handed over to a controller, who will perform certain computation to generate velocity commands to go from one pose to the other, until the list of poses are exhausted.

If you are following along the Nav2 tutorials, the very next one in the series is about writing your own Controller plugin. In case you do not want to write your own controller plugin, you can check what sort of controllers are already implemented.

I’ve identified that my planner fails to reset certain variables, such as flags or memory variables.

Have you tried overriding the cleanup() function? From a quick glance at the tutorial, the description "Method is called when planner server goes to on_cleanup state. Ideally this method should clean up resoures which are created for the planner", seems to fit the use-case you want.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.