2020-03-02 16:40:34 +08:00
# How to generate the pedestrian navigation info
2020-03-02 21:35:50 +08:00
---
## Introduction
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
The pedestrians to walk need information about the map in a specific format. That file that describes the map for navigation is a binary file with extension `.BIN` , and they are saved in the **Nav** folder of the map. Each map needs a `.BIN` file with the same name that the map, so automatically can be loaded with the map.
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
This `.BIN` file is generated from the Recast & Detour library and has all the information that allows pathfinding and crow management.
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
If we need to generate this `.BIN` file for a custom map, we need to follow this process:
2019-12-05 19:03:55 +08:00
* Export the map meshes
2019-12-10 01:41:57 +08:00
* Rebuild the `.BIN` file with RecastBuilder
* Copy the `.BIN` file in a `Nav/` folder with the map
2019-12-05 19:03:55 +08:00
2020-03-02 21:35:50 +08:00
---
## Export meshes
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
We have several types of meshes for navigation. The meshes need to be identified as one of those types, using specific nomenclature.
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
| Type | Start with | Description |
|-----------|------------|-------------|
| Ground | `Road_Sidewalk` | Pedestrians can walk over these meshes freely (sidewalks...). |
| Grass | `Road_Crosswalk` | Pedestrians can walk over these meshes but as a second option if no ground is found. |
| Road | `Road_Grass` | Pedestrians won't be allowed to walk on it unless we specify some percentage of pedestrians that will be allowed. |
| Crosswalk | `Road_Road` , `Road_Curb` , `Road_Gutter` or `Road_Marking` | Pedestrians can cross the roads only through these meshes. |
2020-03-02 16:40:34 +08:00
| Block | any other name | Pedestrians will avoid these meshes always (are obstacles like traffic lights, trees, houses...). |
< br >
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
For instance, all road meshes need to start with `Road_Road` e.g: `Road_Road_Mesh_1` , `Road_Road_Mesh_2` ...
2019-12-05 19:03:55 +08:00
This nomenclature is used by RoadRunner when it exports the map, so we are just following the same.
2019-12-10 01:41:57 +08:00
Also, we don't need to export meshes that are not of interest by the navigation system, like landscapes where pedestrians will not walk, or UE4's _sky domes_ , rivers, lakes and so on.
2019-12-05 19:03:55 +08:00
We can **tag** any mesh with the name **NoExport** and then the exporter will ignore that mesh.
2019-12-10 01:41:57 +08:00
Once we have all meshes with the proper nomenclature and tagged the ones that we want to ignore, we can call the Carla Exporter that is found under the `File > Actors > Carla Exporter` :
2019-12-05 19:03:55 +08:00
2020-05-05 22:33:13 +08:00
![Carla Exporter ](img/tuto_D_pedestrian_CarlaExporter.jpg )
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
The `.OBJ` file will be saved with the name of the map with extension OBJ in the **CarlaUE4/Saved** folder of UE4.
2019-12-05 19:03:55 +08:00
2020-03-02 21:35:50 +08:00
---
## Rebuild the navigation binary
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
With Recast & Detour library comes an executable file that needs to be used to generate the final `.BIN` file.
The executable uses by default the parameters to work on Carla, and you only need to pass as parameter the `.OBJ` you exported above, and the `.BIN` will be created.
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
You can find the executable, on the `Carla/Build/recast-{version}-install/bin/` folder, already compiled when Carla was installed.
2019-12-05 19:03:55 +08:00
2019-12-10 01:41:57 +08:00
Run:
```sh
$ RecastBuilder test.object
2019-12-05 19:03:55 +08:00
```
2019-12-10 01:41:57 +08:00
And it will create a `test.bin` file, that needs to be copied to the map folder, inside the `Nav/` folder.
2019-12-05 19:03:55 +08:00
For example, this would be the structure of files of a Test map:
2019-12-10 01:41:57 +08:00
```
Test/
├─ Test.umap
├─ Nav/
│ └─ Test.bin
└─ OpenDrive/
└─ Test.xodr
```