https://github.com/ika-rwth-aachen/betterosi
betterosi - a python library for reading and writing open-simulation-interface files using betterproto2
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 2 committers (100.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.8%) to scientific vocabulary
Repository
betterosi - a python library for reading and writing open-simulation-interface files using betterproto2
Basic Info
- Host: GitHub
- Owner: ika-rwth-aachen
- License: mpl-2.0
- Language: Python
- Default Branch: main
- Size: 854 KB
Statistics
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
betterosi - a python library for reading and writing open-simulation-interface files using betterproto2
A python library for reading and writing ASAM OSI (Open-Simulation-Interace) files (either .osi binary traces or MCAP files) using betterproto2 instead of the default protobuf generated code (better typing and enum support).
- Supports writing and reading either mcap or osi files with
betterosi.Writerandbetterosi.read. - View OSI or MCAP file containing OSI GroundTruth
betterosi-viewer <filepath.mcap / filepath.osi>(adapted from esmini) - Convert osi to mcap with
betterosi-to-mcap <filepath to osi>.
The library uses code from esmini (betterosi/viewer.py) under MPL 2.0 license and the code from open-simulation-interface to read osi traces (betterosi/osi3trace.py).
The library uses code generation of python-betterproto2-compiler to generate python code from the protobuf definitions of open-simulation-interface.
Since OSI and esmini are under MPL, also this repository is published under MPL-2.0 license.
Differences to OSI 3.7.0
The proto definitions extend the OSI 3.7.0 definitions in the following ways:
- Add MapAsamOpenDrive Message: Packages the XML content of an ASAM OpenDRIVE map in a proto Message
See omega-prime for details.
Install
pip install betterosi
Create an OSI or MCAP trace
To create an OSI or MCAP trace, you need to use betterosi.Writer. After creating the OSI Message of your desire, just add it to the Writer as shown in the examples below for either MCAP traaces or OSI traces.
```python import betterosi
with betterosi.Writer('test.mcap') as writer: gt = betterosi.GroundTruth(...) writer.add(gt)
with betterosi.Writer('test.osi') as writer: sv = betterosi.SensorView(...) writer.add(sv) ```
Below a full example is given which creates three files, and MCAP trace and and OSI trace with GroundTruth messages and a MCAP trace of SensorViews. If you use the code, you obviously just need one of the writers.
```python import betterosi NANOSPERSEC = 1000000_000
with betterosi.Writer('test.mcap') as writermcap, betterosi.Writer('test.osi') as writerosi, betterosi.Writer('testsv.mcap') as writersv: movingobject = betterosi.MovingObject(id=betterosi.Identifier(value=42), type = betterosi.MovingObjectType.TYPEUNKNOWN, base=betterosi.BaseMoving( dimension= betterosi.Dimension3D(length=5, width=2, height=1), position = betterosi.Vector3D(x=0, y=0, z=0), orientation = betterosi.Orientation3D(roll = 0.0, pitch = 0.0, yaw = 0.0), velocity = betterosi.Vector3D(x=1, y=0, z=0) )) gt = betterosi.GroundTruth( version=betterosi.InterfaceVersion(versionmajor= 3, versionminor=7, versionpatch=0), timestamp=betterosi.Timestamp(seconds=0, nanos=0), movingobject=[ movingobject ], hostvehicleid=betterosi.Identifier(value=0) ) sv = betterosi.SensorView( version=betterosi.InterfaceVersion(versionmajor= 3, versionminor=7, versionpatch=0), timestamp=betterosi.Timestamp(seconds=0, nanos=0), globalgroundtruth=gt, hostvehicleid=betterosi.Identifier(value=0) ) # Generate 1000 OSI messages for a duration of 10 seconds for i in range(1000): totalnanos = i0.01NANOSPERSEC gt.timestamp.seconds = int(totalnanos // NANOSPERSEC) gt.timestamp.nanos = int(totalnanos % NANOSPERSEC) movingobject.base.position.x += 0.5 sv.timestamp = gt.timestamp
writer_mcap.add(gt)
writer_osi.add(gt)
writer_sv.add(sv)
```
When writing MCAP messages you can specifiy the topic in the writer and the add function by setting the topic argument. When reading such files, set the argument mcap_topic to the same string.
Read OSI and MCAP
With betterosi.read you can read an mcap or osi trace. read returns a generator. With the following code, you can get a list of the GroundTruth messages from a trace, even if the GroundTruth are nested inside SensorViews. It works the same for OSI traces.
python
import betterosi
ground_truths = list(betterosi.read('test_sv.mcap', return_ground_truth=True))
print([len(ground_truths), ground_truths[0]])
Above code prints the following:
<!--pytest-codeblocks:expected-output-->
[1000, GroundTruth(version=InterfaceVersion(version_major=3, version_minor=7), timestamp=Timestamp(), host_vehicle_id=Identifier(), moving_object=[MovingObject(id=Identifier(value=42), base=BaseMoving(dimension=Dimension3D(length=5.0, width=2.0, height=1.0), position=Vector3D(x=0.5), orientation=Orientation3D(), velocity=Vector3D(x=1.0)))])]
If you want a list of the sensor views directly:
python
import betterosi
sensor_views = betterosi.read('test_sv.mcap', return_sensor_view=True)
print(next(sensor_views))
The above prints:
<!--pytest-codeblocks:expected-output-->
SensorView(version=InterfaceVersion(version_major=3, version_minor=7), timestamp=Timestamp(), global_ground_truth=GroundTruth(version=InterfaceVersion(version_major=3, version_minor=7), timestamp=Timestamp(), host_vehicle_id=Identifier(), moving_object=[MovingObject(id=Identifier(value=42), base=BaseMoving(dimension=Dimension3D(length=5.0, width=2.0, height=1.0), position=Vector3D(x=0.5), orientation=Orientation3D(), velocity=Vector3D(x=1.0)))]), host_vehicle_id=Identifier())
If you want to read any OSI trace, you just need to give the filename.
python
import betterosi
any_osi_message = betterosi.read('test.osi')
any_osi_message = betterosi.read('test.mcap')
Generate library code
pip install grpcio-tools git+https://github.com/MichaelSchuldes/python-betterproto2-compiler@serialized_descriptors
cd into osi-proto and run the following command to generate the code
``` cd osi-proto
mkdir ../betterosi/generated
python -m grpctools.protoc -I . --pythonbetterproto2out=../betterosi/generated osicommon.proto osidatarecording.proto osidetectedlane.proto osidetectedobject.proto osidetectedoccupant.proto osidetectedroadmarking.proto osidetectedtrafficlight.proto osidetectedtrafficsign.proto osienvironment.proto osifeaturedata.proto osigroundtruth.proto osihostvehicledata.proto osilane.proto osilogicaldetectiondata.proto osilogicallane.proto osimotionrequest.proto osiobject.proto osioccupant.proto osireferenceline.proto osiroadmarking.proto osiroute.proto osisensordata.proto osisensorspecific.proto osisensorview.proto osisensorviewconfiguration.proto osistreamingupdate.proto ositrafficcommand.proto ositrafficcommandupdate.proto ositrafficlight.proto ositrafficsign.proto ositrafficupdate.proto osiversion.proto osimapasamopendrive.proto ```
LICENSE and Copyright
This code is published under MPL-2.0 license. It utilizes and modifies parts of esmini (betterosi/viewer.py) under MPL-2.0 and open-simulation-interface (osi-proto/* and betterosi/osi3trace.py) under MPL-2.0.
Acknowledgements
This package is developed as part of the SYNERGIES project.
Funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or European Climate, Infrastructure and Environment Executive Agency (CINEA). Neither the European Union nor the granting authority can be held responsible for them.
Owner
- Name: Institut für Kraftfahrzeuge, RWTH Aachen, ika
- Login: ika-rwth-aachen
- Kind: organization
- Location: Aachen, Germany
- Website: https://www.ika.rwth-aachen.de
- Repositories: 16
- Profile: https://github.com/ika-rwth-aachen
GitHub Events
Total
- Issues event: 1
- Watch event: 2
- Delete event: 2
- Member event: 2
- Push event: 17
- Fork event: 1
- Create event: 5
Last Year
- Issues event: 1
- Watch event: 2
- Delete event: 2
- Member event: 2
- Push event: 17
- Fork event: 1
- Create event: 5
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Michael Schuldes | m****s@i****e | 29 |
| Stamatios Chrysanthidis | s****s@i****e | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- MSSandroid (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 399 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 7
- Total maintainers: 2
pypi.org: betterosi
betterosi - a python library for reading and writing open-simulation-interface files using betterproto2
- Homepage: https://github.com/ika-rwth-aachen/betterosi
- Documentation: https://betterosi.readthedocs.io/
- License: MPL-2.0
-
Latest release: 0.5.1
published about 1 year ago
Rankings
Maintainers (2)
Dependencies
- betterproto2 ==0.3.1
- betterproto2-rust-codec *
- matplotlib *
- mcap *
- mcap-protobuf-support *
- numpy *
- protobuf *
- tqdm *
- typer *
- betterproto2 ==0.3.1
- betterproto2-rust-codec ==0.1.3
- click ==8.1.8
- colorama ==0.4.6
- contourpy ==1.3.1
- cycler ==0.12.1
- fonttools ==4.56.0
- kiwisolver ==1.4.8
- lz4 ==4.4.3
- markdown-it-py ==3.0.0
- matplotlib ==3.10.1
- mcap ==1.2.2
- mcap-protobuf-support ==0.5.3
- mdurl ==0.1.2
- numpy ==2.2.3
- packaging ==24.2
- pillow ==11.1.0
- protobuf ==6.30.0
- pygments ==2.19.1
- pyparsing ==3.2.1
- python-dateutil ==2.9.0.post0
- rich ==13.9.4
- shellingham ==1.5.4
- six ==1.17.0
- tqdm ==4.67.1
- typer ==0.15.2
- typing-extensions ==4.12.2
- zstandard ==0.23.0
- betterosi 0.3.2
- betterproto2 0.3.1
- betterproto2-rust-codec 0.1.3
- cffi 1.17.1
- click 8.1.8
- colorama 0.4.6
- contourpy 1.3.1
- cycler 0.12.1
- fonttools 4.56.0
- kiwisolver 1.4.8
- lz4 4.4.3
- markdown-it-py 3.0.0
- matplotlib 3.10.0
- mcap 1.2.2
- mcap-protobuf-support 0.5.3
- mdurl 0.1.2
- numpy 2.2.2
- packaging 24.2
- pillow 11.1.0
- protobuf 5.29.3
- pycparser 2.22
- pygments 2.19.1
- pyparsing 3.2.1
- python-dateutil 2.9.0.post0
- rich 13.9.4
- shellingham 1.5.4
- six 1.17.0
- tqdm 4.67.1
- typer 0.15.1
- typing-extensions 4.12.2
- zstandard 0.23.0