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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addActionListener
(ActionListener listener) void
fromJSON
(org.json.JSONObject from) Deserialize this node and its children from a JSON object and its children.void
getComponents
(List<JPanel> list) Build a Swing Component that represents this Node.double
double
boolean
getLimb()
double
void
boolean
void
removeActionListener
(ActionListener listener) static void
scaleVectorToMagnitude
(double[] vector, double maxLen) Make sure the given vector's length does not exceed maxLen.void
setGoalMarginOfError
(double goalMarginOfError) void
setIsAtGoal
(boolean isAtGoal) void
Set the limb to be controlled by this instance.void
setLinearVelocity
(double linearVelocity) Set the linear velocity of the end effector in cm/s.void
Set the target to move towards.org.json.JSONObject
toJSON()
Serialize this node and its children to a JSON object and its children.void
update
(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
public void update(double dt) Description copied from class:Node
Called every frame. -
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:Node
Serialize 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:Node
Deserialize 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 maxLen. It can be less than the given magnitude. If the maxLen is greater than the vector length, the vector is unchanged. 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:Node
Build a Swing Component that represents this Node.- Overrides:
getComponents
in 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()
-