Class LimbSolver
java.lang.Object
com.marginallyclever.ro3.node.Node
com.marginallyclever.ro3.node.nodes.limbsolver.LimbSolver
LimbSolver calculates Inverse Kinematics for
a Limb. Given a target and a linear velocity, LimbSolver will calculate and apply the
joint velocities required to move the end effector towards the target in a straight line. When the end effector
reaches the target (with a margin of error), LimbSolver will fire an ActionEvent "arrivedAtGoal".-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActionListener(ActionListener listener) voidfromJSON(org.json.JSONObject from) Deserialize this node and its children from a JSON object and its children.voidgetComponents(List<JPanel> list) Build a Swing Component that represents this Node.doubledoublegetIcon()Set a custom icon for this node.booleangetLimb()doublevoidbooleanvoidremoveActionListener(ActionListener listener) static voidscaleVectorToMagnitude(double[] vector, double maxLen) Make sure the given vector's length does not exceed linearVelocity.voidsetGoalMarginOfError(double goalMarginOfError) voidsetIsAtGoal(boolean isAtGoal) voidSet the limb to be controlled by this instance.voidsetLinearVelocity(double linearVelocity) Set the linear velocity of the end effector in cm/s.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.Node
addAttachListener, addChild, addChild, addDetachListener, addReadyListener, addRenameListener, findByPath, findChild, findChild, findFirstChild, findFirstSibling, findNodeByID, findParent, findParent, getAbsolutePath, getChildren, getName, getParent, getRootNode, getUniqueID, hasParent, isNameUsedBySibling, removeAttachListener, removeChild, removeDetachListener, removeReadyListener, removeRenameListener, setName, witnessProtection
-
Constructor Details
-
LimbSolver
public LimbSolver() -
LimbSolver
-
-
Method Details
-
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
-
getLimb
-
setLimb
Set the limb to be controlled by this instance. limb must be in the same node tree as this instance.- Parameters:
limb- the limb to control
-
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.
-
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. -
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() -
getComponents
Description copied from class:NodeBuild a Swing Component that represents this Node.- Overrides:
getComponentsin classNode- Parameters:
list- the list to add components to.
-
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() -
getIcon
-