rustodrive is a rust client library for communicating with ODrives using the CAN protocol.

Related tags

Database rustodrive
Overview

rustodrive is a WIP client library for communicating with ODrives using the CAN protocol.

It is more than a simple CAN sender/receiver and has many convenience structs/methods alongside support for multiple threads sending and receiving safely, loosely following the Command Query Responsibility Segregation (CQRS) paradigm. Only one thread is given permission to send commands that can modify the state of the ODrive while other threads have permission to request any data that doesn't change state.

Why allow multiple threads?

One might be wondering why one would want multiple threads, and for most cases, you can treat this as a single threaded application and simply take advantage of the methods available. But for our case, we are needed to develop a GUI which should silently listen to the commands being send back and forth. This might also be useful for debugging purposes and could allow for playback of past data for non-physical testing.

State of the library

This library is currently in early stages and doesn't support all the CAN commands. However, most of the grunt work has already been done and it should be a matter of passing parameters into our objects (see axis.rs and odrivegroup.rs for what remains to be done).

The library will be under active development for the next few months as this is being used for an overarching project found here AMBER @ UConn

Current functionality

  • Safe multithreading
  • Setting axis states, reading encoder values, setting the control mode, setting input velocity or position

We intend to implement the remaining supported CAN messages in the future.

Examples

// main.rs
use rustodrive::{
    canproxy::CANProxy,
    state::{ODriveAxisState::*, ControlMode, InputMode},
    odrivegroup::ODriveGroup,
    threads::ReadWriteCANThread,
};
use signal_hook::{consts::SIGINT, iterator::Signals};
use std::{error::Error};

fn odrive_main(can_read_write: ReadWriteCANThread) {
    // Specify the CAN ids of all odrives connected
    let odrives = ODriveGroup::new(can_read_write, &[0, 1, 2, 3, 4, 5]);
    odrv.all_axes(|ax| ax.set_state(EncoderIndexSearch));

    odrives.all_axes(|ax| ax.set_state(ClosedLoop));
    odrives.all_axes(|ax| ax.motor.set_control_mode(ControlMode::PositionControl, InputMode::PosFilter));
    odrives.all_axes(|ax| ax.motor.set_input_pos(180.0 / 360.0));

    //odrives.all_axes(|ax| ax.motor.set_input_vel(10.0)); // if we had velocity control enabled
}


// This is useful code to stop threads and exit peacefully
fn main() -> Result<(), Box<dyn Error>> {
    let mut can_proxy = CANProxy::new("can0");

    // We register a thread that is capable of reading state, but also modifying it
    // We can also register a thread that can send "read only" commands.
    can_proxy.register_rw("thread 1", odrive_main);
    can_proxy.register_ro("read only thread", |read_only| {})

    // Turn on the thread to process CAN commands from various threads
    let stop_all = can_proxy.begin();

    // Handle ctrl-c to exit
    let mut signals = Signals::new(&[SIGINT])?;
    for sig in signals.forever() {
        println!("\nQuitting the program {:?}", sig);
        break;
    }

    // Use the hook from `can_proxy.begin()` to clean up the registered threads
    stop_all().unwrap();
    println!("all done!");
    Ok(())
}

Documentation

You can build our public documentation with cargo doc or to include private method documentation, with cargo doc --document-private-items. Currently, most documentation with examples is found in CANProxy and ODriveGroup

Contributing & License

Pull requests are greatly appreciated and all work is available under the MIT license.

You might also like...
CouchDB client-side library for the Rust programming language

Chill Chill is a client-side CouchDB library for the Rust programming language, available on crates.io. It targets Rust Stable. Chill's three chief de

An etcd client library for Rust.

etcd An etcd client library for Rust. etcd on crates.io Documentation for the latest crates.io release Running the tests Install Docker and Docker Com

Mysql client library implemented in rust.

mysql This crate offers: MySql database driver in pure rust; connection pool. Features: macOS, Windows and Linux support; TLS support via nativetls cr

