Topic/aba second order derivatives#2891
Conversation
There was a problem hiding this comment.
👋 Hi,
This is a reminder message to assign an extra build label to this Pull Request if needed.
By default, this PR will be build with minimal build options (URDF support and Python bindings)
The possible extra labels are:
- build_collision (build Pinocchio with coal support)
- build_casadi (build Pinocchio with CasADi support)
- build_autodiff (build Pinocchio with CppAD support)
- build_codegen (build Pinocchio with CppADCodeGen support)
- build_extra (build Pinocchio with extra algorithms)
- build_mpfr (build Pinocchio with Boost.Multiprecision support)
- build_sdf (build Pinocchio with SDF parser)
- build_accelerate (build Pinocchio with APPLE Accelerate framework support)
- build_all (build Pinocchio with ALL the options stated above)
Thanks.
The Pinocchio development team.
|
Hello @shubhamsingh91, Thanks for the contribution. Can you add in your PR message a description of this contribution content ? |
|
Thanks a lot @shubhamsingh91 for this very nice and helpful contribution. Will be highly useful for the entire community. |
43fdba2 to
e314065
Compare
|
@jorisv Yes! i ported over the core algorithm from my own implementation in a separate Pinocchio fork, a while back. I used Claude code to write some parts and formatting. |
380522e to
09a177f
Compare
The per-column forward sweep in ComputeABASecondOrderDerivatives was recomputing q-dependent quantities (jdata via jmodel.calc, liMi, oMi, J_cols, and the leaf body inertia in world frame) on every one of the 3*nv iterations, even though they only depend on q and are already populated by the preceding computeABADerivatives and ComputeRNEASecondOrderDerivatives calls. Restrict the per-column forward visitor to the acceleration-dependent work only: propagate data.oa[i] with zero gravity at the root, write ddJ_cols = oa x J_cols, reset data.oYcrb[i] to the cached leaf value (which the backward sweep then composites in place), and compute data.of[i] = oYcrb[i] * oa. The leaf body inertia is cached once in oYcrb_leaf before the loop, since the backward sweep mutates data.oYcrb on each per-column iteration. For humanoidRandom (nv=32) this drops ComputeABASecondOrderDerivatives median from ~2765us to ~2524us (~9 percent faster). Refs: stack-of-tasks#2891
718c42a to
6f3ee4b
Compare
Add ComputeABASecondOrderDerivatives, which evaluates the second-order partial derivatives of the Articulated Body Algorithm with respect to the joint configuration, velocity and torque. The four non-trivially non-zero tensors d2ddq_dqdq, d2ddq_dvdv, d2ddq_dqdv and d2ddq_dtaudq are also added to Data so the algorithm has matching scratch storage, and they are wired into the equality operator and serialization. The algorithm reuses computeABADerivatives and ComputeRNEASecondOrderDerivatives, then applies the chain-rule identity from Singh & Wensing, IEEE T-RO 2023 (https://ieeexplore.ieee.org/abstract/document/10449483) via a single Direct Matrix Multiplication with -M^-1, producing all four output tensors in one pass. Storage conventions follow the existing SO RNEA tensors: rows index the output joint-acceleration component, columns index the inner derivative variable, and pages index the outer derivative variable. Refs: stack-of-tasks#2691
Validate ComputeABASecondOrderDerivatives on the humanoidRandom model by comparing each of the four output tensors against a finite-difference reference built from computeABADerivatives at perturbed q and v, and also check that the Data-member overload agrees with the explicit 4-tensor output overload. Refs: stack-of-tasks#2691
Time ComputeABASecondOrderDerivatives alongside the existing COMUTE_RNEA_SECOND_ORDER_DERIVATIVES entry in benchmark/timings-derivatives.cpp. Refs: stack-of-tasks#2691
…orward dynamics derivatives
6f3ee4b to
17deb0e
Compare
Thanks for taking the time to make and fill out this pull request!
Description
This PR (discussed in #2691) adds the second-order derivatives of the unconstrained Articulated Body Algorithm as derived in this paper (https://ieeexplore.ieee.org/abstract/document/10449483).
The specific algorithm is from Eq~46 from the paper, and more details can be found in Fig.13. Note that this algorithm uses the rnea-second-order-derivatives, which were contributed previously as a part of #1860.
Paper can be accessed directly on researchGate.
Output of timings-derivatives:
Checklist
pre-commit run --all-filesorpixi run lint