Skip to content

navigation

Gguidini edited this page May 13, 2021 · 3 revisions

The Navigation system provides means for robots to move autonomously in the map. There are actually 3 parts to this system:

  • GotoDESProcessor - A DES system that proceses movement commands
  • PathProcessor - An esper system that moves entities through their paths
  • Navigation function - finds routes in the map from source to destination

Goto

The Goto processor is a reactive DES processor. It exports 2 events: GotoPos and GotoPoi. The first one works with coordinates, indicating what position on the map an entity should move to. The second one works with POIs (point of interest), which are special entities created on the map with the type annotation POI and a tag to identify them.

The Goto processor also exports a Go instruction to be used with the Control system. The instruction supports both coordinates or a POI tag as the destination.

Some ERROR events are also exported for when a Path is not found, for example. It's a more complex system, so maybe is not bad to have a look at the code here. Unfortunatelly the project is that new yet 🙁. Also have a look at the navigation simulation.


To work, the Goto system also requires that the scenario (e.g. entity 1) has a Map component. The Map component holds the path points and the POIs of the scenario. It is shared among all entities.

In the initialization of the Goto system you should provide the find_route function. This function will try to find a route from the point where the entity to be moved is to the destination using a set of previously known points. These points can be added to the map using arrows annotated with the map-path type. All waypoints of the arrow will be added as available points on the scenario Map, creating a graph of safe routes that can be explored.

A Navigation function should be of type NavigationFunction = Callable[[Map, Point, Point], Path]. The parameters are the scenario Map, the source Point and the destination Point. The return of the function is a Path component that goes from source to destination. If a route is not found it can raise a PathNotFound exception passing the best partial path found. A default navigation function is defined here.

Actually, to reduce the number of points that need to be saved, close points from paths are normalized in "superpoints". The size of a superpoint can be controlled using the Map component of the scenario. Another thing that can be controlled is how far an entity can go outside of known paths and "wander about" the map. Every time an entity finds a successful path to a destination the path points are added to the graph, expanding it.

When a route is found and is to be followed, a Path component is added to the entity, and the PathProcessor will move the entity along that path.

PathProcessor

The PathProcessor is an esper processor whose only job is to move entities accross a Path. It does that by keeping track of the next point the entity needs to go to and adding Velocity to it until it gets there.

💡
The PathProcesor can be used without the Goto processor. If you directly add a Path to an entity in the Map it will automatically follow that Path.

Being an esper processor it will adjust the velocity as the Movement processor effectively moves the entity through the map. The max speed increase can be controlled by the speed attribute of the Path component. Once the entity arrives at the last point of the Path, the Path component is removed and a EndOfPath event is added to the EVENT_STORE.

To make the entity stop following a Path in the middle of it you can simply remove the Path component, or change the Path in it.