Add ProxQP differential inverse kinematics in Python#385
Conversation
|
😎😎 |
pariterre
left a comment
There was a problem hiding this comment.
@pariterre reviewed 3 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on mickaelbegon).
binding/python3/rigid_body.py line 21 at r1 (raw file):
class DifferentialInverseKinematicsResult: fun: np.ndarray nfev: int
Can these names be more specific and/or described in a docstring?
binding/python3/rigid_body.py line 464 at r1 (raw file):
class DifferentialInverseKinematics(InverseKinematics):
(I assume this is AI coded, so here is a prompt that should be tested)
Can you move this class and the base class in a dedicated file (and folder?)
If the base class can/should be abstracted, this should be done and the current backend should be given a proper distinctive name.
I feel an API that gives something like this:
ik = InverseKinematics(solver=INVERSE_KINEMATICS_SOLVER.IPOPT, ...)
ik.solve()could be nice
If it increases the complexity too much, do not do it and keep the two current classes
binding/python3/rigid_body.py line 471 at r1 (raw file):
handles marker tracking and generalized-coordinate bounds, but no holonomic loop constraints. """
Can this docstring explains the pros and cons against other approaches?
binding/python3/rigid_body.py line 584 at r1 (raw file):
success = False iterations = 0 for iterations in range(1, max_iterations + 1):
Isn't doing the main loop in Python slow?
Should this logic be moved in a dedicated C++ class and fully compiled?
pariterre
left a comment
There was a problem hiding this comment.
@pariterre reviewed 3 files and all commit messages, and resolved 4 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on mickaelbegon).
Summary
DifferentialInverseKinematicssolver using ProxQP for repeated linearized marker-tracking QPsInverseKinematicsProxQPas an alias and keepproxsuiteas an optional dependencyMarkerLoopClosureConstraintScope
This is a first Python implementation for marker-tracking differential inverse kinematics with generalized-coordinate bounds. Loop closure is supported for marker-marker constraints by linearizing the closure residual into equality constraints in the QP. Point-on-ellipsoid constraints are not included yet.
References and acknowledgements
Validation
PYTHONPYCACHEPREFIX=/private/tmp/biorbd_pycache python3 -m py_compile binding/python3/inverse_kinematics.py binding/python3/rigid_body.py examples/python3/inverse_kinematics_loop_constraint.py test/binding/python3/test_inverse_kinematics.pytest_inverse_kinematics.py:6 passed, 1 skipped, 2 warningsgit diff --checkExploratory benchmark
Small synthetic benchmark on 20 frames from
pyomecaman.bioMod, with markers generated exactly by the model:only_lm3.99e-173.38e-162.36e-16lm1.62e-41.30e-21.13e-2trf3.38e-31.44e-25.31e-2proxqp_dik_cold_103.38e-31.44e-25.31e-2proxqp_dik_warm_23.22e-31.44e-25.19e-2proxqp_dik_warm_53.22e-31.44e-25.19e-2Loop-closure example benchmark
examples/python3/inverse_kinematics_loop_constraint.pycreates a temporary loop-constrained model with tracking markers, hides the closure markers from the measurements, and compares unconstrained least-squares/DIK with constrained TRF and constrained DIK.trf_loopsolves marker tracking plus loop closure as an augmentedscipy.optimize.least_squares(method="trf")residual, whileproxqp_dik_loopsolves the linearized closure as a QP equality constraint:only_lm4.52e-122.64e-082.16e-07lm1.22e-122.64e-082.16e-07trf4.76e-112.65e-082.16e-07trf_loop5.59e-091.30e-128.42e-12proxqp_dik3.31e-112.64e-082.16e-07proxqp_dik_loop5.59e-092.57e-121.52e-11The benchmarks are intentionally small and should be interpreted as sanity checks rather than final performance claims.
This change is