Skip to content
This repository was archived by the owner on Mar 31, 2024. It is now read-only.

Start creating a Python ROS2 bridge#2

Merged
phil-opp merged 35 commits intomainfrom
python-ros2-bridge
Jul 21, 2023
Merged

Start creating a Python ROS2 bridge#2
phil-opp merged 35 commits intomainfrom
python-ros2-bridge

Conversation

@phil-opp
Copy link
Contributor

@phil-opp phil-opp commented Jul 5, 2023

  • Make compile-time ROS2 message generation optional
    • We will ship a prebuilt version of the dora-ros2-bridge crate via pip, so we don't want to generate the ROS2 message structs at build time.
    • Instead, we will create the message structs at runtime, using the separate msg-gen crate that was created in Split parsing into separate crate #1.
  • Create a new dora-ros2-bridge-python crate that uses maturin and pyo3 to be usable from Python.
    • The crate depends on dora-ros2-bridge without default features, i.e. without compile-time ROS2 message generation.
  • Provide Python-compatible wrapper types for creating nodes, publishers, subscribers, and QoS settings.
  • Experiment with dynamically-typed messages using the pythonize crate.
    • Unfortunately, this doesn't seem to work. The ROS2 CDR serialization format does not encode type information, so we have to know the target type in order to deserialize a message.
    • For publishing messages, it seems like invalid messages are silently ignored, which makes debugging difficult. So for static message types are preferable for publishing too.

phil-opp added 30 commits July 5, 2023 15:31
The encoding of the CDR format is different for different data types. For example, structs are encoded differently than maps. Since Python does not provide native equivalents to all CDR types, we need to some type conversion to the type specified in the `msg` files.

This commit starts implementing such a system through a new `TypeInfo` enum, which we will generate from the ROS2 msg files at runtime. For serialization, we now use a custom `TypedValue` type that calls the correct `serialize_x` functions of serde.
Also: implement f64 support to support Twist message.
ROS2/DDS seems to require a specific type name format for messages.
There is no need for the input data to live exactly as long as the deserializer.
Allows us to reuse the structs for a DeserializeSeed implementation in the future.
This makes it easier to support DeserializeSeed-based deserialization.
This way we don't need to specify the bound everywhere.
@phil-opp
Copy link
Contributor Author

I moved out the ros2-client and rustdds changes into separate crates. The plan is to upstream some or all of these updates. Relevant PRs:

@phil-opp phil-opp marked this pull request as ready for review July 21, 2023 11:12
@phil-opp phil-opp requested a review from haixuanTao July 21, 2023 11:12
@phil-opp
Copy link
Contributor Author

Given that it might take some time until the upstream changes are merged, I don't think that we should wait for it. The dora-ros2-bridge is still experimental anyway, so having some temporary git dependencies in it would be fine with me. What do you think @haixuanTao ?

@haixuanTao
Copy link
Contributor

I see. Sure. Having git dependenccy in the Cargo.toml is totally fine.

@phil-opp
Copy link
Contributor Author

Ok great! Do you want to do a quick review or are you fine with merging this as-is?

@haixuanTao
Copy link
Contributor

I'm okay with merging this as is, as there is not a lot history to begin with.

I'll test maybe later if that's ok!

@phil-opp phil-opp merged commit d152ee3 into main Jul 21, 2023
@phil-opp phil-opp deleted the python-ros2-bridge branch July 21, 2023 12:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants