Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rust Libraries for Robotics

Motivation

tl;dr I want to use Rust to program robots. Help me find the best core libraries to build on.

Robotic systems require high performance and reliability, but also have enormous complexity in terms of algorithms employed, number of subsystems, embedded hardware control, and other metrics. Development is mostly split between C++ for performance and safety critical components, and MatLab or Python for quick research or task iteration.

Rust is a strong/statically typed systems-level language designed with safety, performance, and expressiveness in mind. Given the nature of robotics development, I believe Rust to be the perfect fit for both research and product grade development. However, there are many high quality, fundamental libraries in C++ (as well as Python and MatLab) that must exist before serious robotics-focused libraries are possible.

I can write robotics libraries and systems, but I cannot rebuild the universe from scratch. With this article I hope to draw on the fabulous Rust community to help in determining the current state-of-the-art in several areas of Rust. In particular, robotics development overlaps with game and embedded development, so I am hopeful there will be many sources to draw from.

Please comment with your input and I will keep this article updated with all your suggestions.

General Libraries

Libraries that of use to many development practices.

Mathematics

These libraries need to be fast, as all other systems will be built on top of them.

Top contenders:

  • nalgebra
    • Best option for general (low-dimension) linear algebra
    • Extension to at least 7D would enhance usefulness
  • RustAlgebloat
  • petgraph
    • Data structures and algorithms

Others to consider:

Non-starters:

  • vecmath
    • No linear algebra or quaternions

Simulation

The critical consideration here is flexibility. How much control do the simulations allow, and how many kinds of meshes and objects are supported. But again, the faster the better.

Top contenders:

Collision Detection

This is an active area of research, but having a usable and reasonably quick starting point would help with bootstrapping some other libraries and applications.

Distributed Systems

Most robotics systems are distributed, even if only very local embedded systems. A highly reliable pub/sub and RPC style communication system is the usual solution.

Graphics (2D and 3D)

Rendering robot state and simulation models is incredibly valuable in development, demonstration, and field usage. Graphics libraries need to handle model rendering well (read "correctly support standards"), be viably fast, and preferably cross-platform. A simple/user-friendly API is an important "extra," as many of us are not graphics specialists. Cross-platform input handling would be nice.

High-level libraries:

Utility/core libraries:

GUI

For tool and UI creation.

Robotics Libraries

Most of these don't exist yet! But that shouldn't stop us. Included are ideas for C/C++ libraries to wrap.

Computer Vision

Libraries to wrap or replicate:

Rigid Body Kinematics and Dynamics

C++ Libraries:

  • DART
    • Used by our research lab
    • Very large API, so would be very difficult to wrap by hand
  • RBDL

Planning

  • OMPL
    • Will probably need to be re-implemented, as I'm not sure how compatible interface/implementation style will be with Rust

Control

  • A controls helper library will need to be written in pure Rust.
    • standard control algorithms
    • task-based control framework (TODO explain this better when I have time)
  • Common communication protocols will need implemented or wrapped
    • CANBus
    • Ethernet (UDP in std::net for non-embedded)
    • EtherCAT
@kvark

This comment has been minimized.

Copy link

@kvark kvark commented May 5, 2016

Piston has separate libraries for quaterions, in addition to vecmath: https://github.com/PistonDevelopers/quaternion, https://github.com/PistonDevelopers/dual_quaternion

Also, for collision detection there is https://github.com/csherratt/collision-rs

@ClintLiddick

This comment has been minimized.

Copy link
Owner Author

@ClintLiddick ClintLiddick commented May 5, 2016

Thanks for the tip @kvark! Piston has a lot of small libraries, I'll have to dig through more of them.

@AtomicVikings5256

This comment has been minimized.

Copy link

@AtomicVikings5256 AtomicVikings5256 commented Dec 4, 2016

One other thing is having good access to the GPIO pins on a board, weather raspberry pi, Arduino, Beagle bone, RoboRIO, ect.
https://crates.io/crates/sysfs_gpio

@paolofulgoni

This comment has been minimized.

Copy link

@paolofulgoni paolofulgoni commented Sep 15, 2017

@ClintLiddick could you suggest some control helper libraries in other languages?

@wbthomason

This comment has been minimized.

Copy link

@wbthomason wbthomason commented Jul 15, 2019

What about https://github.com/rust-ndarray/ndarray as a math library option?

@JackRipper1888

This comment has been minimized.

Copy link

@JackRipper1888 JackRipper1888 commented Jan 27, 2021

NB

@Sollimann

This comment has been minimized.

Copy link

@Sollimann Sollimann commented Feb 8, 2021

I have started on a Open-source Autonomy Software in Rust-lang with gRPC for the Roomba series robot vacuum cleaners. Motivation is to build a complete DIY autonomy software from scratch (motion planning, guidance and motion control, SLAM, mission control, 2D/3D visualization etc..) with a real-time client-server communication stream using async gRPC for intercommunication, distributed compute and teleoperation.

Project: https://github.com/Sollimann/CleanIt

Benefits to using Rust (vs C++):

  • Rust prevents segmentation faults, guarantees thread safety and memory safety.
  • In addition to being a great programming language, Rust also features a powerful build system and the best package manager in the game called Cargo. No more CMake and gcc!

Benefits to using gRPC (vs ROS):

  • gRPC is language agnostic
  • Blazingly fast
  • Allows for Client-Side streaming, Server-Side streaming, Bidirectional streaming and Unary (no streaming)
    Contributions are welcome!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment