sybot_lib

Crates.io version ![sybot_lib: rustc 1.68+]

A simple library to control groups of components and robots.

Extension library for the stepper_lib.

-- UNFINISHED DOCS --

Full documentation will be added soon

Goal

In action

The following example creates a new SyArm robot, runs all setup functions and executes a GCode-script.

Click to show Cargo.toml

```toml

...

[dependencies]

Include the library configured for the raspberry pi

sybot_lib = { version = "0.7.8", features = [ "rasp" ] }

...

```

```rust use sybotlib::{SyArm, Robot, JsonConfig}; use sybotlib::intpr::Interpreter; use sybotlib::intpr::gcode::initintpr;

fn main() -> std::io::Result<()> { // Load the standard-partlibs in order to use motor names as data // // json // "ctrl": { // "consts": "MOT_17HE15_1504S", // Motor name, see // // <https://docs.rs/stepper_lib/0.11.1/stepper_lib/data/struct.StepperConst.html#associatedconstant.MOT_17HE15_1504S> // "pin_dir": 17, // "pin_step": 26 // }, // let libs = sybotlib::partlib::createstd_libs();

// Create the robot out of the [configuration file]
// (https://github.com/SamuelNoesslboeck/sybot_lib/blob/master/res/SyArm_Mk1.conf.json)
let mut syarm = SyArm::from_conf(
    JsonConfig::read_from_file(&libs, "res/SyArm_Mk1.conf.json")
)?;

// Run setup functions
syarm.setup();
// Enables async movements (multiple motors moving at once)
syarm.setup_async();

// DEBUG
    // Select "NoTool" at index 2
    syarm.set_tool_id(2);
// 

// Create a new GCode interpreter
let intpr = init_intpr();

// Run a GCode script
dbg!(intpr.interpret_file(&mut syarm, "res/gcode/basicYZpos.gcode"));

Ok(())

} ```

(Source: "examples/in_action.rs")

Overview

Features

For more features, see stepper_lib#features

Robots

In order to access all the functionalities of the library, we must first create an instance of an existing robot type or create a new custom one. The library

Custom robots

Tools

Configuration

The library includes methods for parsing JSON configuration files (file extension ".conf.json"). Out of these files, all the constants for a previously defined robot can be parsed.

Example configuration file:

```json { "name": "SyArmMk1", "confversion": "0.0.1/2023/02/21", "author": "Samuel Nösslböck",

"lk": { "u": 12, "s_f": 1.5 },

"anchor": [ 0.0, 0.0, 100.0 ], "dims": [ [ 0.0, 0.0, 15.0 ], [ 0.0, 285.0, 0.0 ], [ 0.0, 285.0, 0.0 ], [ 0.0, 45.0, 0.0 ] ], "axes": [ [ 0.0, 0.0, 1.0 ], [ 1.0, 0.0, 0.0 ], [ 1.0, 0.0, 0.0 ], [ 1.0, 0.0, 0.0 ] ],

"comps": [ { "name": "Base", "typename": "stepperlib::comp::gearbearing::GearJoint", "obj": { "ctrl": { "consts": "MOT17HE151504S", "pindir": 17, "pinstep": 26 }, "ratio": 0.08333 }, "sim": { "mass": 0.2, "fric": 2.0 }, "meas": { "pin": 16, "setval": 0.0, "dist": 0.0 }, "limit": { "vel": 5.0, "min": -3.14, "max": 3.14 } }, // ... ```

Calculation

The library includes functions for inertia and load calculations.

Command systems

With the intpr module you can create your own command systems or use the already implemented GCode one.

Networking

Remotes

HTTP

Click to show Cargo.toml

```toml

...

[dependencies]

Include the library configured for the raspberry pi and with http enabled

sybot_lib = { version = "0.7.8", features = [ "rasp", "http" ] }

...

```

```rust extern crate alloc;

use core::cell::RefCell;

use alloc::rc::Rc; use actix_web::{HttpServer, App};

use sybotlib::{JsonConfig, SyArm, Robot}; use sybotlib::intpr::gcode::initintpr; use sybotlib::http::createrobotwebserver;

[actix::main]

async fn main() -> Result<(), std::io::Error> {
HttpServer::new(move || { // Load the standard-partlibs in order to use motor names as data // // json // "ctrl": { // "consts": "MOT_17HE15_1504S", // Motor name, see // // <https://docs.rs/stepper_lib/0.11.1/stepper_lib/data/struct.StepperConst.html#associatedconstant.MOT_17HE15_1504S> // "pin_dir": 17, // "pin_step": 26 // }, // let libs = sybotlib::partlib::createstd_libs();

    // Create the robot out of the [configuration file]
    // (https://github.com/SamuelNoesslboeck/sybot_lib/blob/master/res/SyArm_Mk1.conf.json)
    let mut syarm = SyArm::from_conf(
        JsonConfig::read_from_file(&libs, "res/SyArm_Mk1.conf.json")
    )?;

    // Create a new interpreter in a [std::rc::Rc]
    let intpr = Rc::new(RefCell::new(init_intpr()));

    // Create the webserver
    create_robot_webserver::<SyArm, _, 4, 1, 4, 4>(syarm, intpr, App::new())
}).bind(("127.0.0.1", 8080))?   // Bind the webserver 
.run()
.await

} ```

MQTT

Custom connections

With the creation of custom remotes, the user can create their own connections to the internet or other forms of networks.

Platforms and simulation

The final goal of the library is to work on as many platforms as possible. To configure the library for a specific platform, the right features have to be enabled.

The current platforms and features enabled are - "rasp": Raspberry Pi and similar controllers

```toml

platform features

rasp = [ "stepper_lib/rasp" ] ```

If no platform is selected the library automatically goes into simulation mode. In simulation mode, no movements will be executed, but all calculations will be done. Which means that for example GCode scripts can be "debugged" in advance.

Issues and requests

If you encounter any issues or if you have any request for new features, feel free to create an issue at the GitHub repo.