Skip to main content

forward_kinematics

Function forward_kinematics 

Source
pub fn forward_kinematics(joints: &[DhParameters]) -> Transform
Expand description

Returns the transform from the base to the tool for a serial arm of DH joints.

§Arguments

  • joints - the arm’s joints, base first, each as DhParameters.

§Returns

The composed base-to-tool Transform; the identity for an empty arm. Take Transform::position for the tool point.

§Examples

use pamoja_kit::{forward_kinematics, DhParameters};

// A two-link planar arm written in DH form: links of 1.0, both joints at 0, flat along x.
let arm = [
    DhParameters { a: 1.0, alpha: 0.0, d: 0.0, theta: 0.0 },
    DhParameters { a: 1.0, alpha: 0.0, d: 0.0, theta: 0.0 },
];
let (x, y, _z) = forward_kinematics(&arm).position();
assert!((x - 2.0).abs() < 1e-5 && y.abs() < 1e-5); // reaches straight out to x = 2