NPC Map Navigation

In the latest Simulator Release, NPC vehicles follow the annotated HD map. No extra steps are required.

The following tutorial works with Simulator Release 2019.05

NPCSetup

Non-player character (NPC) vehicles now use the MapSegmentBuilder classes to navigate annotated maps.

Map Manager#

Use SanFrancisco.scene as a template to build map data for NPCs.

  1. Remove SFTraffic_New.prefab from scene and any associated scripts, e.g., TrafPerformanceManager.cs, TrafInfoManager.cs and TrafSystem.cs.
  2. Create a new GameObject at position Vector3.zero and Quaternion.identity, named Map.
  3. Add MapManager.cs component to this object and save as a prefab in project assets.
  4. The public field, SpawnLanesHolder, of MapManager.cs requires the MapLaneSegmentBuilder holder transform.
  5. The public field, IntersectionsHolder, of MapManager.cs requires the TrafficLights holder transform. This has intersection meshes and scripts for lights.
  6. The public fields Green, Yellow, and Red are materials for the segmentation camera system. If using the Traffic meshes from SanFrancisco.scene, these need to be added here. If not, IntersectionComponent.cs and associated scripts will need to be edited.
Map Lane and Intersection Grouping#

NPCSetup_IntersectionMapBuilder

  1. Create TrafficLanes holder object as a child of Map.prefab.
  2. Place all MapLaneSegmentBuilder objects into TrafficLanes holder object for all non intersection lanes.
  3. Create IntersectionLanes holder object as a child of Map.prefab.
  4. Create a new Intersection holder object as a child of IntersectionLanes transform for each intersection annotation. Be sure its world position is in the center of each intersection.
  5. Place MapLaneSegmentBuilder and MapStopLineSegmentBuilder objects into Intersection holder object for each intersection.
Map Intersection Builder#

NPCSetup_IntersectionMapBuilder

  1. For each Intersection holder, add the MapIntersectionBuilder.cs component.
Traffic Lights#

NPCSetup_TrafficLight01

  1. Create a TrafficLights holder object to hold all traffic light meshes or place all traffic meshes under the map annotation Intersections. Just be sure to have the root holder be in MapManager.cs IntersectionHolder public reference.
  2. Create a Intersection holder object. Be sure its world position is in the center of each intersection.
  3. Add IntersectionComponent.cs to each Intersection holder object.

NPCSetup_TrafficLight02

  1. Place TrafficLightPole facing it's corresponding StopLineSegmentBuilder object. The transfom needs to be Z axis or gizmo arrow forward, parallel to the StopLineSegmentBuilder object Z axis or gizmo arrow forward.
  2. Add IntersectionTrafficLightSetComponent.cs.
  3. Place as a child of the Intersection holder object.
  4. For opposite facing TrafficLightPoles and StopLineSegmentBuilders, be sure to orient transforms in Z axis or gizmo arrow forward but perpendicular to other facing light poles and stoplines.

NPCSetup_TrafficLight03

  1. Add TrafficLight meshes as children of the TrafficLightPole.
  2. Add IntersectionTrafficLightSetComponent.cs to each TrafficLight.
StopLine and MapLaneSegmentBuilder overlap#

NPCSetup_StopLineAndLaneOverlap

MapLaneSegmentBuilders final waypoint needs to be slightly overlapping the MapStopLineBuilder