java.lang.Object
com.marginallyclever.ro3.node.Node
com.marginallyclever.ro3.node.nodes.pose.Pose
com.marginallyclever.ro3.node.nodes.pose.poses.Limb
- All Implemented Interfaces:
PoseChangeListener,EventListener
Limb is a linear chain of bones driven by joints powered by muscles. Limb is designed to handle six joints or less.
- Bones are represented by
Poses. - Joints are represented by
HingeJoints. - Muscles are represented by
Motors. - The end of the chain - at the wrist - is a
Posecalled the end effector. - The target is a
Posethat the end effector is trying to reach at a given linear velocity.
Limbs perform both Forward Kinematics and
Inverse kinematics. In earlier versions of the app
the concerns were separated, but this made it difficult to tell who was in charge and led to cyclic, jittery behavior.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActionListener(ActionListener listener) voidvoidfromJSON(org.json.JSONObject from) Deserialize this node and its children from a JSON object and its children.double[]voidgetComponents(List<JPanel> list) Build a Swing Component that represents this Node.doubledoublegetIcon()Set a custom icon for this node.booleangetJoint(int index) Get the motor at the given index.doubleintvoidMove the target to the end effector's current pose, stopping all motion of the arm (because it is now at the target).booleanvoidremoveActionListener(ActionListener listener) voidstatic voidscaleVectorToMagnitude(double[] vector, double maxLen) Make sure the given vector's length does not exceed linearVelocity.voidsetAllJointAngles(double[] values) Set all joint angles at once while respecting the joint range limits.voidsetAllJointAnglesUnsafe(double[] values) Set all joint angles at once without respecting the joint range limits.voidsetAllJointVelocities(double @NotNull [] values) voidsetEndEffector(Pose pose) voidsetGoalMarginOfError(double goalMarginOfError) voidsetIsAtGoal(boolean isAtGoal) voidGet the motor at the given index.voidsetLinearVelocity(double linearVelocity) Set the linear velocity of the end effector in cm/s.voidsetMotorAngle(Motor motor, double angle) Move a motor to a specific angle and notify listeners that the pose has changed.voidSet the target to move towards.org.json.JSONObjecttoJSON()Serialize this node and its children to a JSON object and its children.voidupdate(double dt) Called every frame.Methods inherited from class com.marginallyclever.ro3.node.nodes.pose.Pose
addPoseChangeListener, getLocal, getParentPose, getPosition, getRotationEuler, getRotationIndex, getWorld, onPoseChange, removePoseChangeListener, setLocal, setPosition, setRotationEuler, setRotationIndex, setWorldMethods inherited from class com.marginallyclever.ro3.node.Node
addAttachListener, addChild, addChild, addDetachListener, addReadyListener, addRenameListener, findByPath, findChild, findChild, findFirstChild, findFirstSibling, findNodeByID, findParent, findParent, getAbsolutePath, getChildren, getName, getParent, getRootNode, getUniqueID, hasChild, hasParent, isNameUsedBySibling, removeAttachListener, removeChild, removeDetachListener, removeReadyListener, removeRenameListener, setName, witnessProtection
-
Field Details
-
MAX_JOINTS
public static final int MAX_JOINTS- See Also:
-
DEFAULT_LINEAR_VELOCITY
public static final double DEFAULT_LINEAR_VELOCITY- See Also:
-
DEFAULT_GOAL_MARGIN_OF_ERROR
public static final double DEFAULT_GOAL_MARGIN_OF_ERROR- See Also:
-
ACTION_ARRIVED_AT_GOAL
- See Also:
-
PROPERTY_POSE_CHANGED
- See Also:
-
-
Constructor Details
-
Limb
public Limb() -
Limb
-
-
Method Details
-
getEndEffector
-
setEndEffector
-
getMotors
-
getNumJoints
public int getNumJoints() -
getJoint
Get the motor at the given index.- Parameters:
index- the index of the motor to get.- Returns:
- the motor at the given index.
- Throws:
IndexOutOfBoundsException- if the index is out of range.
-
getAllJointAngles
public double[] getAllJointAngles() -
setJoint
Get the motor at the given index.- Parameters:
index- the index of the motor to get.newValue- the new motor to set.- Throws:
IndexOutOfBoundsException- if the index is out of range.
-
setAllJointAngles
public void setAllJointAngles(double[] values) Set all joint angles at once while respecting the joint range limits. Then notify listeners that the pose has changed.- Parameters:
values- the angles to set each joint to.
-
setAllJointAnglesUnsafe
public void setAllJointAnglesUnsafe(double[] values) Set all joint angles at once without respecting the joint range limits.- Parameters:
values- the angles to set each joint to.
-
setAllJointVelocities
public void setAllJointVelocities(double @NotNull [] values) -
toJSON
public org.json.JSONObject toJSON()Description copied from class:NodeSerialize this node and its children to a JSON object and its children. Classes that override this method should call super.toJSON() first, then add to the object returned. -
fromJSON
public void fromJSON(org.json.JSONObject from) Description copied from class:NodeDeserialize this node and its children from a JSON object and its children. Classes that override this method should call super.fromJSON(). When they do it will trigger the creation of child nodes. The child nodes will then call their own fromJSON() methods. -
getComponents
Description copied from class:PoseBuild a Swing Component that represents this Node.- Overrides:
getComponentsin classPose- Parameters:
list- the list to add components to.
-
getIcon
-
addPropertyChangeListener
-
removePropertyChangeListener
-
setMotorAngle
Move a motor to a specific angle and notify listeners that the pose has changed.- Parameters:
motor- the motor to moveangle- the angle to move the motor to
-
getTarget
-
setTarget
Set the target to move towards. target must be in the same node tree as this instance.- Parameters:
target- the target to move towards
-
update
-
readyToSolve
public boolean readyToSolve()- Returns:
- true if the solver has a limb, an end effector, and a target. Does not guarantee that a solution exists.
-
scaleVectorToMagnitude
public static void scaleVectorToMagnitude(double[] vector, double maxLen) Make sure the given vector's length does not exceed linearVelocity. This means as the limb approaches the target the velocity will slow down.
Store the results in the original array.
- Parameters:
vector- the vector to capmaxLen- the max length of the vector.
-
moveTargetToEndEffector
public void moveTargetToEndEffector()Move the target to the end effector's current pose, stopping all motion of the arm (because it is now at the target). -
getLinearVelocity
public double getLinearVelocity() -
setLinearVelocity
public void setLinearVelocity(double linearVelocity) Set the linear velocity of the end effector in cm/s.- Parameters:
linearVelocity- must be >= 0
-
getDistanceToTarget
public double getDistanceToTarget()- Returns:
- the distance to the target that is a combination of linear and angular distances.
-
getGoalMarginOfError
public double getGoalMarginOfError()- Returns:
- the distance to the target that is a combination of linear and angular distances.
-
setGoalMarginOfError
public void setGoalMarginOfError(double goalMarginOfError) - Parameters:
goalMarginOfError- the distance to the target that is a combination of linear and angular distances.
-
addActionListener
-
removeActionListener
-
setIsAtGoal
public void setIsAtGoal(boolean isAtGoal) -
getIsAtGoal
public boolean getIsAtGoal()
-