skbot.inverse_kinematics.ccd

skbot.inverse_kinematics.ccd(pointA, pointB, frameA, frameB, cycle_links, *, metric=None, tol=0.001, maxiter=500, line_search_maxiter=500)[source]

Cyclic Coordinate Descent.

Note

This function will modify the passed-in frame graph as a side effect.

New in version 0.7.0.

This function adjusts the parameters of the links in cycle_links such that a point that has pointA as its representation in frameA has pointB as representation in frameB. Parameters are fitted in a cyclical fashion, i.e., by repeatedly iterating over cycle_links. Each time the respective link’s parameter is updated to minimize the distance between pointB and pointA’s representation in frameB. Distance is measured in frameB using euclidian distance or a custom metric if provided.

Parameters
pointAArrayLike

The representation of the point in frameA.

pointBArrayLike

The desired representation of the point in frameB.

frameAtf.Frame

The frame in which pointA is represented.

frameBtf.Frame

The frame in which pointB is represented.

cycle_links: List[joint]

A list of 1DoF joints which should be adjusted to make pointA and pointB valid representations of the same point.

metricCallable

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

tolfloat

Absolute tolerance for termination.

maxiterint

The maximum number of cycles to perform.

line_search_maxiterint

The maximum number of iterations to use when optimizing a single joint.

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 :)

Return type

List[ndarray]