The breakage was introduced in af12322e9d.
__has_builtin was introduced to GCC in version 10, and the arithmetic overflow builtins were available since version 5.
Fixesdeepmind/mujoco#386.
Tested with GCC 9.
PiperOrigin-RevId: 461463027
Change-Id: I76627539a5c0e7f5617b56a2c9ada9251bceb0f6
- Never modify `d->ctrl`:
- `ctrl` values which are outside their respective `ctrlrange` are clamped internally, but `d->ctrl` itself is unmodified.
- Similarly, if `mjWARN_BADCTRL` is raised (NaNs or huge values), `ctrl` is cleared internally, but `d->ctrl` itself is unmodified.
- `mjWARN_BADCTRL` is no longer raised for `d->ctrl` values that are larger in absolute value than `mjMAXVAL`, if clamping makes them smaller than that.
- Added `mju_clip()` utility function.
- Added missing warning string for `case mjWARN_BADCTRL`.
PiperOrigin-RevId: 459025950
Change-Id: Ifbf974f9c02c3d70afdaa3114018fc81dfd746d3
- Add basic test for keyframes.
- Add missing documentation for keyframe mocap positions and quaternions.
PiperOrigin-RevId: 459021649
Change-Id: I91cf7ecbddc6262e8c72a868eeb82d627f389fb3
mj_makeModel returns NULL if any of the array sizes are negative. Callers of the function need to handle that case.
PiperOrigin-RevId: 457948558
Change-Id: I9a5c8c0d3293ed0a92c5791f00d3ed34c848e024
- Add `qH` and `qHDiagInv` to `mjData` to save factorized modified inertia.
- Add `mj_EulerSkip`, `mj_implicitSkip`, to `engine_forward.c`.
- Using the above functions, implement `mj_stepSkip` in `engine_derivative.c`.
- Add `mjd_stepFD` and `mjd_transitionFD` to `engine_derivative.c` to compute `mj_step` Jacobians.
- Exploit "Skip" functionality for speed.
- Correctly handle quaternion derivatives.
- Handle warmstarts and control limits.
PiperOrigin-RevId: 456584811
Change-Id: Iee8541f11e7b66feb8f431cb102d9bbe65461f79
- Introduced private function `mj_advance()` as single point of state & time advancement.
PiperOrigin-RevId: 456525969
Change-Id: Iae17217e305c7baf07cb5ecd1e1b84b936421097
When using MSAN, mjData->buffer is marked as poisoned, despite being initialized with zeroes.
This is useful for catching computations that accidentally use uninitialized values.
However, when using engine_print, it's OK to assume the buffer is initialized to zeros.
PiperOrigin-RevId: 456085776
Change-Id: I9d85e37fa82958eb54ac413140543a6581aa46ad
This will allow us to add fields that can't be cast to int or double, without breaking print.
PiperOrigin-RevId: 456005913
Change-Id: I1fccfd11466f4745f69172af0ae61be07642927c
I am running through simulate.swift (my port of simulate.cc) with
address sanitizer to discover related bugs.
Besides ones in my port, there are two in MuJoCo:
1. in maketext, the logic to find . is not protected against j is less
than 0 (due to the decreasing logic above), creating out of bound
access.
2. in mj_printFormattedData, qfrc_applied should use length nv not nq,
otherwise out of bound access could be triggered.
Test Plan:
Run through the simulate.cc with asan. Before this fix, when presenting
profiler view, it will trigger bug #1. When print data, it will trigger
bug #2. Both are using model/humanoid/22_humanoids.xml.
The introduction of additional mjData arrays for the implicit integrator caused in a shift in data alignment in memory. In certain combinations of machines and models, this change resulted in ~5% performance regression that appears to be attributable to L2 cache misses.
This change aligns all arrays in mjData to the boundary of a typical L2 cache line size. Benchmarking shows that this resolves the performance regression on a Broadwell machine.
PiperOrigin-RevId: 451652783
Change-Id: I4ed2c2d03453a83a0b4a9b8e224e2fd7c0dadea9
This allows us to detect reads and writes that are logically out of bounds.
PiperOrigin-RevId: 451520772
Change-Id: I614a8062c404d97148166bcd37db399420956d8b
Indiscriminate memset into d->buffer and m->buffer previously caused msan to not detect uninitialized reads.
Also fix tests with uninitialized read bugs that are detected by msan after this change.
PiperOrigin-RevId: 451508224
Change-Id: I1f4b080a8ef765c34ba7a0adc2c686419f6e5516
Before this change, xipos[0,1,2] was only set to 0 by mj_resetData zeroing the entire buffer.
When using mj_resetDataDebug, the value would be wrong.
PiperOrigin-RevId: 450939814
Change-Id: I887dd977161c7d132a80b766db7be23350ffb50b
Added analytic derivatives of smooth (unconstrained) dynamics forces, with respect to velocities:
- Centripetal and Coriolis forces computed by the Recursive Newton-Euler algorithm.
- Damping and fluid-drag passive forces.
- Actuation forces.
A new implicit-in-velocity integrator is implemented using the analytic derivatives. This integrator lies between the Euler and Runge Kutta integrators in terms of both stability and computational cost.
PiperOrigin-RevId: 450377010
Change-Id: Ie192b441876c22e732fb749333926f296e0a09cc