Announcing ros-env: Access ROS 2 messages from Rust with just Cargo

Hey all! I’m one of the maintainers of ros2_rust, and we recently released a new crate, ros-env, that aims to unify ROS 2 message consumption in Rust.

If you’re already generating Rust code for your message interfaces with rosidl_generator_rs, you can add ros-env as a regular Cargo dependency and access the message types from any packages in your sourced ROS 2 environment.

// Assuming the Rust crate for `shape_msgs` is in `AMENT_PREFIX_PATH`
use ros_env::shape_msgs::msg::Plane;

You don’t need Colcon, and you don’t need to use ros2_rust. The goal is to provide a common way for Rust ROS 2 clients to consume and share message definitions.

Happy to answer any questions!

1 Like