public bool Export(string foldername) { try { MapAnnotationData = new MapManagerData(); // Process lanes, intersections. MapAnnotationData.GetIntersections(); MapAnnotationData.GetTrafficLanes(); if (Calculate()) { var sb = new StringBuilder(); foreach (var list in ExportLists) { var csvFilename = list.FileName; var csvHeader = VectorMapUtility.GetCSVHeader(list.Type); var filepath = Path.Combine(foldername, csvFilename); if (!System.IO.Directory.Exists(foldername)) { System.IO.Directory.CreateDirectory(foldername); } if (System.IO.File.Exists(filepath)) { System.IO.File.Delete(filepath); } sb.Clear(); using (StreamWriter sw = File.CreateText(filepath)) { sb.Append(csvHeader); sb.Append("\n"); foreach (var e in list.List) { foreach (var field in list.Type.GetFields(BindingFlags.Instance | BindingFlags.Public)) { sb.Append(field.GetValue(e).ToString()); sb.Append(","); } sb.Remove(sb.Length - 1, 1); sb.Append("\n"); } sw.Write(sb); } } Debug.Log("Successfully generated and exported Autoware Vector Map!"); return(true); } Debug.LogError("Failed to export Autoware Map!"); } catch (Exception exc) { Debug.LogError($"Autoware Map export unexpected error: {exc.Message}"); } return(false); }
private void SetMapData() { mapData = new MapManagerData(); if (mapData.MapHolder == null) { return; } trafficLanes = mapData.GetTrafficLanes(); intersections = mapData.GetIntersections(); totalLaneDist = MapManagerData.GetTotalLaneDistance(trafficLanes); intersections.ForEach(intersection => intersection.SetTriggerAndState()); }
public void ExportVectorMap(string foldername) { MapAnnotationData = new MapManagerData(); // Process lanes, intersections. MapAnnotationData.GetIntersections(); MapAnnotationData.GetTrafficLanes(); if (Calculate()) { Export(foldername); } }
private void SetMapData() { mapData = new MapManagerData(); if (mapData.MapHolder == null) { return; } trafficLanes = mapData.GetTrafficLanes(); intersections = mapData.GetIntersections(); pedestrianLanes = mapData.GetPedestrianLanes(); trafficLanes.ForEach(trafficLane => trafficLane.SetTrigger()); intersections.ForEach(intersection => intersection.SetTriggerAndState()); }
private void SetMapData() { mapData = new MapManagerData(); if (mapData.MapHolder == null) { return; } trafficLanes = mapData.GetTrafficLanes(); intersections = mapData.GetIntersections(); pedestrianLanes = mapData.GetPedestrianLanes(); parkingSpaces = mapData.GetParkingSpaces(); allLanes.AddRange(trafficLanes); foreach (MapIntersection itersection in intersections) { allLanes.AddRange(itersection.GetIntersectionLanes()); } trafficLanes.ForEach(trafficLane => trafficLane.SetTrigger()); intersections.ForEach(intersection => intersection.SetTriggerAndState()); }
/// <summary> /// Initialization method, has to be called every time map is loaded /// </summary> public void Initialize() { var mapManagerData = new MapManagerData(); var trafficLanes = mapManagerData.GetTrafficLanes(); foreach (var mapLane in trafficLanes) { if (mapLane.mapLocalPositions.Count == 0) { continue; } var previousPosition = mapLane.transform.TransformPoint(mapLane.mapLocalPositions[0]); for (var i = 1; i < mapLane.mapLocalPositions.Count; i++) { var localPos = mapLane.mapLocalPositions[i]; var position = mapLane.transform.TransformPoint(localPos); trafficLines.Add(new LaneLineData(previousPosition, position)); previousPosition = position; } } var pedestrianLanes = mapManagerData.GetPedestrianLanes(); foreach (var mapLane in pedestrianLanes) { if (mapLane.mapLocalPositions.Count == 0) { continue; } var previousPosition = mapLane.transform.TransformPoint(mapLane.mapLocalPositions[0]); for (var i = 1; i < mapLane.mapLocalPositions.Count; i++) { var localPos = mapLane.mapLocalPositions[i]; var position = mapLane.transform.TransformPoint(localPos); pedestrianLines.Add(new LaneLineData(previousPosition, position)); previousPosition = position; } } }
public Dictionary <MapTrafficLane, LaneLineOverrideData> Process() { var mapManagerData = new MapManagerData(); var lanes = mapManagerData.GetTrafficLanes(); var lineDict = new Dictionary <MapLine, SegmentedLine3D>(); var laneDict = new Dictionary <MapTrafficLane, LaneLineSegments>(); foreach (var lane in lanes) { var laneData = new LaneLineSegments(); if (lineDict.ContainsKey(lane.rightLineBoundry)) { laneData.rightLine = lineDict[lane.rightLineBoundry]; } else { var segment = LaneLineToSegmentedLine(lane.rightLineBoundry); laneData.rightLine = segment; lineDict[lane.rightLineBoundry] = segment; } if (lineDict.ContainsKey(lane.leftLineBoundry)) { laneData.leftLine = lineDict[lane.leftLineBoundry]; } else { var segment = LaneLineToSegmentedLine(lane.leftLineBoundry); laneData.leftLine = segment; lineDict[lane.leftLineBoundry] = segment; } laneDict.Add(lane, laneData); } connectedSegments = ConnectSegments(segments, settings); const float correctionThreshold = 1f; SegmentedLine3D prevMatch = null; var index = 0; try { foreach (var mapLine in lineDict.Values) { var progress = (float)index++ / lineDict.Count; EditorUtility.DisplayProgressBar("Correcting HD map lines", $"Processing lane {index} of {lineDict.Count}", progress); for (var i = 0; i < mapLine.lines.Count; ++i) { Vector3 start, end; if (i == 0) { var startVec = mapLine.lines[i].Vector; var startnVec = new Vector2(-startVec.z, startVec.x).normalized *correctionThreshold; start = FindBestSegmentMatch(mapLine.lines[i].Start, startnVec, prevMatch, out prevMatch); } else { start = mapLine.lines[i - 1].End; } var vec = mapLine.lines[i].Vector; if (i != mapLine.lines.Count - 1) { vec += mapLine.lines[i + 1].Vector; } var nVec = new Vector2(-vec.z, vec.x).normalized *correctionThreshold; end = FindBestSegmentMatch(mapLine.lines[i].End, nVec, prevMatch, out prevMatch); var width = mapLine.lines[i].width; var color = mapLine.lines[i].color; mapLine.lines[i] = new Line3D(start, end, width) { color = color }; } } } finally { EditorUtility.ClearProgressBar(); } var result = new Dictionary <MapTrafficLane, LaneLineOverrideData>(); foreach (var kvp in laneDict) { var entry = new LaneLineOverrideData(); var rightPoints = new List <Vector3>(); rightPoints.Add(kvp.Value.rightLine.lines[0].Start); for (var i = 0; i < kvp.Value.rightLine.lines.Count; ++i) { rightPoints.Add(kvp.Value.rightLine.lines[i].End); } entry.rightLineWorldPositions = rightPoints; var leftPoints = new List <Vector3>(); leftPoints.Add(kvp.Value.leftLine.lines[0].Start); for (var i = 0; i < kvp.Value.leftLine.lines.Count; ++i) { leftPoints.Add(kvp.Value.leftLine.lines[i].End); } entry.leftLineWorldPositions = leftPoints; result.Add(kvp.Key, entry); } return(result); }