Unity NavMesh and ROS Map
This document explains the use of Unity NavMesh and ROS Map in SEAN. For user-developers, this document also goes over the steps needed to update or create the NavMesh and map of a scene.
The NavMesh is the "map" used by Unity to determine where the robot and avatars are allowed to go. In particular, the robot start position and goal position are always chosen inside the region marked by the "Walkable area" of the NavMesh.
To view the NavMesh of a scene, open the Window >> AI >> Navigation tab, and turn on Gizmos the scene view. The region highlighted in blue is the walkable area. We use the Zara scene as an example.
Updating the NavMesh
We update the NavMesh to set the robot's area of movement and encourage more human-robot interactions. To do so, we first identify the game object that contains the walkable area (in this case the MainSideWalk), select it in the hierarchy, go to the Navigation >> Object, and set its Navigation Area to Walkable.
Next, to limit the robot's area of movement, we create some cubes in the scene, and set their Navigation Area to Not Walkable. After some testing, it seems best to place the cubes slightly above the ground (walking surface).
Finally, with these cubes activated in the hierarchy, go to Navigation >> Bake and click Bake. The updated NavMesh should be shown in the scene view. Deactivate the cubes after baking the NavMesh.
SEAN uses the ROS map_server to publish the map of the scene. The map consists of a png image and a YAML file that contains the metadata of the map. In SEAN, the png image is black and white, and the white region in the image corresponds to the walkable area in the scene. The robot can thus use this published map to plan its route.
Generating the ROS map
To generate a ROS map, launch tmux as usual with
cd ~/sim_ws/tmux/sean_navstack && tmuxinator. In the top left window of tmux, run
rosrun rqt_image_view rqt_image_view
The rqt window will open up and select the topic on the top left to be
Next, in Unity, deactivate everything in the scene except for the static environment and the Game Object SEAN >> Util >> CreateMap. For playback scenes, remember to deactivate the Environment >> PedestrianControl game object. Now, make sure SEAN, Util, CreateMap are all positioned at (0,0,0), and only adjust the position and scale of the SEAN >> Util >> CreateMap >> LowerMap object to lie slightly above the ground and cover the walkable area. This is what it looks like:
Note: due to the logic of our code, it is best to set the LowerMap to be a square (x-scale = y-scale).
Note: While theoretically the ROS map should agree with the Unity NavMesh, in practice, we only need the walkable NavMesh to be well-contained in the white region in the ROS map (as shown in the picture). The ROS map may contain regions that are not walkable in the NavMesh, as long as any possible route will not go through those regions.
Finally, click Play in the Unity Editor. After the map is generated, a black and white map should appear in the rqt window. Save the image as
short_map.png in the corresponding folder in
social_sim_ros. For our example, the following shows the map of the Zara scene, so the image should be saved to
Meanwhile, the Unity console should log the following messages:
Update this information in the corresponding YAML file. If you did not edit the map generating script, you only need to update the origin position. For our example, we update line 3 of
origin: [-15,-21,0], according to the Unity console log.
Now the ROS map_server should be able to publish the map. Remember to deactivate the CreateMap object when running trials.