Skip to main content

TwoJointArm

Struct TwoJointArm 

Source
pub struct TwoJointArm {
    pub theta1: f64,
    pub theta2: f64,
    pub target_x: f64,
    pub target_y: f64,
    pub trajectory: Vec<(f64, f64, f64, f64)>,
}

Fields§

§theta1: f64§theta2: f64§target_x: f64§target_y: f64§trajectory: Vec<(f64, f64, f64, f64)>

Implementations§

Source§

impl TwoJointArm

Link lengths in metres; this planar arm has unrestricted revolute joints.

Source

pub fn new() -> Self

Source

pub fn set_target(&mut self, x: f64, y: f64)

Source

pub fn solve_inverse_kinematics(&mut self, goal_threshold: f64) -> bool

Source

pub fn inverse_kinematics( x: f64, y: f64, branch: ElbowBranch, ) -> Option<(f64, f64)>

Solve one analytic IK branch without moving the arm.

Returns None for nonfinite targets or targets outside the reachable disk. At the origin both unit links fold; the shoulder angle is underdetermined, so zero is returned as a deterministic representative.

Source

pub fn forward_kinematics(&self) -> (f64, f64)

Source

pub fn jacobian(&self) -> [[f64; 2]; 2]

Cartesian tip velocity is J * [shoulder_rate, elbow_rate]. Rows are x/y and columns are shoulder/elbow; link lengths are metres.

Source

pub fn damped_joint_velocity( &self, velocity: [f64; 2], damping: f64, ) -> Option<[f64; 2]>

Damped least-squares differential IK: dq = J^T (J J^T + λ² I)^-1 v.

Rates are rad/s for a requested velocity in m/s. No speed limit is applied. Returns None for nonfinite inputs, nonpositive damping, or an unrepresentable solve. Damping regularizes the matrix but cannot create motion in a Cartesian direction absent from the Jacobian.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V