Rustypot is a communication library for Dynamixel/Feetech motors. It is notably used in the Reachy project. More types of servo can be added in the future.
- Relies on serialport for serial communication
- Support for dynamixel protocol v1 and v2 (can also use both on the same bus)
- Support for sync read and sync write operations
- Easy support for new type of motors (register definition through macros). Currently support for dynamixel XL320, XL330, XL430, XM430, MX*, Orbita 2D & 3D.
- Pure Rust plus python bindings (using pyo3).
To add new servo, please refer to the Servo documentation.
It exposes two APIs:
DynamixelProtocolHandler
: low-level API. It handles the serial communication and the Dynamixel protocol parsing. It can be used for fine-grained control of the shared bus with other communication.Controller
: high-level API for the Dynamixel protocol. Simpler and cleaner API but it takes full ownership of the io (it can still be shared if wrapped with a mutex for instance).
See the examples below for usage.
use rustypot::{DynamixelProtocolHandler, servo::dynamixel::mx};
use std::time::Duration;
fn main() {
let mut serial_port = serialport::new("/dev/ttyACM0", 1_000_000)
.timeout(Duration::from_millis(10))
.open()
.expect("Failed to open port");
let dph = DynamixelProtocolHandler::v1();
loop {
let pos =
mx::read_present_position(&dph, serial_port.as_mut(), 11).expect("Communication error");
println!("Motor 11 present position: {:?}", pos);
}
}
use rustypot::servo::feetech::sts3215::STS3215Controller;
use std::time::Duration;
fn main() {
let serial_port = serialport::new("/dev/ttyUSB0", 1_000_000)
.timeout(Duration::from_millis(1000))
.open()
.unwrap();
let mut c = STS3215Controller::new()
.with_protocol_v1()
.with_serial_port(serial_port);
let pos = c.read_present_position(&vec![1, 2]).unwrap();
println!("Motors present position: {:?}", pos);
c.write_goal_position(&vec![1, 2], &vec![1000, 2000]).unwrap();
}
See https://docs.rs/rustypot for more information on APIs and examples.
See python/README.md for information on how to use the python bindings.
The python bindings are generated using pyo3. They are available on pypi
(https://pypi.org/project/rustypot/). You can install them using pip, pix, uv, etc.
To build them locally, you can use maturin.
maturin build --release --features python
or, if you want to install them in your local python environment:
maturin develop --release --features python
See maturin official documentation for more information on how to use it.
If you want to contribute to Rustypot, please fork the repository and create a pull request. We welcome any contributions, including bug fixes, new features, and documentation improvements. We especially appreciate support for new servos. If you want to add support for a new servo, please follow the instructions in the Servo documentation.
This library is licensed under the Apache License 2.0.
Rustypot is developed and maintained by Pollen-Robotics. They developed open-source hardware and tools for robotics. Visit https://pollen-robotics.com to learn more or join the Discord community if you have any questions or want to share your projects.