29 releases (15 breaking)

0.15.0 Jun 11, 2019
0.14.0 Mar 19, 2019
0.13.1 Jan 16, 2019
0.12.0 Dec 17, 2018
0.6.0 Nov 23, 2017

#71 in Algorithms

Download history 377/week @ 2019-06-26 203/week @ 2019-07-03 561/week @ 2019-07-10 39/week @ 2019-07-17 41/week @ 2019-07-24 40/week @ 2019-07-31 63/week @ 2019-08-07 16/week @ 2019-08-14 355/week @ 2019-08-21 71/week @ 2019-08-28 135/week @ 2019-09-04 47/week @ 2019-09-11 243/week @ 2019-09-18 67/week @ 2019-09-25 43/week @ 2019-10-02

235 downloads per month
Used in 2 crates

Apache-2.0

91KB
2K SLoC

k: Kinematics library for rust-lang Build Status crates.io

k has below functionalities.

  1. Forward kinematics
  2. Inverse kinematics
  3. URDF Loader

k uses nalgebra as math library.

See Document and examples/ for more details.

API is unstable.

Requirements to build examples

sudo apt install g++ cmake xorg-dev libglu1-mesa-dev

IK example with GUI

cargo run --release --example interactive_ik

ik_sample

Push below keys to move the end of the manipulator.

  • f: forward
  • b: backward
  • p: up
  • n: down
  • l: left
  • r: right
  • z: reset the manipulator state.

Create link tree from urdf and solve IK

extern crate k;

use k::prelude::*;

fn main() {
    // Load urdf file
    let chain = k::Chain::<f32>::from_urdf_file("urdf/sample.urdf").unwrap();
    println!("chain: {}", chain);

    // Set initial joint angles
    let angles = vec![0.2, 0.2, 0.0, -1.0, 0.0, 0.0, 0.2, 0.2, 0.0, -1.0, 0.0, 0.0];

    chain.set_joint_positions(&angles).unwrap();
    println!("initial angles={:?}", chain.joint_positions());

    let target_link = chain.find("l_wrist_pitch").unwrap();

    // Get the transform of the end of the manipulator (forward kinematics)
    chain.update_transforms();
    let mut target = target_link.world_transform().unwrap();

    println!("initial target pos = {}", target.translation);
    println!("move z: +0.1");
    target.translation.vector.z += 0.1;

    // Create IK solver with default settings
    let solver = k::JacobianIKSolver::default();

    // Create a set of joints from end joint
    let arm = k::SerialChain::from_end(target_link);
    // solve and move the manipulator angles
    solver.solve(&arm, &target).unwrap();
    println!("solved angles={:?}", chain.joint_positions());

    chain.update_transforms();
    let solved_pose = target_link.world_transform().unwrap();
    println!("solved target pos = {}", solved_pose.translation);
}

Dependencies

~7.5MB
~166K SLoC