Package org.chsrobotics.lib.models
Class DoubleJointedArmKinematics
java.lang.Object
org.chsrobotics.lib.models.DoubleJointedArmKinematics
Class for performing forward and inverse kinematic operations to determine the configuration of
an arm with 2 revolute (rotational) degrees of freedom.
Units of linear distance in this class are not specified, but must be consistent.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordData class holding information about the state of a double revolute-jointed arm. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal doubleLength of the distal segment (the segment closest to the end effector).final doubleLength of the local segment (the segment closest to the root). -
Constructor Summary
ConstructorsConstructorDescriptionDoubleJointedArmKinematics(double localLength, double distalLength) Constructs a DoubleJointedArmKinematics. -
Method Summary
Modifier and TypeMethodDescriptionforwardKinematics(double localAngle, double distalAngle) Determines the position of the end effector in 2-dimensional space, given the angles of the joints.inverseKinematics(double endEffectorX, double endEffectorY) Returns a tuple of 2 RRConfigurations with the joint angles required for the end effector to reach a certain position in a Cartesian frame.
-
Field Details
-
localLength
public final double localLengthLength of the local segment (the segment closest to the root). -
distalLength
public final double distalLengthLength of the distal segment (the segment closest to the end effector).
-
-
Constructor Details
-
DoubleJointedArmKinematics
public DoubleJointedArmKinematics(double localLength, double distalLength) Constructs a DoubleJointedArmKinematics.If either of the below are zero or less, this class's methods will return
null.- Parameters:
localLength- Length of the local segment (the segment closest to the root).distalLength- Length of the distal segment (the segment closest to the end effector).
-
-
Method Details
-
forwardKinematics
public DoubleJointedArmKinematics.RRConfiguration forwardKinematics(double localAngle, double distalAngle) Determines the position of the end effector in 2-dimensional space, given the angles of the joints.- Parameters:
localAngle- Angle of the local joint (the joint connected to the root), in radians, from (counterclockwise) the horizontal (or the positive x-axis in non-vertically oriented setups).distalAngle- Angle of the distal joint (the joint between arm segments), in radians, from (counterclockwise) parallel with the local joint.- Returns:
- A RRConfiguration describing the orientation.
-
inverseKinematics
public Tuple2<DoubleJointedArmKinematics.RRConfiguration> inverseKinematics(double endEffectorX, double endEffectorY) Returns a tuple of 2 RRConfigurations with the joint angles required for the end effector to reach a certain position in a Cartesian frame.Two returned RRConfigurations are needed because there are 2 inverse kinematic solutions to most possible cases. When only one solution exists, it is returned twice.
If the goal point is (0,0), there are either 0 or an infinite number of solutions, depending on arm lengths, so a tuple of
nulls is returned.This will also return
nulls if there are no solutions to reach the goal position. This happens whensqrt(x^2 + y^2) > lenA + lenB, orsqrt(x^2 + y^2) < |lenA - lenB|.No guarantees are made about the actual feasibility of these configurations on hardware.
- Parameters:
endEffectorX- The x-position of the end effector in Cartesian space.endEffectorY- The y-position of the end effector in Cartesian space.- Returns:
- A Tuple2 of up to 2 (possibly 0!) unique valid inverse kinematic solutions.
-