-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.ts
More file actions
115 lines (108 loc) · 3.57 KB
/
Copy pathindex.ts
File metadata and controls
115 lines (108 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { Time } from "@foxglove/schemas";
import { LogicalLane, LogicalLaneBoundary } from "@lichtblick/asam-osi-types";
import {
pointListToTriangleListPrimitive,
laneToTriangleListPrimitive,
MarkerPoint,
} from "@utils/primitives/lines";
import { PartialSceneEntity, generateSceneEntityId } from "@utils/scene";
import { DeepRequired } from "ts-essentials";
import { buildLogicalLaneBoundaryMetadata, buildLogicalLaneMetadata } from "./metadata";
import {
LANE_BOUNDARY_ARROWS,
LOGICAL_LANE_BOUNDARY_RENDERING_WIDTH,
LOGICAL_LANE_BOUNDARY_COLOR,
LOGICAL_LANE_RENDERING_HEIGHT_OFFSET,
LOGICAL_LANE_COLOR,
LOGICAL_LANE_VISUALIZATION_WIDTH,
} from "@/config/constants";
import { PREFIX_LOGICAL_LANE, PREFIX_LOGICAL_LANE_BOUNDARY } from "@/config/entityPrefixes";
export function buildLogicalLaneBoundaryEntity(
osiLogicalLaneBoundary: DeepRequired<LogicalLaneBoundary>,
frame_id: string,
time: Time,
): PartialSceneEntity {
// Create LaneBoundaryPoint objects using only necessary fields for rendering
const laneBoundaryPoints = osiLogicalLaneBoundary.boundary_line.map((point) => {
return {
position: {
x: point.position.x,
y: point.position.y,
z: point.position.z + LOGICAL_LANE_RENDERING_HEIGHT_OFFSET,
},
width: LOGICAL_LANE_BOUNDARY_RENDERING_WIDTH,
height: 0,
};
});
// Set option for dashed lines
const options = {
dashed: false,
arrows: LANE_BOUNDARY_ARROWS,
invertArrows: false,
};
return {
timestamp: time,
frame_id,
id: generateSceneEntityId(PREFIX_LOGICAL_LANE_BOUNDARY, osiLogicalLaneBoundary.id.value),
lifetime: { sec: 0, nsec: 0 },
frame_locked: true,
triangles: [
pointListToTriangleListPrimitive(laneBoundaryPoints, LOGICAL_LANE_BOUNDARY_COLOR, options),
],
metadata: buildLogicalLaneBoundaryMetadata(osiLogicalLaneBoundary),
};
}
export function buildLogicalLaneEntity(
osiLogicalLane: DeepRequired<LogicalLane>,
frame_id: string,
time: Time,
osiLeftLaneBoundaries: DeepRequired<LogicalLaneBoundary>[],
osiRightLaneBoundaries: DeepRequired<LogicalLaneBoundary>[],
): PartialSceneEntity {
const leftLaneBoundaries: MarkerPoint[][] = [];
for (const lb of osiLeftLaneBoundaries) {
const laneBoundaryPoints = lb.boundary_line.map((point) => {
return {
position: {
x: point.position.x,
y: point.position.y,
z: point.position.z + LOGICAL_LANE_RENDERING_HEIGHT_OFFSET,
},
width: LOGICAL_LANE_BOUNDARY_RENDERING_WIDTH,
height: 0, // no need to set height for logical lanes
};
});
leftLaneBoundaries.push(laneBoundaryPoints);
}
const rightLaneBoundaries: MarkerPoint[][] = [];
for (const lb of osiRightLaneBoundaries) {
const laneBoundaryPoints = lb.boundary_line.map((point) => {
return {
position: {
x: point.position.x,
y: point.position.y,
z: point.position.z + LOGICAL_LANE_RENDERING_HEIGHT_OFFSET,
},
width: LOGICAL_LANE_BOUNDARY_RENDERING_WIDTH,
height: 0, // no need to set height for logical lanes
};
});
rightLaneBoundaries.push(laneBoundaryPoints);
}
return {
timestamp: time,
frame_id,
id: generateSceneEntityId(PREFIX_LOGICAL_LANE, osiLogicalLane.id.value),
lifetime: { sec: 0, nsec: 0 },
frame_locked: true,
triangles: [
laneToTriangleListPrimitive(
leftLaneBoundaries,
rightLaneBoundaries,
LOGICAL_LANE_COLOR,
LOGICAL_LANE_VISUALIZATION_WIDTH,
),
],
metadata: buildLogicalLaneMetadata(osiLogicalLane),
};
}