Replace double- or single-precision-denominated function calls in the engine with the equivalent mjtNum-denominated calls. This avoids unnecessary casting or precision loss when MuJoCo is compiled for 32-bit float precision. Accordingly, remove #include <math.h> from all engine source files.
build / windows-2022 (push) Has been cancelled
build / macos-12 (push) Has been cancelled
build / ubuntu-20.04-clang-10 (push) Has been cancelled
build / ubuntu-20.04-clang-11 (push) Has been cancelled
build / ubuntu-20.04-clang-12 (push) Has been cancelled
build / ubuntu-22.04-clang-13 (push) Has been cancelled
build / ubuntu-22.04-clang-14 (push) Has been cancelled
build / ubuntu-22.04-gcc-10 (push) Has been cancelled
build / ubuntu-22.04-gcc-11 (push) Has been cancelled
build / ubuntu-22.04-gcc-12 (push) Has been cancelled
build / ubuntu-22.04-gcc-9 (push) Has been cancelled

Also, minor type-related fixes in `user_mesh.cc`.

PiperOrigin-RevId: 675082329
Change-Id: Icc5eb9f9eb4fbf09b08d7d4b9b2929f414e4a75c
This commit is contained in:
Yuval Tassa
2024-09-16 03:39:11 -07:00
committed by Copybara-Service
parent dde25d039b
commit fd17b2144a
12 changed files with 52 additions and 64 deletions
+3 -4
View File
@@ -14,7 +14,6 @@
#include "engine/engine_vis_interact.h"
#include <math.h>
#include <stddef.h>
#include <mujoco/mjdata.h>
@@ -690,7 +689,7 @@ void mjv_applyPerturbForce(const mjModel* m, mjData* d, const mjvPerturb* pert)
mju_addTo3(svel, body_linvel);
// add critical damping force of selection point
mju_addToScl3(force, svel, -sqrtf(stiffness)*pert->localmass);
mju_addToScl3(force, svel, -mju_sqrt(stiffness)*pert->localmass);
// torque on body com due to force
mju_cross(torque, moment_arm, force);
@@ -698,7 +697,7 @@ void mjv_applyPerturbForce(const mjModel* m, mjData* d, const mjvPerturb* pert)
// add critically damped torsional torque along displacement axis
stiffness = m->vis.map.stiffnessrot;
mju_normalize3(diff);
mju_addToScl3(torque, diff, -sqrtf(stiffness)*inertia*mju_dot3(diff, body_rotvel));
mju_addToScl3(torque, diff, -mju_sqrt(stiffness)*inertia*mju_dot3(diff, body_rotvel));
}
if (((pert->active | pert->active2) & mjPERT_ROTATE)) {
@@ -709,7 +708,7 @@ void mjv_applyPerturbForce(const mjModel* m, mjData* d, const mjvPerturb* pert)
mju_negQuat(xiquat, xiquat);
mju_mulQuat(difquat, pert->refquat, xiquat);
mju_quat2Vel(torque, difquat, 1.0/(stiffness*inertia));
mju_addToScl3(torque, body_rotvel, -sqrtf(stiffness)*inertia);
mju_addToScl3(torque, body_rotvel, -mju_sqrt(stiffness)*inertia);
}
}