skbot.inverse_kinematics.ccd

skbot.inverse_kinematics.ccd(targets, joints=None, *args, rtol=1e-06, maxiter=500, line_search_maxiter=500, weights=None, tol=None, cycle_links=None, pointA=None, pointB=None, frameA=None, frameB=None, metric=None)[source]

Cyclic Coordinate Descent.

Note

This function will modify the objects in joints as a side effect.

This function cycles through targets and joints. For each pair it - one joint at a time - chooses a value for the joint that minimizes the score of the target. If all targets are reached, this function returns the the corresponding joint parameters; otherwise an exception is raised.

Changed in version 0.10.0: CCD has a new signature and now makes use of Targets.

Changed in version 0.10.0: CCD can now jointly optimize for multiple targets.

New in version 0.7.0.

Parameters
targetsList[Target]

A list of quality measures that a successful pose minimizes.

jointsList[joint]

A list of 1DoF joints which should be adjusted to minimize targets.

rtolfloat

Relative tolerance for termination. If, after one full cycle, none of the targets have improved by more than rtol the algorithm terminates and assumes that a local optimum has been found.

maxiterint

The maximum number of times to cycle over target+joint pairs.

line_search_maxiterint

If no fast-path is implemented for a joint+target pair then CCD solves a 1D sub-optimization problem for the pair instead. This parameter limits the total number of iterations for this sub-optimization.

weightsList[float]

Deprecated since version 0.10.0: Targets are optimized cyclical instead of optimizing a weighted sum.

This parameter has no effect.

cycle_linksList[tf.Joint]

Deprecated since version 0.10.0: Use joints instead.

A list of 1DoF joints which should be adjusted to minimize targets.

tolfloat

Deprecated since version 0.10.0: Specify atol on the desired target instead.

Absolute tolerance for termination.

pointAArrayLike

Deprecated since version 0.10.0: Use targets and a ik.PositionTarget instead.

A list of points. The i-th pointA is represented in the i-th frame of frameA. If only one point is given, the list can be omitted and the point can be directly used as input.

pointBArrayLike

Deprecated since version 0.10.0: Use targets and a ik.PositionTarget instead.

The desired positions of each point given in pointA. The i-th pointB is represented in the i-th frame of frameB. If only one point is given, the list can be omitted and the point can be directly used as input.

frameAtf.Frame

Deprecated since version 0.10.0: Use targets and a ik.PositionTarget instead.

The frame in which the points in pointA are represented. The i-th element corresponds to the i-th pointA. If only one point is given, the list can be omitted and the frame can be directly used as input.

frameBtf.Frame

Deprecated since version 0.10.0: Use targets and a ik.PositionTarget instead.

The frame in which the points in pointB are represented. The i-th element corresponds to the i-th pointB. If only one point is given, the list can be omitted and the frame can be directly used as input.

metricCallable

Deprecated since version 0.10.0: Specify norm in a PositionTarget instead.

A function that takes two points (expressed in the corresponding frameB) and that computs the distance between them. Its signature is metric(transformed_point, pointB) -> distance. If None, the euclidian distance will be used.

Returns
joint_valuesList[float]

The final parameters of each joint.

Notes

Joint limits (min/max) are enforced as hard constraints.

The current implementation is a naive python implementation and not very optimized. PRs improving performance are welcome :)

References

kenwright2012

Kenwright, Ben. “Inverse kinematics-cyclic coordinate descent (CCD).” Journal of Graphics Tools 16.4 (2012): 177-217.

Return type

List[ndarray]