44
55from osi3trace .osi_trace import OSITrace
66from osi3 .osi_sensorview_pb2 import SensorView
7+ from osi3 .osi_sensorviewconfiguration_pb2 import SensorViewConfiguration
78from osi3 .osi_groundtruth_pb2 import GroundTruth
89from osi3 .osi_hostvehicledata_pb2 import HostVehicleData
910from osi3 .osi_sensordata_pb2 import SensorData
10- from osi3 .osi_sensorviewconfiguration_pb2 import SensorViewConfiguration
11- from osi3 .osi_trafficupdate_pb2 import TrafficUpdate
1211from osi3 .osi_trafficcommand_pb2 import TrafficCommand
1312from osi3 .osi_trafficcommandupdate_pb2 import TrafficCommandUpdate
13+ from osi3 .osi_trafficupdate_pb2 import TrafficUpdate
1414from osi3 .osi_motionrequest_pb2 import MotionRequest
1515from osi3 .osi_streamingupdate_pb2 import StreamingUpdate
1616
@@ -35,6 +35,23 @@ def test_osi_trace_sv(self):
3535
3636 self .assertTrue (os .path .exists (path_output ))
3737
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+
3855 def test_osi_trace_gt (self ):
3956 with tempfile .TemporaryDirectory () as tmpdirname :
4057 path_output = os .path .join (tmpdirname , "output_gt.txth" )
@@ -86,40 +103,6 @@ def test_osi_trace_sd(self):
86103
87104 self .assertTrue (os .path .exists (path_output ))
88105
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-
123106 def test_osi_trace_tc (self ):
124107 with tempfile .TemporaryDirectory () as tmpdirname :
125108 path_output = os .path .join (tmpdirname , "output_tc.txth" )
@@ -154,6 +137,23 @@ def test_osi_trace_tcu(self):
154137
155138 self .assertTrue (os .path .exists (path_output ))
156139
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+
157157 def test_osi_trace_mr (self ):
158158 with tempfile .TemporaryDirectory () as tmpdirname :
159159 path_output = os .path .join (tmpdirname , "output_mr.txth" )
@@ -257,6 +257,31 @@ def create_sample_sv(path):
257257 f .close ()
258258
259259
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+
260285def create_sample_gt (path ):
261286 f = open (path , "ab" )
262287 ground_truth = GroundTruth ()
@@ -379,72 +404,6 @@ def create_sample_sd(path):
379404 f .close ()
380405
381406
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-
448407def create_sample_tc (path ):
449408 f = open (path , "ab" )
450409 trafficcommand = TrafficCommand ()
@@ -508,6 +467,47 @@ def create_sample_tcu(path):
508467 f .close ()
509468
510469
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+
511511def create_sample_mr (path ):
512512 f = open (path , "ab" )
513513 motionrequest = MotionRequest ()
0 commit comments