The code for this section is located in multi_bot_02 part of an archive. Note that archive does not include some common files like maps and worlds, that are used by all projects and therefore are located outside of them. They are part of an archive, too. Also note that we use ROS2 Galactic now.
So we have a map amd a robot. We run navigate-to-waypoint... What is there is an object present in a simulation or in a real world, that is not on the map? Will navigation algorithm ignore it.
The short answer is "it will try to avoid it", the longer answer will include "but in a funny and ugly way".
To test this case, let's create a new set of waypoints that will move our robot in a "circle". We are going to use the waypoints_creator utility presented in earlier sections.
So a robot will go around (say, patrolling the territory). Now let's add an object to our map, but let's not rescan the area, so map doesn't have this object's representation:
This is a new world called maze_with_charger_and_obstacle.sdf, as you can see, it has a cube right on a robot's way.
The rest is going to be the same as earlier: we run our robot with --slam set to False, and...
Well, the robot definitely detects an obstacle. The navigation system moves the suggested path away from it, and the robot gets stuck (not every time!) in the non-drivable area. Beginner drivers do it a lot: they are trying to stay as far as possible from the opposite traffic, so they end up in the ditch.
This is definitely a nav. algorithm's problem (I tried two, see nav2_params.yaml) and they both have this flaw. I am almost sure it can be fixed by carefully setting the secure area around the robot, which is either its radius (footprint) or the extra inflation (how far should it stay from non-drivable areas).
But at least it tries.