Expand description
A low-level communication library for servo (Dynamixel and Feetech motors).
§Attribution
This crate is a derivative work based on servocom, originally developed and maintained by Pollen Robotics. It has been modified and extended from the upstream source.
Both the original work and this derivative are distributed under the
Apache License 2.0. In
accordance with Section 4 of the License, all original copyright, patent,
trademark, and attribution notices from the source form have been retained,
and this notice indicates that modifications have been made to the
original files. See the NOTICE file distributed with this crate for
additional details.
We sincerely thank the servocom authors and the Pollen Robotics team for releasing their work as open source.
§Feature Overview
- Relies on serialport for serial communication
- Support for dynamixel protocol v1 and v2 (both can be used on the same io)
- Support for sync read and sync write operations
- Easy support for new type of motors (register definition through macros)
- Pure Rust
§APIs
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.
§Examples
§With the low-level API
use servocom::{DynamixelProtocolHandler, servo::dynamixel::mx};
use std::time::Duration;
let mut port = serialport::new("/dev/ttyACM0", 1_000_000)
.timeout(Duration::from_millis(10))
.open()
.expect("Failed to open port");
let dph = DynamixelProtocolHandler::v1();
let raw_pos: i16 = mx::read_raw_present_position(&dph, port.as_mut(), 11).expect("Communication error");
let pos: f64 =
mx::read_present_position(&dph, port.as_mut(), 11).expect("Communication error");
println!("Motor 11 present position: {:?}rads (raw: {:?})", pos, raw_pos);§With the high-level API
use servocom::servo::feetech::sts3215::Sts3215Controller;
use std::time::Duration;
let port = serialport::new("/dev/ttyUSB0", 1_000_000)
.timeout(Duration::from_millis(1000))
.open()
.unwrap();
let mut c = Sts3215Controller::new().with_serial_port(port);
let pos = c.sync_read_present_position(&vec![1, 2]).unwrap();
println!("Motors present position: {:?}", pos);
c.sync_write_goal_position(&vec![1, 2], &vec![0.0, 90.0_f64.to_radians()]).unwrap();Modules§
Macros§
- __
generate_ servo_ with - generate_
addr_ read_ write - generate_
protocol_ constructor - generate_
reg_ access - generate_
reg_ read - generate_
reg_ write - generate_
reg_ write_ fb - Generates write and sync_write functions with feedback for given register
- generate_
servo - generate_
special_ instructions - register_
servo
Structs§
- Dynamixel
Protocol Handler - Raw dynamixel communication messages controller (protocol v1 or v2)
- Feetech
Protocol Handler - Raw Feetech (FT-SCS) communication messages controller. Feetech servos use a single protocol version
Enums§
- Communication
Error Kind - Dynamixel Communication Error