pub struct RobotArm {
pub name: String,
pub links: Vec<RobotLink>,
pub base_transform: Mat4,
}Expand description
A serial-chain robot arm described by a sequence of DH links.
Supports forward kinematics, Jacobian computation (analytical and numerical), Newton-Raphson inverse kinematics, workspace Monte-Carlo sampling, joint-limit checking, and self-collision detection.
Fields§
§name: StringName of the robot.
links: Vec<RobotLink>Ordered list of links (joint 0 is closest to base).
base_transform: Mat4Base transform applied before all joint transforms.
Implementations§
Source§impl RobotArm
impl RobotArm
Sourcepub fn with_base_transform(self, t: Mat4) -> Self
pub fn with_base_transform(self, t: Mat4) -> Self
Sets the base transform and returns self for chaining.
Sourcepub fn forward_frames(&self, q: &[f64]) -> Vec<Mat4> ⓘ
pub fn forward_frames(&self, q: &[f64]) -> Vec<Mat4> ⓘ
Computes all intermediate frames (base → end-effector) for a given joint
configuration q. Returns one matrix per link plus the base.
Sourcepub fn end_effector(&self, q: &[f64]) -> Mat4
pub fn end_effector(&self, q: &[f64]) -> Mat4
Returns the end-effector transform for joint configuration q.
Sourcepub fn end_effector_pos(&self, q: &[f64]) -> [f64; 3]
pub fn end_effector_pos(&self, q: &[f64]) -> [f64; 3]
Returns the end-effector position [x, y, z] for joint configuration q.
Sourcepub fn jacobian_numerical(&self, q: &[f64]) -> Vec<f64>
pub fn jacobian_numerical(&self, q: &[f64]) -> Vec<f64>
Computes the 3×n positional Jacobian numerically (finite differences).
Returns a flat row-major array of shape 3 × dof.
Sourcepub fn jacobian_6dof_numerical(&self, q: &[f64]) -> Vec<f64>
pub fn jacobian_6dof_numerical(&self, q: &[f64]) -> Vec<f64>
Computes the full 6×n Jacobian (position + orientation) numerically.
Orientation rows use angle-axis approximation via the rotation part of
the end-effector transform. Returns flat row-major 6 × dof.
Sourcepub fn jacobian_analytical(&self, q: &[f64]) -> Vec<f64>
pub fn jacobian_analytical(&self, q: &[f64]) -> Vec<f64>
Computes the 3×n analytical Jacobian using the geometric (cross-product) method.
For revolute joints: J_i = z_{i-1} × (p_e − p_{i-1}).
For prismatic joints: J_i = z_{i-1}.
Sourcepub fn jacobian_pseudoinverse(j: &[f64], n: usize, lambda: f64) -> Vec<f64>
pub fn jacobian_pseudoinverse(j: &[f64], n: usize, lambda: f64) -> Vec<f64>
Computes the damped least-squares pseudo-inverse of a 3 × n Jacobian.
Uses the formula J^+ = J^T (J J^T + λ²I)^{-1} with closed-form
inversion for the 3×3 system.
Sourcepub fn ik_newton_raphson(
&self,
target: [f64; 3],
q_init: &[f64],
max_iter: usize,
tol: f64,
lambda: f64,
) -> Result<Vec<f64>, Vec<f64>>
pub fn ik_newton_raphson( &self, target: [f64; 3], q_init: &[f64], max_iter: usize, tol: f64, lambda: f64, ) -> Result<Vec<f64>, Vec<f64>>
Attempts to solve inverse kinematics using Newton-Raphson iteration.
Returns Ok(q) if converged within max_iter steps, or Err with the
best solution found.
Sourcepub fn workspace_monte_carlo(&self, n_samples: usize) -> Vec<[f64; 3]>
pub fn workspace_monte_carlo(&self, n_samples: usize) -> Vec<[f64; 3]>
Samples n_samples random joint configurations and returns the set of
reachable end-effector positions.
Sourcepub fn workspace_bounding_box(
&self,
n_samples: usize,
) -> Option<([f64; 3], [f64; 3])>
pub fn workspace_bounding_box( &self, n_samples: usize, ) -> Option<([f64; 3], [f64; 3])>
Estimates the reachable workspace bounding box from a Monte-Carlo sample.
Returns (min_corner, max_corner) or None if no samples.
Sourcepub fn link_capsules(&self, q: &[f64]) -> Vec<([f64; 3], [f64; 3], f64)>
pub fn link_capsules(&self, q: &[f64]) -> Vec<([f64; 3], [f64; 3], f64)>
Returns all link capsule endpoints in world space for configuration q.
Each entry is (p_start, p_end, radius) describing the capsule axis.
Sourcepub fn check_collision_sphere(
&self,
q: &[f64],
sphere_center: [f64; 3],
sphere_radius: f64,
) -> bool
pub fn check_collision_sphere( &self, q: &[f64], sphere_center: [f64; 3], sphere_radius: f64, ) -> bool
Checks whether any robot link capsule intersects an obstacle sphere.
Returns true if any link is in collision.
Sourcepub fn check_collision_aabb(
&self,
q: &[f64],
box_min: [f64; 3],
box_max: [f64; 3],
) -> bool
pub fn check_collision_aabb( &self, q: &[f64], box_min: [f64; 3], box_max: [f64; 3], ) -> bool
Checks whether any robot link capsule intersects an axis-aligned box.
Returns true if any link is in collision.
Sourcepub fn check_self_collision(&self, q: &[f64]) -> bool
pub fn check_self_collision(&self, q: &[f64]) -> bool
Detects self-collision between non-adjacent link capsules.
Links with indices that differ by 1 (adjacent) are always skipped.
Returns true if any non-adjacent pair of capsules overlaps.
Sourcepub fn joints_within_limits(&self, q: &[f64]) -> bool
pub fn joints_within_limits(&self, q: &[f64]) -> bool
Returns true if all joint values in q satisfy the robot’s joint limits.
Sourcepub fn clamp_joints(&self, q: &[f64]) -> Vec<f64>
pub fn clamp_joints(&self, q: &[f64]) -> Vec<f64>
Clamps all joints in q to the robot’s limits and returns the result.
Sourcepub fn swept_volume_aabb(
&self,
q_start: &[f64],
q_end: &[f64],
n_steps: usize,
) -> ([f64; 3], [f64; 3])
pub fn swept_volume_aabb( &self, q_start: &[f64], q_end: &[f64], n_steps: usize, ) -> ([f64; 3], [f64; 3])
Computes a coarse AABB for the swept volume of the end-effector as joints
vary linearly from q_start to q_end using n_steps samples.
Sourcepub fn manipulability(&self, q: &[f64]) -> f64
pub fn manipulability(&self, q: &[f64]) -> f64
Computes Yoshikawa’s manipulability measure sqrt(det(J J^T)).
High values indicate configurations far from singularities.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RobotArm
impl RefUnwindSafe for RobotArm
impl Send for RobotArm
impl Sync for RobotArm
impl Unpin for RobotArm
impl UnsafeUnpin for RobotArm
impl UnwindSafe for RobotArm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.