Skip to content

What's going on with rosidl_generator_rs? #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hikari20XX opened this issue Apr 6, 2025 · 5 comments
Open

What's going on with rosidl_generator_rs? #470

hikari20XX opened this issue Apr 6, 2025 · 5 comments

Comments

@hikari20XX
Copy link

Hello!

Sorry if this is a dumb question, but what's going on with rosidl_generator_rs? I've been working creating a bridge for the Blue Robotics Flight Controller (API is written in Rust) for some time now, and while I have a working version using standard message types, I'd really like to implement custom message types to avoid issues with string parsing down the road. However, whenever I try to include rosidl_generator_rs for type support functionality, it can't find the crate and the build fails. Tried following the instructions at the end of the building.md by sourcing the install directory, but no dice. Digging into ~/workspace/install/rosidl_generator_rs/share/rosidl_generator_rs, I can see it's missing the /rust directory (which I was looking for to hard code the path into the Cargo.toml in my custom_msgs directory).

Tl;dr: what's going on with rosidl_generator_rs? Am I just dumb? The basic pub/sub example works for me just fine. If anyone can offer any advice/wisdom, I'd really appreciate it.

@mxgrey
Copy link
Collaborator

mxgrey commented Apr 7, 2025

I also ran into this and it took me an embarrassingly long time to figure out what the problem was despite the fact that I reviewed and approved the PR that led to it.

rosidl_generator_rs has been moved out of the main ros2_rust repo so that we can eventually get it released on the build farm.

All you need to do is use vcs import with the latest repos file and then run colcon build again. Note that rosidl_runtime_rs has also been moved to its own repo.

@mxgrey
Copy link
Collaborator

mxgrey commented Apr 7, 2025

Although what you're describing sounds slightly different than what I experienced.

If you do have rosidl_generator_rs in your workspace, then maybe double-check whether you've installed both colcon-cargo and colcon-ros-cargo.

@hikari20XX
Copy link
Author

Thank you so much, I really appreciate the help. I did double check both colcon-cargo and colcon-ros-cargo were installed (they were), and I tried doing the vcs import again, still to no avail. I'm able to use other bindings fine and build ROS2 packages with cargo just fine, so long as I don't include rosidl_generator_rs.

@mxgrey
Copy link
Collaborator

mxgrey commented Apr 7, 2025

When you say

so long as I don't include rosidl_generator_rs.

Do you mean that inside your Cargo.toml you're doing something like this?

[dependencies]
rosidl_generator_rs = "*"

If that's what you're doing then you should remove that. rosidl_generator_rs is a Python package, not a Rust crate, so cargo doesn't care about it and can't use it.

In fact for your custom message package you shouldn't be using cargo at all. You should just use the typical cmake and package.xml files. As long as you have rosidl_generator_rs in the same workspace as your custom message package, the Rust bindings should get generated.

The auto-generated Rust bindings will produce a Cargo.toml for your message package with the same name as your message package. colcon-ros-cargo will then allow your Rust node to link against the auto-generated Rust bindings for your message package by putting

[dependencies]
my_message_package = "*"

into the Cargo.toml of your Rust node.

@hikari20XX
Copy link
Author

That is precisely what I was doing. I'm not sure when, but some point awhile ago I stopped using colcon and have just been using cargo. I'll give it another go! Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants