88 LaneBoundary_Classification_Type ,
99 MovingObject ,
1010 MovingObject_Type ,
11- MovingObject_VehicleClassification ,
1211 MovingObject_VehicleClassification_LightState_BrakeLightState ,
1312 MovingObject_VehicleClassification_LightState_GenericLightState ,
1413 MovingObject_VehicleClassification_LightState_IndicatorState ,
@@ -18,7 +17,7 @@ import {
1817import { ExtensionContext } from "@lichtblick/suite" ;
1918import { DeepRequired } from "ts-essentials" ;
2019
21- import { activate , buildVehicleMetadata } from "../index" ;
20+ import { activate , buildMovingObjectMetadata } from "../index" ;
2221import { buildLaneBoundaryMetadata } from "../lanes" ;
2322
2423jest . mock (
@@ -51,14 +50,43 @@ describe("OSI Visualizer: Message Converter", () => {
5150 roll : 0 ,
5251 } ,
5352 } ;
53+ const mockBaseMoving = {
54+ dimension : {
55+ width : 1 ,
56+ height : 1 ,
57+ length : 1 ,
58+ } ,
59+ position : {
60+ x : 0 ,
61+ y : 0 ,
62+ z : 0 ,
63+ } ,
64+ acceleration : {
65+ x : 20 ,
66+ y : 20 ,
67+ z : 0 ,
68+ } ,
69+ velocity : {
70+ x : 30 ,
71+ y : 40 ,
72+ z : 0 ,
73+ } ,
74+ orientation : {
75+ yaw : 0 ,
76+ pitch : 0 ,
77+ roll : 0 ,
78+ } ,
79+ } ;
5480 const mockMovingObject = {
5581 id : {
5682 value : 0 ,
5783 } ,
58- base : mockBase ,
84+ base : mockBaseMoving ,
5985 type : {
6086 value : MovingObject_Type . VEHICLE ,
6187 } ,
88+ assigned_lane_id : [ 99 , 100 ] ,
89+ model_reference : "" ,
6290 vehicle_attributes : {
6391 bbcenter_to_rear : {
6492 x : 0 ,
@@ -186,40 +214,73 @@ describe("OSI Visualizer: Message Converter", () => {
186214} ) ;
187215
188216describe ( "OSI Visualizer: Moving Objects" , ( ) => {
189- it ( "builds metadata for vehicle moving objects" , ( ) => {
190- const input = {
217+ const input = {
218+ type : MovingObject_Type . VEHICLE ,
219+ base : {
220+ acceleration : {
221+ x : 20 ,
222+ y : 20 ,
223+ z : 0 ,
224+ } ,
225+ velocity : {
226+ x : 30 ,
227+ y : 40 ,
228+ z : 0 ,
229+ } ,
230+ } ,
231+ assigned_lane_id : [ { value : 99 } , { value : 100 } ] ,
232+ vehicle_classification : {
191233 type : 5 ,
192234 light_state : {
193235 indicator_state : 5 ,
194236 brake_light_state : 4 ,
195237 head_light : 3 ,
196238 } ,
197- } as DeepRequired < MovingObject_VehicleClassification > ;
198- expect ( buildVehicleMetadata ( input ) ) . toEqual (
239+ } ,
240+ } as unknown as DeepRequired < MovingObject > ;
241+
242+ it ( "builds metadata for vehicle moving objects" , ( ) => {
243+ expect ( buildMovingObjectMetadata ( input ) ) . toEqual (
199244 expect . arrayContaining ( [
245+ expect . objectContaining ( {
246+ key : "moving_object_type" ,
247+ value : MovingObject_Type [ input . type ] ,
248+ } ) ,
249+ expect . objectContaining ( {
250+ key : "acceleration" ,
251+ value : `${ input . base . acceleration . x } , ${ input . base . acceleration . y } , ${ input . base . acceleration . z } ` ,
252+ } ) ,
253+ expect . objectContaining ( {
254+ key : "velocity" ,
255+ value : `${ input . base . velocity . x } , ${ input . base . velocity . y } , ${ input . base . velocity . z } ` ,
256+ } ) ,
257+ expect . objectContaining ( {
258+ key : "assigned_lane_id" ,
259+ value : input . assigned_lane_id . map ( ( id ) => id . value ) . join ( "," ) ,
260+ } ) ,
200261 expect . objectContaining ( {
201262 key : "type" ,
202- value : MovingObject_VehicleClassification_Type [ input . type ] ,
263+ value : MovingObject_VehicleClassification_Type [ input . vehicle_classification . type ] ,
203264 } ) ,
204265 expect . objectContaining ( {
205266 key : "light_state.indicator_state" ,
206267 value :
207268 MovingObject_VehicleClassification_LightState_IndicatorState [
208- input . light_state . indicator_state
269+ input . vehicle_classification . light_state . indicator_state
209270 ] ,
210271 } ) ,
211272 expect . objectContaining ( {
212273 key : "light_state.brake_light_state" ,
213274 value :
214275 MovingObject_VehicleClassification_LightState_BrakeLightState [
215- input . light_state . brake_light_state
276+ input . vehicle_classification . light_state . brake_light_state
216277 ] ,
217278 } ) ,
218279 expect . objectContaining ( {
219280 key : "light_state.head_light" ,
220281 value :
221282 MovingObject_VehicleClassification_LightState_GenericLightState [
222- input . light_state . head_light
283+ input . vehicle_classification . light_state . head_light
223284 ] ,
224285 } ) ,
225286 ] ) ,
0 commit comments