ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How can I restart move_base server?

asked 2021-12-29 07:32:11 -0500

Laura gravatar image

Sometimes I will encounter such a problem: due to the positioning error of AMCL, during the execution of the target sent to move_base, the robot will be considered to collide with an obstacle or get stuck in the wall. At this time, the target is Aborted, but move_base will not respond to subsequent targets. I have tried requesting clearmap and using AMCL's request_nomotion_update, but the effect is not very immediate. But I found that starting a move_base node with the same name through the launch file to force the previous move_base to close, so as to restart move_base, can effectively solve this problem, and can go to the next target point normally. So I want to know if it is possible to restart the move_base server or node in C++ (some kind of API?) to achieve the same effect, instead of forcing the old node out by using the node with the same name.

edit retag flag offensive close merge delete

Comments

Hi @Laura:

Have you considered using resetState. Below the code, perhaps you can create a method to do something not as drastic as well.

  void MoveBase::resetState(){
    state_ = PLANNING;
    recovery_index_ = 0;
    recovery_trigger_ = PLANNING_R;
    publishZeroVelocity();

    //if we shutdown our costmaps when we're deactivated... we'll do that now
    if(shutdown_costmaps_){
      ROS_DEBUG_NAMED("move_base","Stopping costmaps");
      planner_costmap_ros_->stop();
      controller_costmap_ros_->stop();
    }
  }

https://github.com/strawlab/navigatio...

osilva gravatar image osilva  ( 2021-12-30 08:11:25 -0500 )edit

@osilva,Thank you very much for your solution. ROS is a very large system for beginners like me. I also need to learn more about the source code and interfaces. Thank you again for your patient answers all the time!

Laura gravatar image Laura  ( 2021-12-31 03:28:06 -0500 )edit

Hey @Laura I learned every day in this forum that’s what I like the most. Thank you for asking too

osilva gravatar image osilva  ( 2021-12-31 05:12:06 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2022-01-02 08:38:19 -0500

osilva gravatar image

Hi @Laura, adding this as an answer for future use.

Consider resetState() method. Below the code on how it works.

  void MoveBase::resetState(){
    state_ = PLANNING;
    recovery_index_ = 0;
    recovery_trigger_ = PLANNING_R;
    publishZeroVelocity();

    //if we shutdown our costmaps when we're deactivated... we'll do that now
    if(shutdown_costmaps_){
      ROS_DEBUG_NAMED("move_base","Stopping costmaps");
      planner_costmap_ros_->stop();
      controller_costmap_ros_->stop();
    }
  }

https://github.com/strawlab/navigatio...

edit flag offensive delete link more

Comments

@osilva Thank you very much! I recently modified the source code of move_base so that this function will be called automatically under preset error conditions.

Laura gravatar image Laura  ( 2022-01-02 10:22:08 -0500 )edit

Great 👍🏼

osilva gravatar image osilva  ( 2022-01-02 11:24:57 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-12-29 07:32:11 -0500

Seen: 90 times

Last updated: Jan 02 '22