Skip to content
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

Cargo can't find Std_msgs #374

Open
Guelakais opened this issue Mar 19, 2024 · 6 comments
Open

Cargo can't find Std_msgs #374

Guelakais opened this issue Mar 19, 2024 · 6 comments

Comments

@Guelakais
Copy link
Contributor

I followed your example This gave me the following error output:

Updating crates.io index
error: no matching package named `std_msgs` found
location searched: registry `crates-io`
required by package `position_printer_rs v0.1.0 (/ros_ws/src/position_printer_rs)`

Here you can see my current status for comparison.

@mxgrey
Copy link
Collaborator

mxgrey commented Mar 19, 2024

Thanks for reporting this problem.

We should fix the instructions to say that you should build your package in the same colcon workspace that rclrs and your message packages were built in according to the README instructions.

Ideally it should be possible to build your package in a separate colcon workspace with the original workspace as an underlay, but I just tested it out and it seems there's a bug in colcon-cargo that currently prevents that from working. I'll try to investigate that problem.

@Guelakais
Copy link
Contributor Author

Thank you for your reply. I don't know how to add the appropriate commands to my docker file. That's what you want me to do, isn't it?

git clone https://github.com/ros2-rust/ros2_rust.git src/ros2_rust
vcs import src < src/ros2_rust/ros2_rust_humble.repos
. /opt/ros/humble/setup.sh
colcon build

Perhaps the Docker Forum can help. I'll give it a try.

@Guelakais
Copy link
Contributor Author

yeah, it doesn't work.

@hikari20XX
Copy link

hikari20XX commented Apr 25, 2024

I also ran into this problem, managed to get around it by including the path in the dependency section of my Cargo.toml (without building ros2_rust in the same directory as my project), for example: std_msgs = { path = "/home/newton/workspace/install/std_msgs/share/std_msgs/rust" } and also including it in my package.xml (not the whole path just std_msgs). Hope this helps!!

@Guelakais
Copy link
Contributor Author

Yes, in the meantime I've also been working a bit with the manifest format of rust and therefore now know that it can work like this. My personal problem with this approach is that you cannot publish the package in this way, neither on crates nor on gitlab, as it is already a very individually functioning thing.

@hikari20XX
Copy link

I see what you mean, it's definitely not an end-all fix. I tinkered for a bit exploring for the root of the problem, the best hypothesis I could come up with is that rosidl_generator_rs isn't generating bindings correctly (could be a couple causes for that). std_msgs is handled through the ROS2 build system (not Cargo), so rosidl_generator_rs generates the Rust bindings for the ROS2 packages, allowing for them to be used in Rust code. Once the bindings are generated, then the types defined in ROS2 packages can be imported as modules; the catch being that the modules only exist after the bindings have been generated, and won't be known to Rust or Cargo until then. What's probably happening is that rosidl_generator_rs isn't properly set up or not generating bindings as expected. How to remedy this is still beyond me, but will definitely report back if I find out anything more. Good luck with your project in the meantime!

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

3 participants