Skip to content

Commit 52710bc

Browse files
authored
Merge pull request #720 from OpenSimulationInterface/719-other-structure-for-usage-examples-needed-in-readme-and-docu
Links in README and example moved to docu
2 parents 86b29be + 21d231f commit 52710bc

File tree

4 files changed

+88
-71
lines changed

4 files changed

+88
-71
lines changed

README.md

Lines changed: 7 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,18 @@ The Open Simulation Interface <sup>[[1]](https://www.hot.ei.tum.de/forschung/aut
77

88
As the complexity of automated driving functions rapidly increases, the requirements for test and development methods are growing. Testing in virtual environments offers the advantage of completely controlled and reproducible environment conditions.
99

10-
For more information on OSI see the [official documentation](https://opensimulationinterface.github.io/osi-documentation/) or the [official reference documentation](https://opensimulationinterface.github.io/open-simulation-interface/) for defined protobuf messages.
11-
12-
<!-- TODO: Update with new Antora hosting -->
10+
For more information on OSI see the [official documentation](https://opensimulationinterface.github.io/osi-antora-generator/asamosi/latest/specification/index.html) or the [class list](https://opensimulationinterface.github.io/osi-antora-generator/asamosi/latest/gen/annotated.html) for defined protobuf messages.
1311

1412
[1] Hanke, T., Hirsenkorn, N., van-Driesten, C., Garcia-Ramos, P., Schiementz, M., Schneider, S. & Biebl, E. (2017, February 03). *A generic interface for the environment perception of automated driving functions in virtual scenarios.* Retrieved January 25, 2020, from https://www.hot.ei.tum.de/forschung/automotive-veroeffentlichungen/
1513

1614
## Usage
17-
##### Example of generating OSI messages in `Python`
18-
```python
19-
# generate_osi_messages.py
20-
from osi3.osi_sensorview_pb2 import SensorView
21-
import struct
22-
23-
NANO_INCREMENT = 10000000
24-
MOVING_OBJECT_LENGTH = 5
25-
MOVING_OBJECT_WIDTH = 2
26-
MOVING_OBJECT_HEIGHT = 1
27-
28-
def main():
29-
"""Initialize SensorView"""
30-
f = open("sv_330_361_1000_movingobject.osi", "ab")
31-
sensorview = SensorView()
32-
33-
sv_ground_truth = sensorview.global_ground_truth
34-
sv_ground_truth.version.version_major = 3
35-
sv_ground_truth.version.version_minor = 5
36-
sv_ground_truth.version.version_patch = 0
37-
38-
sv_ground_truth.timestamp.seconds = 0
39-
sv_ground_truth.timestamp.nanos = 0
40-
41-
moving_object = sv_ground_truth.moving_object.add()
42-
moving_object.id.value = 42
43-
44-
# Generate 1000 OSI messages for a duration of 10 seconds
45-
for i in range(1000):
46-
47-
# Increment the time
48-
if sv_ground_truth.timestamp.nanos > 1000000000:
49-
sv_ground_truth.timestamp.seconds += 1
50-
sv_ground_truth.timestamp.nanos = 0
51-
sv_ground_truth.timestamp.nanos += NANO_INCREMENT
52-
53-
moving_object.vehicle_classification.type = 2
54-
55-
moving_object.base.dimension.length = MOVING_OBJECT_LENGTH
56-
moving_object.base.dimension.width = MOVING_OBJECT_WIDTH
57-
moving_object.base.dimension.height = MOVING_OBJECT_HEIGHT
58-
59-
moving_object.base.position.x += 0.5
60-
moving_object.base.position.y = 0.0
61-
moving_object.base.position.z = 0.0
62-
63-
moving_object.base.orientation.roll = 0.0
64-
moving_object.base.orientation.pitch = 0.0
65-
moving_object.base.orientation.yaw = 0.0
66-
67-
"""Serialize"""
68-
bytes_buffer = sensorview.SerializeToString()
69-
f.write(struct.pack("<L", len(bytes_buffer)))
70-
f.write(bytes_buffer)
71-
72-
f.close()
73-
74-
if __name__ == "__main__":
75-
main()
76-
```
77-
78-
To run the script execute the following command in the terminal:
79-
```bash
80-
python3 generate_osi_messages.py
81-
```
82-
83-
This will output an osi file (`sv_330_361_1000_movingobject.osi`) which can be visualized and played back by the [osi-visualizer](https://github.com/OpenSimulationInterface/osi-visualizer).
15+
For usage examples, please refer to the official documentation:
16+
- [Trace file generation with python](https://opensimulationinterface.github.io/osi-antora-generator/asamosi/latest/interface/architecture/trace_file_example.html)
17+
- [OSMP examples](https://opensimulationinterface.github.io/osi-antora-generator/asamosi/latest/sensor-model/setup/build_install_example.html), including the code found at [osi-sensor-model-packaging](https://github.com/OpenSimulationInterface/osi-sensor-model-packaging):
18+
- [OSMPDummySource](https://github.com/OpenSimulationInterface/osi-sensor-model-packaging/tree/master/examples/OSMPDummySource)
19+
- [OSMPDummySensor](https://github.com/OpenSimulationInterface/osi-sensor-model-packaging/tree/master/examples/OSMPDummySensor)
20+
- [OSMPCNetworkProxy](https://github.com/OpenSimulationInterface/osi-sensor-model-packaging/tree/master/examples/OSMPCNetworkProxy)
8421

85-
See Google's documentation for more tutorials on how to use protocol buffers with [Python](https://developers.google.com/protocol-buffers/docs/pythontutorial) or [C++](https://developers.google.com/protocol-buffers/docs/cpptutorial).
8622
## Installation
8723
##### Dependencies
8824
Install `cmake` 3.10.2:

doc/_config.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ ifndef::include-only-once[]
4141
// Please note that this variable has to used in all image includes. Includes here have to use "image::./images..."
4242
// :images_osi_sensor_model_packaging: ./osi-sensor-model-packaging/doc/images // example
4343
:imagesoutdir: ./images/generated_images
44+
4445
endif::[]
4546
ifndef::use-antora-rules[]
4647
include::{asciidoc-resources}/preamble.adoc[]
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
ifndef::include-only-once[]
2+
:root-path: ../
3+
include::{root-path}_config.adoc[]
4+
endif::[]
5+
[#top-osi_trace_file_example]
6+
= OSI trace file example
7+
8+
[source, python]
9+
----
10+
# generate_osi_messages.py
11+
from osi3.osi_sensorview_pb2 import SensorView
12+
import struct
13+
14+
NANO_INCREMENT = 10000000
15+
MOVING_OBJECT_LENGTH = 5
16+
MOVING_OBJECT_WIDTH = 2
17+
MOVING_OBJECT_HEIGHT = 1
18+
19+
def main():
20+
"""Initialize SensorView"""
21+
f = open("sv_330_361_1000_movingobject.osi", "ab")
22+
sensorview = SensorView()
23+
24+
sv_ground_truth = sensorview.global_ground_truth
25+
sv_ground_truth.version.version_major = 3
26+
sv_ground_truth.version.version_minor = 5
27+
sv_ground_truth.version.version_patch = 0
28+
29+
sv_ground_truth.timestamp.seconds = 0
30+
sv_ground_truth.timestamp.nanos = 0
31+
32+
moving_object = sv_ground_truth.moving_object.add()
33+
moving_object.id.value = 42
34+
35+
# Generate 1000 OSI messages for a duration of 10 seconds
36+
for i in range(1000):
37+
38+
# Increment the time
39+
if sv_ground_truth.timestamp.nanos > 1000000000:
40+
sv_ground_truth.timestamp.seconds += 1
41+
sv_ground_truth.timestamp.nanos = 0
42+
sv_ground_truth.timestamp.nanos += NANO_INCREMENT
43+
44+
moving_object.vehicle_classification.type = 2
45+
46+
moving_object.base.dimension.length = MOVING_OBJECT_LENGTH
47+
moving_object.base.dimension.width = MOVING_OBJECT_WIDTH
48+
moving_object.base.dimension.height = MOVING_OBJECT_HEIGHT
49+
50+
moving_object.base.position.x += 0.5
51+
moving_object.base.position.y = 0.0
52+
moving_object.base.position.z = 0.0
53+
54+
moving_object.base.orientation.roll = 0.0
55+
moving_object.base.orientation.pitch = 0.0
56+
moving_object.base.orientation.yaw = 0.0
57+
58+
"""Serialize"""
59+
bytes_buffer = sensorview.SerializeToString()
60+
f.write(struct.pack("<L", len(bytes_buffer)))
61+
f.write(bytes_buffer)
62+
63+
f.close()
64+
65+
if __name__ == "__main__":
66+
main()
67+
----
68+
69+
To run the script execute the following command in the terminal:
70+
71+
[source, bash]
72+
----
73+
python3 generate_osi_messages.py
74+
----
75+
76+
This will output an osi file (`sv_330_361_1000_movingobject.osi`) which can be visualized and played back by the https://github.com/OpenSimulationInterface/osi-visualizer[osi-visualizer^].
77+
78+
See Google's documentation for more tutorials on how to use protocol buffers with https://developers.google.com/protocol-buffers/docs/pythontutorial[Python^] or https://developers.google.com/protocol-buffers/docs/cpptutorial[C++^].

doc/open-simulation-interface_user_guide.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ include::./architecture/trace_file_naming.adoc[leveloffset=+3]
6767

6868
// include::./architecture/test_scripts.adoc[leveloffset=+3]
6969

70+
include::./architecture/trace_file_example.adoc[leveloffset=+3]
71+
7072
include::./architecture/formatting_scripts.adoc[leveloffset=+3]
7173

7274
== Setting up OSI

0 commit comments

Comments
 (0)