Skip to content

Commit ceeb575

Browse files
committed
Add missing trace file prefix adjust to common order
Fixes #816. Signed-off-by: Pierre R. Mai <[email protected]>
1 parent af72665 commit ceeb575

File tree

3 files changed

+125
-113
lines changed

3 files changed

+125
-113
lines changed

doc/architecture/trace_file_naming.adoc

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,35 @@ The names of OSI trace files should have the following format:
1414

1515
**Types**
1616

17-
`sd`::
18-
Trace file contains `SensorData` messages.
19-
2017
`sv`::
2118
Trace file contains `SensorView` messages.
2219

20+
`svc`::
21+
Trace file contains `SensorViewConfiguration` messages.
22+
2323
`gt`::
2424
Trace file contains `GroundTruth` messages.
2525

26-
`tu`::
27-
Trace file contains `TrafficUpdate` messages.
26+
`hvd`::
27+
Trace file contains `HostVehicleData` messages.
28+
29+
`sd`::
30+
Trace file contains `SensorData` messages.
2831

2932
`tc`::
3033
Trace file contains `TrafficCommand` messages.
3134

32-
`hvd`::
33-
Trace file contains `HostVehicleData` messages.
35+
`tcu`::
36+
Trace file contains `TrafficCommandUpdate` messages.
37+
38+
`tu`::
39+
Trace file contains `TrafficUpdate` messages.
40+
41+
`mr`::
42+
Trace file contains `MotionRequest` messages.
43+
44+
`su`::
45+
Trace file contains `StreamingUpdate` messages.
3446

3547
**Example**
3648

osi3trace/osi_trace.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66
import struct
77

88
from osi3.osi_sensorview_pb2 import SensorView
9+
from osi3.osi_sensorviewconfiguration_pb2 import SensorViewConfiguration
910
from osi3.osi_groundtruth_pb2 import GroundTruth
1011
from osi3.osi_hostvehicledata_pb2 import HostVehicleData
1112
from osi3.osi_sensordata_pb2 import SensorData
12-
from osi3.osi_sensorviewconfiguration_pb2 import SensorViewConfiguration
13-
from osi3.osi_trafficupdate_pb2 import TrafficUpdate
1413
from osi3.osi_trafficcommand_pb2 import TrafficCommand
1514
from osi3.osi_trafficcommandupdate_pb2 import TrafficCommandUpdate
15+
from osi3.osi_trafficupdate_pb2 import TrafficUpdate
1616
from osi3.osi_motionrequest_pb2 import MotionRequest
1717
from osi3.osi_streamingupdate_pb2 import StreamingUpdate
1818

1919

2020
MESSAGES_TYPE = {
2121
"SensorView": SensorView,
22+
"SensorViewConfiguration": SensorViewConfiguration,
2223
"GroundTruth": GroundTruth,
2324
"HostVehicleData": HostVehicleData,
2425
"SensorData": SensorData,
25-
"SensorViewConfiguration": SensorViewConfiguration,
26-
"TrafficUpdate": TrafficUpdate,
2726
"TrafficCommand": TrafficCommand,
2827
"TrafficCommandUpdate": TrafficCommandUpdate,
28+
"TrafficUpdate": TrafficUpdate,
2929
"MotionRequest": MotionRequest,
3030
"StreamingUpdate": StreamingUpdate,
3131
}

tests/test_osi_trace.py

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
from osi3trace.osi_trace import OSITrace
66
from osi3.osi_sensorview_pb2 import SensorView
7+
from osi3.osi_sensorviewconfiguration_pb2 import SensorViewConfiguration
78
from osi3.osi_groundtruth_pb2 import GroundTruth
89
from osi3.osi_hostvehicledata_pb2 import HostVehicleData
910
from osi3.osi_sensordata_pb2 import SensorData
10-
from osi3.osi_sensorviewconfiguration_pb2 import SensorViewConfiguration
11-
from osi3.osi_trafficupdate_pb2 import TrafficUpdate
1211
from osi3.osi_trafficcommand_pb2 import TrafficCommand
1312
from osi3.osi_trafficcommandupdate_pb2 import TrafficCommandUpdate
13+
from osi3.osi_trafficupdate_pb2 import TrafficUpdate
1414
from osi3.osi_motionrequest_pb2 import MotionRequest
1515
from 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+
260285
def 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-
448407
def 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+
511511
def create_sample_mr(path):
512512
f = open(path, "ab")
513513
motionrequest = MotionRequest()

0 commit comments

Comments
 (0)