Skytable rust client support library for the bb8 connection pool

bb8-skytable Skytable rust client support library for the bb8 connection pool. Heavily based on bb8-redis Basic usage example use bb8_skytable::{

CouchDB client library for the Rust programming language

CouchDB This project is reborn! As of its v0.6.0 release, the couchdb crate has new life as a toolkit instead of providing a full-blown client. In a n

An async-ready Phoenix Channels v2 client library in Rust

Phoenix Channels This crate implements a Phoenix Channels (v2) client in Rust. Status NOTE: This client is still a work-in-progress, though it has eno

LDAP client library

LDAP client library A pure-Rust LDAP client library using the Tokio stack. Compatibility with Tokio versions Tokio 1.0 is the long-term stable version

A simple, workable RCS client library.

rust-rcs-client A simple, workable RCS client library. RCS capabilities are mainly provided by your cellular network. This is a working client side im

A Rust crate for writing servers that speak PostgreSQL's wire protocol

Convergence A Rust crate for writing servers that speak PostgreSQL's wire protocol. Additionally, the experimental convergence-arrow crate enables con

Owner
null
The rust client for CeresDB. CeresDB is a high-performance, distributed, schema-less, cloud native time-series database that can handle both time-series and analytics workloads.

The rust client for CeresDB. CeresDB is a high-performance, distributed, schema-less, cloud native time-series database that can handle both time-series and analytics workloads.

null 12 Nov 18, 2022
Rust client for the anna-rs KVS that can run in the WasmEdge Runtime

wasmedge-anna-client wasmedge-anna-client is a Rust client for anna-rs based on Tokio for WasmEdge. It communicates with Anna routing nodes and KVS no

WasmEdge Runtime 4 Nov 8, 2022
This code features a viper-client, which can connect to a viper-server, a custom interface made for Comelit devices.

Viper Client ?? (WIP) This is code for my intercom; specifically for the Comelit Mini Wi-Fi MSFV. This features a ViperClient which can talk to the Co

Gerard 4 Feb 20, 2023
Async Lightweight HTTP client using system native library if possible. (Currently under heavy development)

Async Lightweight HTTP Client (aka ALHC) What if we need async but also lightweight http client without using such a large library like reqwest, isahc

SteveXMH 7 Dec 15, 2022
Affine-client is a client for AFFINE based on Tauri

Affine Client affine-client is a client for AFFINE based on Tauri Supported Platforms Windows Linux MacOS Download https://github.com/m1911star/affine

Horus 216 Dec 25, 2022
Hypergraph is data structure library to create a directed hypergraph in which a hyperedge can join any number of vertices.

Hypergraph is data structure library to create a directed hypergraph in which a hyperedge can join any number of vertices.

Davy Duperron 224 Dec 21, 2022
A firebase HTTP v1 client implementation in Rust using google-authz

firebase-client A firebase HTTP v1 client implementation in Rust using the google_authz library. Example There are two ways to send notifications, one

Mobiltracker 2 Dec 14, 2022
Incomplete Redis client and server implementation using Tokio - for learning purposes only

mini-redis mini-redis is an incomplete, idiomatic implementation of a Redis client and server built with Tokio. The intent of this project is to provi

Tokio 2.3k Jan 4, 2023
Rust lib for a Vec-like structure that can store different types of different sizes contiguous with each other in memory.

hvec In memory of Anna Harren, who coined the term turbofish - which you'll see a lot of if you use this crate. The main purpose of this crate is the

Vi 2 Oct 23, 2022
This represents staked SOL, and can be sold for wSOL in the wSOL/stSOL Liquidity Pool

This represents staked SOL, and can be sold for wSOL in the wSOL/stSOL Liquidity Pool (paying a fee to skip the unstaking cool-down period). The value of your stSOL holdings is automatically incremented each epoch when staking rewards are paid.

null 2 Jun 4, 2022