4
4
5
5
from osi3trace .osi_trace import OSITrace
6
6
from osi3 .osi_sensorview_pb2 import SensorView
7
+ from osi3 .osi_sensorviewconfiguration_pb2 import SensorViewConfiguration
7
8
from osi3 .osi_groundtruth_pb2 import GroundTruth
8
9
from osi3 .osi_hostvehicledata_pb2 import HostVehicleData
9
10
from osi3 .osi_sensordata_pb2 import SensorData
10
- from osi3 .osi_sensorviewconfiguration_pb2 import SensorViewConfiguration
11
- from osi3 .osi_trafficupdate_pb2 import TrafficUpdate
12
11
from osi3 .osi_trafficcommand_pb2 import TrafficCommand
13
12
from osi3 .osi_trafficcommandupdate_pb2 import TrafficCommandUpdate
13
+ from osi3 .osi_trafficupdate_pb2 import TrafficUpdate
14
14
from osi3 .osi_motionrequest_pb2 import MotionRequest
15
15
from osi3 .osi_streamingupdate_pb2 import StreamingUpdate
16
16
@@ -35,6 +35,23 @@ def test_osi_trace_sv(self):
35
35
36
36
self .assertTrue (os .path .exists (path_output ))
37
37
38
+ def test_osi_trace_svc (self ):
39
+ with tempfile .TemporaryDirectory () as tmpdirname :
40
+ path_output = os .path .join (tmpdirname , "output_svc.txth" )
41
+ path_input = os .path .join (tmpdirname , "input_svc.osi" )
42
+ create_sample_svc (path_input )
43
+
44
+ trace = OSITrace (path_input , "SensorViewConfiguration" )
45
+ with open (path_output , "wt" ) as f :
46
+ for message in trace :
47
+ self .assertIsInstance (message , SensorViewConfiguration )
48
+ f .write (str (message ))
49
+
50
+ self .assertEqual (len (trace .retrieve_offsets ()), 1 )
51
+ trace .close ()
52
+
53
+ self .assertTrue (os .path .exists (path_output ))
54
+
38
55
def test_osi_trace_gt (self ):
39
56
with tempfile .TemporaryDirectory () as tmpdirname :
40
57
path_output = os .path .join (tmpdirname , "output_gt.txth" )
@@ -86,40 +103,6 @@ def test_osi_trace_sd(self):
86
103
87
104
self .assertTrue (os .path .exists (path_output ))
88
105
89
- def test_osi_trace_svc (self ):
90
- with tempfile .TemporaryDirectory () as tmpdirname :
91
- path_output = os .path .join (tmpdirname , "output_svc.txth" )
92
- path_input = os .path .join (tmpdirname , "input_svc.osi" )
93
- create_sample_svc (path_input )
94
-
95
- trace = OSITrace (path_input , "SensorViewConfiguration" )
96
- with open (path_output , "wt" ) as f :
97
- for message in trace :
98
- self .assertIsInstance (message , SensorViewConfiguration )
99
- f .write (str (message ))
100
-
101
- self .assertEqual (len (trace .retrieve_offsets ()), 1 )
102
- trace .close ()
103
-
104
- self .assertTrue (os .path .exists (path_output ))
105
-
106
- def test_osi_trace_tu (self ):
107
- with tempfile .TemporaryDirectory () as tmpdirname :
108
- path_output = os .path .join (tmpdirname , "output_tu.txth" )
109
- path_input = os .path .join (tmpdirname , "input_tu.osi" )
110
- create_sample_tu (path_input )
111
-
112
- trace = OSITrace (path_input , "TrafficUpdate" )
113
- with open (path_output , "wt" ) as f :
114
- for message in trace :
115
- self .assertIsInstance (message , TrafficUpdate )
116
- f .write (str (message ))
117
-
118
- self .assertEqual (len (trace .retrieve_offsets ()), 10 )
119
- trace .close ()
120
-
121
- self .assertTrue (os .path .exists (path_output ))
122
-
123
106
def test_osi_trace_tc (self ):
124
107
with tempfile .TemporaryDirectory () as tmpdirname :
125
108
path_output = os .path .join (tmpdirname , "output_tc.txth" )
@@ -154,6 +137,23 @@ def test_osi_trace_tcu(self):
154
137
155
138
self .assertTrue (os .path .exists (path_output ))
156
139
140
+ def test_osi_trace_tu (self ):
141
+ with tempfile .TemporaryDirectory () as tmpdirname :
142
+ path_output = os .path .join (tmpdirname , "output_tu.txth" )
143
+ path_input = os .path .join (tmpdirname , "input_tu.osi" )
144
+ create_sample_tu (path_input )
145
+
146
+ trace = OSITrace (path_input , "TrafficUpdate" )
147
+ with open (path_output , "wt" ) as f :
148
+ for message in trace :
149
+ self .assertIsInstance (message , TrafficUpdate )
150
+ f .write (str (message ))
151
+
152
+ self .assertEqual (len (trace .retrieve_offsets ()), 10 )
153
+ trace .close ()
154
+
155
+ self .assertTrue (os .path .exists (path_output ))
156
+
157
157
def test_osi_trace_mr (self ):
158
158
with tempfile .TemporaryDirectory () as tmpdirname :
159
159
path_output = os .path .join (tmpdirname , "output_mr.txth" )
@@ -257,6 +257,31 @@ def create_sample_sv(path):
257
257
f .close ()
258
258
259
259
260
+ def create_sample_svc (path ):
261
+ f = open (path , "ab" )
262
+ sensorviewconfig = SensorViewConfiguration ()
263
+
264
+ sensorviewconfig .version .version_major = 3
265
+ sensorviewconfig .version .version_minor = 0
266
+ sensorviewconfig .version .version_patch = 0
267
+
268
+ sensorviewconfig .sensor_id .value = 42
269
+
270
+ sensorviewconfig .mounting_position .position .x = 0.8
271
+ sensorviewconfig .mounting_position .position .y = 1.0
272
+ sensorviewconfig .mounting_position .position .z = 0.5
273
+
274
+ sensorviewconfig .mounting_position .orientation .roll = 0.10
275
+ sensorviewconfig .mounting_position .orientation .pitch = 0.15
276
+ sensorviewconfig .mounting_position .orientation .yaw = 0.25
277
+
278
+ """Serialize"""
279
+ bytes_buffer = sensorviewconfig .SerializeToString ()
280
+ f .write (struct .pack ("<L" , len (bytes_buffer )) + bytes_buffer )
281
+
282
+ f .close ()
283
+
284
+
260
285
def create_sample_gt (path ):
261
286
f = open (path , "ab" )
262
287
ground_truth = GroundTruth ()
@@ -379,72 +404,6 @@ def create_sample_sd(path):
379
404
f .close ()
380
405
381
406
382
- def create_sample_svc (path ):
383
- f = open (path , "ab" )
384
- sensorviewconfig = SensorViewConfiguration ()
385
-
386
- sensorviewconfig .version .version_major = 3
387
- sensorviewconfig .version .version_minor = 0
388
- sensorviewconfig .version .version_patch = 0
389
-
390
- sensorviewconfig .sensor_id .value = 42
391
-
392
- sensorviewconfig .mounting_position .position .x = 0.8
393
- sensorviewconfig .mounting_position .position .y = 1.0
394
- sensorviewconfig .mounting_position .position .z = 0.5
395
-
396
- sensorviewconfig .mounting_position .orientation .roll = 0.10
397
- sensorviewconfig .mounting_position .orientation .pitch = 0.15
398
- sensorviewconfig .mounting_position .orientation .yaw = 0.25
399
-
400
- """Serialize"""
401
- bytes_buffer = sensorviewconfig .SerializeToString ()
402
- f .write (struct .pack ("<L" , len (bytes_buffer )) + bytes_buffer )
403
-
404
- f .close ()
405
-
406
-
407
- def create_sample_tu (path ):
408
- f = open (path , "ab" )
409
- trafficupdate = TrafficUpdate ()
410
-
411
- trafficupdate .version .version_major = 3
412
- trafficupdate .version .version_minor = 0
413
- trafficupdate .version .version_patch = 0
414
-
415
- trafficupdate .timestamp .seconds = 0
416
- trafficupdate .timestamp .nanos = 0
417
-
418
- moving_object = trafficupdate .update .add ()
419
- moving_object .id .value = 114
420
-
421
- # Generate 10 OSI messages for 9 seconds
422
- for i in range (10 ):
423
- # Increment the time
424
- trafficupdate .timestamp .seconds += 1
425
- trafficupdate .timestamp .nanos += 100000
426
-
427
- moving_object .vehicle_classification .type = 2
428
-
429
- moving_object .base .dimension .length = 5
430
- moving_object .base .dimension .width = 2
431
- moving_object .base .dimension .height = 1
432
-
433
- moving_object .base .position .x = 0.0 + i
434
- moving_object .base .position .y = 0.0
435
- moving_object .base .position .z = 0.0
436
-
437
- moving_object .base .orientation .roll = 0.0
438
- moving_object .base .orientation .pitch = 0.0
439
- moving_object .base .orientation .yaw = 0.0
440
-
441
- """Serialize"""
442
- bytes_buffer = trafficupdate .SerializeToString ()
443
- f .write (struct .pack ("<L" , len (bytes_buffer )) + bytes_buffer )
444
-
445
- f .close ()
446
-
447
-
448
407
def create_sample_tc (path ):
449
408
f = open (path , "ab" )
450
409
trafficcommand = TrafficCommand ()
@@ -508,6 +467,47 @@ def create_sample_tcu(path):
508
467
f .close ()
509
468
510
469
470
+ def create_sample_tu (path ):
471
+ f = open (path , "ab" )
472
+ trafficupdate = TrafficUpdate ()
473
+
474
+ trafficupdate .version .version_major = 3
475
+ trafficupdate .version .version_minor = 0
476
+ trafficupdate .version .version_patch = 0
477
+
478
+ trafficupdate .timestamp .seconds = 0
479
+ trafficupdate .timestamp .nanos = 0
480
+
481
+ moving_object = trafficupdate .update .add ()
482
+ moving_object .id .value = 114
483
+
484
+ # Generate 10 OSI messages for 9 seconds
485
+ for i in range (10 ):
486
+ # Increment the time
487
+ trafficupdate .timestamp .seconds += 1
488
+ trafficupdate .timestamp .nanos += 100000
489
+
490
+ moving_object .vehicle_classification .type = 2
491
+
492
+ moving_object .base .dimension .length = 5
493
+ moving_object .base .dimension .width = 2
494
+ moving_object .base .dimension .height = 1
495
+
496
+ moving_object .base .position .x = 0.0 + i
497
+ moving_object .base .position .y = 0.0
498
+ moving_object .base .position .z = 0.0
499
+
500
+ moving_object .base .orientation .roll = 0.0
501
+ moving_object .base .orientation .pitch = 0.0
502
+ moving_object .base .orientation .yaw = 0.0
503
+
504
+ """Serialize"""
505
+ bytes_buffer = trafficupdate .SerializeToString ()
506
+ f .write (struct .pack ("<L" , len (bytes_buffer )) + bytes_buffer )
507
+
508
+ f .close ()
509
+
510
+
511
511
def create_sample_mr (path ):
512
512
f = open (path , "ab" )
513
513
motionrequest = MotionRequest ()
0 commit comments