-
Notifications
You must be signed in to change notification settings - Fork 408
/
hooksImporter.js
218 lines (205 loc) · 8.57 KB
/
hooksImporter.js
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* eslint-disable header/header */
// Copyright (c) 2018-present, Cruise LLC
//
// This source code is licensed under the Apache License, Version 2.0,
// found in the LICENSE file in the root directory of this source tree.
// You may not use this file except in compliance with the License.
import memoize from "lodash/memoize";
import { getGlobalHooks } from "./loadWebviz";
import { DIAGNOSTIC_TOPIC } from "./util/globalConstants";
/*
We've split this code out seperately from the rest of the hooks so that we can lazy load these components by
lazily importing this file at runtime.
*/
export function panelsByCategory() {
const DiagnosticStatusPanel = require("webviz-core/src/panels/diagnostics/DiagnosticStatusPanel").default;
const DiagnosticSummary = require("webviz-core/src/panels/diagnostics/DiagnosticSummary").default;
const GlobalVariables = require("webviz-core/src/panels/GlobalVariables").default;
const GlobalVariableSlider = require("webviz-core/src/panels/GlobalVariableSlider").default;
const ImageViewPanel = require("webviz-core/src/panels/ImageView").default;
const Internals = require("webviz-core/src/panels/Internals").default;
const NodePlayground = require("webviz-core/src/panels/NodePlayground").default;
const Note = require("webviz-core/src/panels/Note").default;
const NumberOfRenders = require("webviz-core/src/panels/NumberOfRenders").default;
const PlaybackPerformance = require("webviz-core/src/panels/PlaybackPerformance").default;
const Plot = require("webviz-core/src/panels/Plot").default;
const Publish = require("webviz-core/src/panels/Publish").default;
const RawMessages = require("webviz-core/src/panels/RawMessages").default;
const Rosout = require("webviz-core/src/panels/Rosout").default;
const SourceInfo = require("webviz-core/src/panels/SourceInfo").default;
const StateTransitions = require("webviz-core/src/panels/StateTransitions").default;
const SubscribeToList = require("webviz-core/src/panels/SubscribeToList").default;
const Tab = require("webviz-core/src/panels/Tab").default;
const TwoDimensionalPlot = require("webviz-core/src/panels/TwoDimensionalPlot").default;
const ThreeDimensionalViz = require("webviz-core/src/panels/ThreeDimensionalViz").default;
const { ndash } = require("webviz-core/src/util/entities");
const ros = [
{ title: "2D Plot", component: TwoDimensionalPlot },
{ title: "3D", component: ThreeDimensionalViz },
{ title: `Diagnostics ${ndash} Summary`, component: DiagnosticSummary },
{ title: `Diagnostics ${ndash} Detail`, component: DiagnosticStatusPanel },
{ title: "Image", component: ImageViewPanel },
{ title: "Plot", component: Plot },
{ title: "Publish", component: Publish },
{ title: "Raw Messages", component: RawMessages },
{ title: "rosout", component: Rosout },
{ title: "State Transitions", component: StateTransitions },
];
const utilities = [
{ title: "Global Variables", component: GlobalVariables },
{ title: "Global Variable Slider", component: GlobalVariableSlider },
{ title: "Node Playground", component: NodePlayground },
{ title: "Notes", component: Note },
{ title: "Tab", component: Tab },
{ title: "Webviz Internals", component: Internals },
{ title: "Data Source Info", component: SourceInfo },
];
const debugging = [
{ title: "Number of Renders", component: NumberOfRenders },
{ title: "Playback Performance", component: PlaybackPerformance },
{ title: "Subscribe to List", component: SubscribeToList },
];
return { ros, utilities, debugging };
}
export function perPanelHooks() {
const BlurIcon = require("@mdi/svg/svg/blur.svg").default;
const GridIcon = require("@mdi/svg/svg/grid.svg").default;
const HexagonIcon = require("@mdi/svg/svg/hexagon.svg").default;
const HexagonMultipleIcon = require("@mdi/svg/svg/hexagon-multiple.svg").default;
const PentagonOutlineIcon = require("@mdi/svg/svg/pentagon-outline.svg").default;
const RadarIcon = require("@mdi/svg/svg/radar.svg").default;
const RobotIcon = require("@mdi/svg/svg/robot.svg").default;
const LaserScanVert = require("webviz-core/src/panels/ThreeDimensionalViz/LaserScanVert").default;
const { defaultMapPalette } = require("webviz-core/src/panels/ThreeDimensionalViz/commands/utils");
const { POINT_CLOUD_DATATYPE, POSE_STAMPED_DATATYPE, TF_DATATYPE } = require("webviz-core/src/util/globalConstants");
const SUPPORTED_MARKER_DATATYPES = {
// generally supported datatypes
VISUALIZATION_MSGS_MARKER_DATATYPE: "visualization_msgs/Marker",
VISUALIZATION_MSGS_MARKER_ARRAY_DATATYPE: "visualization_msgs/MarkerArray",
POSE_STAMPED_DATATYPE,
POINT_CLOUD_DATATYPE,
SENSOR_MSGS_LASER_SCAN_DATATYPE: "sensor_msgs/LaserScan",
NAV_MSGS_OCCUPANCY_GRID_DATATYPE: "nav_msgs/OccupancyGrid",
GEOMETRY_MSGS_POLYGON_STAMPED_DATATYPE: "geometry_msgs/PolygonStamped",
TF_DATATYPE,
};
return {
DiagnosticSummary: {
defaultConfig: {
pinnedIds: [],
hardwareIdFilter: "",
topicToRender: DIAGNOSTIC_TOPIC,
},
},
ImageView: {
defaultConfig: {
cameraTopic: "",
enabledMarkerTopics: [],
customMarkerTopicOptions: [],
scale: 0.2,
transformMarkers: false,
synchronize: false,
mode: "fit",
zoomPercentage: 100,
offset: [0, 0],
},
imageMarkerDatatypes: ["visualization_msgs/ImageMarker"],
canTransformMarkersByTopic: (topic) => !topic.includes("rect"),
},
GlobalVariableSlider: {
getVariableSpecificOutput: () => null,
},
StateTransitions: { defaultConfig: { paths: [] }, customStateTransitionColors: {} },
ThreeDimensionalViz: {
defaultConfig: {
checkedKeys: ["name:Topics"],
expandedKeys: ["name:Topics"],
followTf: null,
cameraState: {},
modifiedNamespaceTopics: [],
pinTopics: false,
settingsByKey: {},
autoSyncCameraState: false,
},
SUPPORTED_MARKER_DATATYPES,
allSupportedMarkers: [
"arrow",
"cube",
"cubeList",
"cylinder",
"filledPolygon",
"grid",
"instancedLineList",
"laserScan",
"linedConvexHull",
"lineList",
"lineStrip",
"pointcloud",
"points",
"poseMarker",
"sphere",
"sphereList",
"text",
"triangleList",
],
renderAdditionalMarkers: () => {},
topics: [],
iconsByDatatype: {
"visualization_msgs/Marker": HexagonIcon,
"visualization_msgs/MarkerArray": HexagonMultipleIcon,
"nav_msgs/OccupancyGrid": GridIcon,
"sensor_msgs/LaserScan": RadarIcon,
"geometry_msgs/PolygonStamped": PentagonOutlineIcon,
[POINT_CLOUD_DATATYPE]: BlurIcon,
[POSE_STAMPED_DATATYPE]: RobotIcon,
},
// TODO(Audrey): remove icons config after topic group release
icons: {},
AdditionalToolbarItems: () => null,
LaserScanVert,
setGlobalVariablesInSceneBuilder: (globalVariables, selectionState, topicsToRender) => ({
selectionState,
topicsToRender,
}),
consumeMessage: (topic, msg, consumeMethods, { errors }) => {
// TF messages are consumed by TransformBuilder, not SceneBuilder.
if (msg.datatype === SUPPORTED_MARKER_DATATYPES.TF_DATATYPE) {
return;
}
errors.topicsWithError.set(topic, `Unrecognized topic datatype for scene: ${msg.datatype}`);
},
getMessagePose: (msg) => msg.message.pose,
addMarkerToCollector(add, topic, marker, setTopicError) {
setTopicError(topic, `Unsupported marker type: ${marker.type}`);
},
getSyntheticArrowMarkerColor: () => ({ r: 0, g: 0, b: 1, a: 0.5 }),
getFlattenedPose: () => undefined,
getOccupancyGridValues: (topic) => [0.5, "map"],
getMapPalette() {
return defaultMapPalette;
},
consumePose: () => {},
getMarkerColor: (topic, markerColor) => markerColor,
hasBlacklistTopics: () => false,
ungroupedNodesCategory: "Topics",
rootTransformFrame: "map",
defaultFollowTransformFrame: null,
skipTransformFrame: null,
},
RawMessages: { docLinkFunction: () => undefined },
installChartJs: () => {
require("webviz-core/src/util/installChartjs").default();
},
};
}
// Helper function to bypass lazy fetch when running tests
export function testSetup() {
const hooks = getGlobalHooks();
hooks.panelsByCategory = memoize(() => {
return panelsByCategory();
});
hooks.perPanelHooks = memoize(() => {
return perPanelHooks();
});
hooks.areHooksImported = () => true;
}