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
Non-player character (NPC) vehicles now use the MapSegmentBuilder classes to navigate annotated maps.
Use SanFrancisco.scene as a template to build map data for NPCs.
- Remove SFTraffic_New.prefab from scene and any associated scripts, e.g., TrafPerformanceManager.cs, TrafInfoManager.cs and TrafSystem.cs.
- Create a new GameObject at position Vector3.zero and Quaternion.identity, named Map.
- Add MapManager.cs component to this object and save as a prefab in project assets.
- The public field, SpawnLanesHolder, of MapManager.cs requires the MapLaneSegmentBuilder holder transform.
- The public field, IntersectionsHolder, of MapManager.cs requires the TrafficLights holder transform. This has intersection meshes and scripts for lights.
- 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
- Create TrafficLanes holder object as a child of Map.prefab.
- Place all MapLaneSegmentBuilder objects into TrafficLanes holder object for all non intersection lanes.
- Create IntersectionLanes holder object as a child of Map.prefab.
- 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.
- Place MapLaneSegmentBuilder and MapStopLineSegmentBuilder objects into Intersection holder object for each intersection.
Map Intersection Builder
- For each Intersection holder, add the MapIntersectionBuilder.cs component.
- 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.
- Create a Intersection holder object. Be sure its world position is in the center of each intersection.
- Add IntersectionComponent.cs to each Intersection holder object.
- 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.
- Add IntersectionTrafficLightSetComponent.cs.
- Place as a child of the Intersection holder object.
- 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.
- Add TrafficLight meshes as children of the TrafficLightPole.
- Add IntersectionTrafficLightSetComponent.cs to each TrafficLight.
StopLine and MapLaneSegmentBuilder overlap
MapLaneSegmentBuilders final waypoint needs to be slightly overlapping the MapStopLineBuilder