pub struct NLinkArm3D { /* private fields */ }Expand description
A 3D N-link arm with alternating yaw/pitch joints.
Implementations§
Source§impl NLinkArm3D
impl NLinkArm3D
Sourcepub fn new(link_lengths: Vec<f64>) -> Self
pub fn new(link_lengths: Vec<f64>) -> Self
Creates a new arm with all joint angles initialized to zero.
Sourcepub fn with_angles(link_lengths: Vec<f64>, joint_angles: Vec<f64>) -> Self
pub fn with_angles(link_lengths: Vec<f64>, joint_angles: Vec<f64>) -> Self
Creates a new arm with specified joint angles.
§Panics
Panics if link_lengths and joint_angles have different lengths.
Sourcepub fn forward_kinematics(&self) -> Vec<Vector3<f64>> ⓘ
pub fn forward_kinematics(&self) -> Vec<Vector3<f64>> ⓘ
Computes forward kinematics, returning positions of base, all joints, and the end effector (n+1 points total).
For each joint i:
- If i is even: rotate around Z by
joint_angles\[i\](yaw) - If i is odd: rotate around Y by
joint_angles\[i\](pitch)
Then advance by link_lengths\[i\] along the current local X direction.
Sourcepub fn end_effector(&self) -> Vector3<f64>
pub fn end_effector(&self) -> Vector3<f64>
Returns the end-effector position.
Sourcepub fn jacobian(&self) -> Matrix3xX<f64>
pub fn jacobian(&self) -> Matrix3xX<f64>
Computes the 3-by-n numerical Jacobian via finite differences.
Each column j is (end_effector(q + eps*e_j) - end_effector(q - eps*e_j)) / (2*eps).
Sourcepub fn inverse_kinematics(
&mut self,
target: Vector3<f64>,
max_iter: usize,
tolerance: f64,
) -> bool
pub fn inverse_kinematics( &mut self, target: Vector3<f64>, max_iter: usize, tolerance: f64, ) -> bool
Solves inverse kinematics using damped least squares (Levenberg-Marquardt).
dq = J^T * (J * J^T + lambda * I)^{-1} * error
Returns true if the end effector converged to within tolerance of
the target.
Sourcepub fn joint_angles(&self) -> &[f64]
pub fn joint_angles(&self) -> &[f64]
Returns a reference to the current joint angles.
Sourcepub fn link_lengths(&self) -> &[f64]
pub fn link_lengths(&self) -> &[f64]
Returns a reference to the link lengths.
Trait Implementations§
Source§impl Clone for NLinkArm3D
impl Clone for NLinkArm3D
Source§fn clone(&self) -> NLinkArm3D
fn clone(&self) -> NLinkArm3D
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NLinkArm3D
impl RefUnwindSafe for NLinkArm3D
impl Send for NLinkArm3D
impl Sync for NLinkArm3D
impl Unpin for NLinkArm3D
impl UnsafeUnpin for NLinkArm3D
impl UnwindSafe for NLinkArm3D
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> 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 more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.