Skip to content

Instantly share code, notes, and snippets.

@ClintLiddick
Last active April 3, 2023 02:38
Show Gist options
  • Star 62 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save ClintLiddick/2966203a425ac5fb70a3d6eb0022f675 to your computer and use it in GitHub Desktop.
Save ClintLiddick/2966203a425ac5fb70a3d6eb0022f675 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link
Author

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

@AtomicVikings5256
Copy link

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
Copy link

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

@wbthomason
Copy link

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

@JackRipper1888
Copy link

NB

@Sollimann
Copy link

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