Skip to main content

CuKinematicChain

Struct CuKinematicChain 

Source
pub struct CuKinematicChain<const N: usize> { /* private fields */ }
Expand description

Compile-time sized $N$-DOF serial robot kinematic chain.

§Example

use repose_kinematics::{CuJointAxis, CuJointLimits, CuJointSpec, CuKinematicChain};
use cu_spatial_payloads::Transform3D;
use cu29::units::si::angle::radian;
use cu29::units::si::angular_velocity::radian_per_second;
use cu29::units::si::f64::{Angle, AngularVelocity, Length};
use cu29::units::si::length::meter;

let m = Length::new::<meter>;
let rad = Angle::new::<radian>;
let chain = CuKinematicChain::new([CuJointSpec::revolute(
    [m(0.0), m(0.0), m(0.1)],
    [rad(0.0); 3],
    CuJointAxis::PosZ,
    CuJointLimits::revolute(
        rad(-core::f64::consts::PI),
        rad(core::f64::consts::PI),
        AngularVelocity::new::<radian_per_second>(2.0),
    ),
)])
.with_tool_offset(Transform3D::<f64>::from_translation_euler_xyz([m(0.0), m(0.0), m(0.05)], [rad(0.0); 3]));
chain.validate().unwrap();
let mut ee = Transform3D::<f64>::identity();
chain.forward_kinematics(&[Angle::new::<radian>(0.0).into()], &mut ee).unwrap();
assert!((ee.to_matrix()[2][3] - 0.15).abs() < 1e-12);

Implementations§

Source§

impl<const N: usize> CuKinematicChain<N>

Source

pub const fn new(joints: [CuJointSpec; N]) -> Self

Creates a serial kinematic chain with an identity tool offset.

Source

pub const fn with_tool_offset(self, tool_offset: Transform3D<f64>) -> Self

Replaces the flange-to-tool transform (builder form of Self::set_tool_offset).

Source

pub fn validate(&self) -> CuResult<()>

Checks that every joint has finite origins, a valid axis, and well-formed limits.

Source

pub const fn joints(&self) -> &[CuJointSpec; N]

Borrows the static joint specifications.

Source

pub const fn tool_offset(&self) -> &Transform3D<f64>

Borrows the flange-to-tool transform.

Source

pub fn set_tool_offset(&mut self, tool_offset: Transform3D<f64>)

Sets the flange-to-tool transform.

Source

pub fn is_within_limits(&self, q: &[CuJointPosition; N]) -> bool

Returns true if every joint angle in q satisfies its joint limits.

Source

pub fn clamp_to_limits(&self, q: &mut [CuJointPosition; N]) -> CuResult<()>

Clamps each joint angle in q in place to its configured limits.

Source

pub fn forward_kinematics( &self, q: &[CuJointPosition; N], out: &mut Transform3D<f64>, ) -> CuResult<()>

Computes the base-to-tool forward kinematics transform in place.

Source

pub fn forward_frames( &self, q: &[CuJointPosition; N], out_frames: &mut [Transform3D<f64>; N], out_ee: &mut Transform3D<f64>, ) -> CuResult<()>

Computes every intermediate link frame (0..N) and the final end-effector frame in place.

Source

pub fn geometric_jacobian( &self, q: &[CuJointPosition; N], out_jacobian: &mut [[f64; N]; 6], ) -> CuResult<()>

Computes the $6 \times N$ geometric space Jacobian in the base frame in place.

Rows 0..3 correspond to linear velocity $[v_x, v_y, v_z]^T$ in $\text{m/s}$ and rows 3..6 correspond to angular velocity $[\omega_x, \omega_y, \omega_z]^T$ in $\text{rad/s}$, both measured at the tool origin and expressed in the base frame.

Source

pub fn body_jacobian( &self, q: &[CuJointPosition; N], out_jacobian: &mut [[f64; N]; 6], ) -> CuResult<()>

Computes the $6 \times N$ geometric body Jacobian in the end-effector (tool) frame in place.

Rows 0..3 correspond to linear velocity $[v_x, v_y, v_z]^T$ in $\text{m/s}$ and rows 3..6 correspond to angular velocity $[\omega_x, \omega_y, \omega_z]^T$ in $\text{rad/s}$, both measured at the tool origin and expressed in the end-effector frame.

Source§

impl<const N: usize> CuKinematicChain<N>

Source

pub fn manipulability_squared(&self, q: &[CuJointPosition; N]) -> CuResult<f64>

Computes Yoshikawa’s manipulability index squared $w^2 = \max(0, \det(J J^T))$ at q.

Source

pub fn differential_ik( &self, q: &[CuJointPosition; N], twist: &CuTwist6D, cfg: &CuDiffIkParams, out_qd: &mut [CuJointVelocity; N], ) -> CuResult<CuDiffIkStatus>

Computes joint velocities out_qd in place for a desired 6D Cartesian twist using singularity-robust and joint-limit-aware damped least squares.

Source

pub fn inverse_kinematics_dls( &self, target: &Transform3D<f64>, seed: &[CuJointPosition; N], cfg: &CuIkParams, out_q: &mut [CuJointPosition; N], ) -> CuResult<CuIkStatus>

Solves inverse kinematics in place using Damped Least-Squares (DLS).

Writes the resulting joint configuration into out_q without heap allocation.

Trait Implementations§

Source§

impl<const N: usize> Clone for CuKinematicChain<N>

Source§

fn clone(&self) -> CuKinematicChain<N>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Copy for CuKinematicChain<N>

Source§

impl<const N: usize> Debug for CuKinematicChain<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, const N: usize> Deserialize<'de> for CuKinematicChain<N>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<const N: usize> From<CuKinematicChain<N>> for CuChainSpec<N>

Source§

fn from(chain: CuKinematicChain<N>) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> PartialEq for CuKinematicChain<N>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<const N: usize> Serialize for CuKinematicChain<N>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<const N: usize> TypePath for CuKinematicChain<N>

§

fn type_path() -> &'static str

§

fn short_type_path() -> &'static str

§

fn type_ident() -> Option<&'static str>

§

fn crate_name() -> Option<&'static str>

§

fn module_path() -> Option<&'static str>

Auto Trait Implementations§

§

impl<const N: usize> Freeze for CuKinematicChain<N>

§

impl<const N: usize> RefUnwindSafe for CuKinematicChain<N>

§

impl<const N: usize> Send for CuKinematicChain<N>

§

impl<const N: usize> Sync for CuKinematicChain<N>

§

impl<const N: usize> Unpin for CuKinematicChain<N>

§

impl<const N: usize> UnsafeUnpin for CuKinematicChain<N>

§

impl<const N: usize> UnwindSafe for CuKinematicChain<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> GetTypeRegistration for T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> PayloadDefaultHandlePolicyApply for T
where T: ?Sized,

§

fn apply_handle_content_policy(&self, _mode: HandleContent)

§

impl<T> PayloadDefaultLoggingPolicy for T
where T: ?Sized,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Reflect for T
where T: 'static,

§

impl<T> ReflectTypePath for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.