*with meadow
, an experimental robotics-focused middleware written in Rust
Ever wanted make an animated turtle move around on screen? Now you can, but with Rust!
Turtlesim is a autonomy simulator made popular by ROS/2, which is described as
Turtlesim is a lightweight simulator for learning ROS 2. It illustrates what ROS 2 does at the most basic level, to give you an idea of what you will do with a real robot or robot simulation later on.
Assuming that you have already have Rust installed (if not, check here for instructions), you can build this program using
$ git clone --depth=1 [email protected]:quietlychris/turtlesim.git
$ cd turtlesim
$ cargo build --all -features bevy/dynamic
Once built, run the following from one terminal, which will start the simulator and allow you to control the turtle's acceleration and movement using your arrow keys
# This will start the simulator and allow you to manually
# move the turtle around using the arrow keys (and [ESC] to exit)
$ cargo run --bin turtlesim --features bevy/dynamic
You can also script the turtle's motion, by running the following from another example (the first one will still be used by the simulator). Try experimenting around with creating different patterns!
$ cargo run --bin move_turtle --features bevy/dynamic
ROS/2 is one of the most commonly-used robotics middleware platforms, although it exists alongside other messaging platforms like MOOS-IvP, MQTT, and ZeroMQ. However, each of these alternatives have something in common; they're all written in C++.
This Turtlesim repository is part of an onoing project testing for out an experimental robotics middleware, called Meadow. It is written in pure Rust, and can be directly integrated with Bevy, a "refreshingly simple data-driven game engine", creating an accessible, extensible base for experimenting with more complex autonomy simulations.
In particular, this project aims to leverage the following benefits of using a middleware like Meadow for robotics applications:
- Catch errors at compile-time: Runtime errors are robots' monster under the bed. Autonomy software is often mission-critical, and errors at runtime potentially mean losing a vehicle or worse. The Rust compiler, with compile-time assurances around static typing, mutability, memory management, and concurrency helps prevent many classes of bugs before the code ever makes it to deployment. An accessible ecosystem of high-quality developer tools makes unit and integration tests, documentation checks, formatting lints, and more exceptionally easy.
- Low-overhead dependency management: Working with and building ROS/2 packages has gotten much easier with the introduction of
colcon
(see bottom of the page), but it's still not painless; developers need to be competent with CMake, ROS'spackage.xml
,rosdep
, and variousament
-related structures. Comparatively, Rust projects (including Turtlesim and Meadow) use the standardcargo
package/build system for all aspects of dependency management. - Easy cross-compilation: Compare the cross-compilation of ROS2 with Rust's
cross
tool, which supports virtually all Rust compilation targets, including popular companion computers like the Raspberry Pi. This workflow makes building hardware-in-the-loop simulations using ARM single-board computers very low-friction. - Limited environment configuration: Rust uses static linking to create binaries, which drastically cuts down on the number of system-level dependencies required on either development or deployment machines. As standard Rust packages, operating system compatibility tracks the upstream ecosystem--no more worrying about which particular Ubuntu distros are currently supported.
Rust is language with a mission of "empowering everyone to write reliable and efficient software." This is especially important in the robotics space, where reliable autonomy software is often the foundational aspect of successful projects. In short, the goal of Meadow is to make writing mission-critical robotics software more accessible. Developers don't need to be experts in class member access operators, shared pointers, or placeholder objects. So don't worry about getting your system configuration perfect, and jump right into developing for robots! (Just worry about the number of pre-1.0 software packages being used instead.)
Turtleim can be configured to do fast-compile using the Bevy dynamic linking feature. This can done by modifying the Cargo.toml
to
bevy = {version = "0.8", features = ["dynamic"]}
# bevy = "0.8
or built manually using this feature using
$ cargo run --bin turtlesim --features bevy/dynamic
Also, check out the following:
- Orientation: Real-time 3D orientation visualization of a BNO055 IMU using Meadow and Bevy
- Bevy: The Bevy game engines ECS represents an exciting new path for writing high-quality robotics simulations
turtle
: Another way to move a turtle-y thing around- rust-mq: A ZeroMQ message client library written in Rust
- MOOS-IvP: Marine robotics-focused middleware
- ROS2: ROS2 Rolling documentation
Turtlesim is licensed under the Mozilla Public License, version 2.0 (MPL-2.0)