To use rclrs in your Rust projects, you must first install the Rust toolchain and necessary system dependencies. You also need to install colcon plugins for Cargo to enable seamless integration with the ROS 2 build system.
1. Install Rust
Use rustup to install the Rust toolchain:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2. Install System Dependencies
Install git, libclang-dev, python3-pip, and python3-vcstool via apt:
sudo apt install -y git libclang-dev python3-pip python3-vcstool
3. Install colcon plugins for Rust
Install the required colcon plugins using pip:
pip install --break-system-packages colcon-cargo colcon-ros-cargo
4. Install Workaround Packages
Due to a known issue in rclrs, you must install the following ROS 2 packages as a workaround:
sudo apt install -y ros-$ROS_DISTRO-example-interfaces
sudo apt install -y ros-$ROS_DISTRO-test-msgs
# Install Rust (see https://rustup.rs/)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install required system packages
sudo apt install -y git libclang-dev python3-pip python3-vcstool
# Install colcon plugins for Rust
pip install --break-system-packages colcon-cargo colcon-ros-cargo
# Install workaround packages
sudo apt install -y ros-$ROS_DISTRO-example-interfaces
sudo apt install -y ros-$ROS_DISTRO-test-msgs