Proposal: Rust Working Group for ROS

This would be great. We use ROS 1 at work and are looking at ROS 2. As for building https://github.com/AndrewGaspar/corrosion/ is very close to working with catkin on ROS 1. It wouldn’t take much to make it work with ament.

1 Like

@jhdcs I haven’t tried rust-analyzer with rclrs yet but does settings rust-analyzer.cargo.loadOutDirsFromCheck and rust-analyzer.procMacro.enable help? If not please file an issue with a simple test case and I can take a look at it.

A bit relevant: This reminded me about the recent improvements around const-generics this year:

https://without.boats/blog/shipping-const-generics/

For those who don’t know, const generics refers to generics that are constant values, rather than types. This allows types to be parameterized by, for example, specific integer values. In stable Rust, only the special array type - [T; N] - has a const parameter (the length of the array), and there is no way to be abstract over all values of N , even for arrays. Const generics will allow creating new types parameterized by values, as well as implementing traits and functions that are abstract over those values.

This might be useful for IDL fields that are array types of fixed lengths. I’m not sure it would have much of an advantage over vectors with primitive values, but perhaps still advantageous for more advance or nested message types.

1 Like

Hi everyone!
I’m interested. I would like to join the meeting but I’m not able to find the meeting link.

This is cool! I must admit I haven’t played around with Ros yet, but I certainly will vouch for Rust for complex projects where safety and performance are top on the list. For those who are on the fence with Rust (as I was two years ago), you need to try it out. It took me a project or two to “get it”, but once that happens you need to work quite hard to avoid looking like a fanatic. :slight_smile:

DDS is a great way to build a data-oriented system which I think is the essence of a distributed system, but I guess I’m preaching to the choir here. CycloneDDS is my favourite implementation as it is small, performs well and it is written in C, allowing easy bindings to other languages. I’m eagerly awaiting version 1.0.

Rust is great and Cargo makes it complete. It is amazing to see how Cargo is used to put together an easy to use build environment with access to lots of packages. The cyclonedds Rust binding allows you to put interfaces into their own crate. Publishing and using interfaces becomes as easy as importing the interface crate in the Cargo.toml. You also get semantic versioning for the interfaces.

Thank you @joespeed for the links!

What is a good weekend project to try out Ros2?

Cheers!

I think the best way to get started with Ros2 is to work through the tutorials. They’ll get you up and running and trying out (admittedly simple) cases. If you run into trouble, feel free to shoot me a message, I can try and smooth things over. I’m sure several others around here will help too, but I’ll let them decide if they want to do that via message or not. Alternatively, you can post your question in Ros Answers, and let the community respond.

I just checked both those options (thanks for the suggestion!), but they didn’t help.

I think the root of the problem is that std_msgs is not exactly a crate. It’s a bunch of .msg files that define message types that can be passed between ROS 2 nodes, and Rust-Analyzer has no idea how to parse that. Not that I would expect it to - It’s not Rust! But we should probably figure out a way for these files to be, I guess, interpreted? Make them recognizable as types, so that we get Rust’s safety guarantees on them.

The std_msgs code is here: https://github.com/ros2/common_interfaces/tree/foxy/std_msgs.

1 Like

Okay! So you need to enable the options I mentioned and then if you look at the CMakeLists.txt in the rclrs_examples you’ll notice that they copy the Cargo.toml to ${CMAKE_BINARY_DIR} and then append a bunch of crates including std_msgs. If you open THAT directory (/opt/overlay_ws/build/rclrs_examples/ in the build docker container) then rust-analyzer will be able to find the messages in rclrs_publisher.rs and rclrs_subscriber.rs. This certainly isn’t ideal but it does give you all the rust-analyzer goodies.

https://github.com/adnanademovic/rosrust handles this much better since it’s pure rust. I’ll have to read up on ament/colcon and understand why corrosion wouldn’t work since it does with catkin (though you need to copy some files in your CMakeLists.txt).

I am curious about building robotics projects using Rust. I tried the matrix link and it no longer seems live. Are there still some using that channel to chat about this?

Element seems to have deprecated the “community” feature for an newer form of room aggregation. However the original matrix room still persists, and remains active today:

1 Like

Responding to this ancient thread. Today we discussed this PR on parameters: Add preliminary support for parameters by luca-della-vedova · Pull Request #332 · ros2-rust/ros2_rust · GitHub

  • ros2_rust aims to be a first-class part of ROS and that means in areas where we change the API from what is in rclcpp / rclpy we try to contribute those design changes to the other client libraries.
  • ros2_rust should try to use the features of rust to have good ergonomics but not deviate too far from the other client libraries.
  • API of parameters in rclcpp / rclpy is less ergonomic than many users would like. ros2_rust would like to improve on that.

Please review the PR to ros2_rust and help improve and merge it.