From 20011a2f53c6bdb25f26102d99d8598020c84057 Mon Sep 17 00:00:00 2001 From: Taylor Howell Date: Mon, 5 Aug 2024 03:17:32 -0700 Subject: [PATCH] Disable RK4 integrator in mjd_transitionFD by throwing an error and improve documentation for mjd_transitionFD and mjd_inverseFD. PiperOrigin-RevId: 659492713 Change-Id: I84ab7ebfba34742f239f60311d8f0a55559995fb --- doc/APIreference/functions.rst | 9 +++++++++ doc/APIreference/functions_override.rst | 9 +++++++++ src/engine/engine_derivative_fd.c | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/doc/APIreference/functions.rst b/doc/APIreference/functions.rst index cbe5bb41..268c7f5c 100644 --- a/doc/APIreference/functions.rst +++ b/doc/APIreference/functions.rst @@ -2618,6 +2618,9 @@ These matrices and their dimensions are: fixed (small) value and solver :ref:`tolerance` is set to 0. This insures that all calls to the solver will perform exactly the same number of iterations. +.. attention:: + - The Runge-Kutta 4th-order integrator (``mjINT_RK4``) is not supported. + .. _mjd_inverseFD: mjd_inverseFD @@ -2654,6 +2657,12 @@ using finite-differencing. These matrices and their dimensions are: - ``eps`` is the (forward) finite-differencing epsilon. - ``flg_actuation`` denotes whether to subtract actuation forces (``qfrc_actuator``) from the output of the inverse dynamics. If this flag is positive, actuator forces are not considered as external. +- The model option flag ``invdiscrete`` should correspond to the representation of ``mjData.qacc`` in order to compute + the correct derivative information. + +.. attention:: + - The Runge-Kutta 4th-order integrator (``mjINT_RK4``) is not supported. + - The noslip solver is not supported. .. _mjd_subQuat: diff --git a/doc/APIreference/functions_override.rst b/doc/APIreference/functions_override.rst index b7e62d78..b9861402 100644 --- a/doc/APIreference/functions_override.rst +++ b/doc/APIreference/functions_override.rst @@ -592,6 +592,9 @@ These matrices and their dimensions are: fixed (small) value and solver :ref:`tolerance` is set to 0. This insures that all calls to the solver will perform exactly the same number of iterations. +.. attention:: + - The Runge-Kutta 4th-order integrator (``mjINT_RK4``) is not supported. + .. _mjd_inverseFD: Finite differenced continuous-time inverse-dynamics Jacobians. @@ -623,6 +626,12 @@ using finite-differencing. These matrices and their dimensions are: - ``eps`` is the (forward) finite-differencing epsilon. - ``flg_actuation`` denotes whether to subtract actuation forces (``qfrc_actuator``) from the output of the inverse dynamics. If this flag is positive, actuator forces are not considered as external. +- The model option flag ``invdiscrete`` should correspond to the representation of ``mjData.qacc`` in order to compute + the correct derivative information. + +.. attention:: + - The Runge-Kutta 4th-order integrator (``mjINT_RK4``) is not supported. + - The noslip solver is not supported. .. _mjd_subQuat: diff --git a/src/engine/engine_derivative_fd.c b/src/engine/engine_derivative_fd.c index 39148a56..84126ffa 100644 --- a/src/engine/engine_derivative_fd.c +++ b/src/engine/engine_derivative_fd.c @@ -548,6 +548,10 @@ void mjd_stepFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_centered, // D: (nsensordata x nu) void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_centered, mjtNum* A, mjtNum* B, mjtNum* C, mjtNum* D) { + if (m->opt.integrator == mjINT_RK4) { + mjERROR("RK4 integrator is not supported"); + } + int nv = m->nv, na = m->na, nu = m->nu, ns = m->nsensordata; int ndx = 2*nv+na; // row length of state Jacobians