skasperski / navigation_2d

ROS nodes to navigate a mobile robot in a planar environment
GNU General Public License v3.0
123 stars 65 forks source link

fix(corridor): the robot will spin in narrow corridor #42

Closed tyuownu closed 3 years ago

tyuownu commented 6 years ago

Hi skasperski, I found that when the robot in a narrow corridor, the robot will spin after a while. Just like the image shows: corridor The RIVZ shows: RVIZ

the robot will turn left when it through the corridor.

So I dig into the source code, and found that when in this situation, the robot is in recovery mode (because the corridor is narrow), the valueDistance and valueSafety are all equal to 1.0 (when the direction = -1/1 and direction = 0), and the final result is best_dir = -1 (turn left). But I think when in this situation, best_dir = 0 is more reasonable:

  1. best_dir = 0 means that the robot walks on the global plan
  2. The purpose of recovery mode is that there is a obstacle in front of the robot, but in this situation there none. Even there is a obstacle, the valueDistance will not equal to 1 (dir = 0).
  3. Even in other situation, the two methods make no difference

And the robot do a lot turn left operation, so I change the code, and after a lot tests found that it can deal with this situation. And it also helps the robot go through the narrow door. What do you think? Thanks

tyuownu commented 6 years ago

There are the world files, you can try it. If I forgot something, pls let me know. world.tar.gz

skasperski commented 6 years ago

The recovery-mode is a little different. It basically means that the robot ignores its goal for a while and just drives to where is space. EvaluateAction is used to calculate the "goodness" of every possible motion command in [-1 .. 1] and the one evaluated best is executed. Changing the order of evaluation (e.g starting at 0 ) shouldn't change anything in the result.

Looking at your narrow passage, I would suggest to decrease the robot_radius instead, so that the robot "knows" that it can fit through the passage. It always helps to visualize the Operator's Costmap to see what is happening. In your case the robot sees its path blocked, and in this situation turning in place is the only safe operation.

tyuownu commented 6 years ago

Yeah, I was do something with the narrow passage. Image that situation stage1 the robot run into a passage with not strictly in line. Than the robot will turn left( with best best_dir), then it turn in a straight line, see below: stage2 The robot still turn left in origin code(with dir=1, -1 or 0, best_dir = -1), but it's more reasonable to run straight forward(best_dir = 0), what do you think?

JinghuiChan commented 5 years ago

I also encountered this problem. What is your solution? @tyuownu @skasperski

skasperski commented 5 years ago

I would say that navigating through a corridor as narrow as this example is a little outside the scope of this package. You might need to use a more sophisticated motion planner.

That being said, if you feel your robot should be able to pass a certain passage but cannot do it, the parameters of the operator's costmap_2d should always be the starting point for fine tuning the system.