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
impl TwoJointArm
Sourcepub const LINK_LENGTHS: [f64; 2]
pub const LINK_LENGTHS: [f64; 2]
Link lengths in metres; this planar arm has unrestricted revolute joints.
pub fn new() -> Self
pub fn set_target(&mut self, x: f64, y: f64)
pub fn solve_inverse_kinematics(&mut self, goal_threshold: f64) -> bool
Sourcepub fn inverse_kinematics(
x: f64,
y: f64,
branch: ElbowBranch,
) -> Option<(f64, f64)>
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.
pub fn forward_kinematics(&self) -> (f64, f64)
Sourcepub fn jacobian(&self) -> [[f64; 2]; 2]
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.
Sourcepub fn damped_joint_velocity(
&self,
velocity: [f64; 2],
damping: f64,
) -> Option<[f64; 2]>
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§
impl Freeze for TwoJointArm
impl RefUnwindSafe for TwoJointArm
impl Send for TwoJointArm
impl Sync for TwoJointArm
impl Unpin for TwoJointArm
impl UnsafeUnpin for TwoJointArm
impl UnwindSafe for TwoJointArm
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> 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.