Migrate types in mjs structs.

PiperOrigin-RevId: 942546629
Change-Id: I46f2b24b53a43361fdc67dc32f2af1c0ce8b1de8
This commit is contained in:
Yuval Tassa
2026-07-04 11:27:00 -07:00
committed by Copybara-Service
parent 315bcfbf3a
commit 11f1da0c44
15 changed files with 339 additions and 311 deletions
@@ -225,6 +225,13 @@ void ImGui_SpecElementTable::operator()(const char* label, mjtByte& val,
Input(val, ref);
}
void ImGui_SpecElementTable::operator()(const char* label, bool& val,
const bool& ref,
const char* tooltip) {
Label(label, tooltip);
Input(val, ref);
}
void ImGui_SpecElementTable::operator()(const char* label, mjtSize& val,
const mjtSize& ref,
const char* tooltip) {
@@ -257,6 +257,8 @@ class ImGui_SpecElementTable : public ImGui_DataPtrTable {
// Scalar values used by mjSpec elements.
void operator()(const char* label, mjtByte& val, const mjtByte& ref,
const char* tooltip);
void operator()(const char* label, bool& val, const bool& ref,
const char* tooltip);
void operator()(const char* label, mjtSize& val, const mjtSize& ref,
const char* tooltip);
void operator()(const char* label, int& val, const int& ref,
+5 -5
View File
@@ -1324,7 +1324,7 @@ const char* mjs_setToIntVelocity(mjsActuator* actuator, double kp, double kv[1],
double dampratio[1], double timeconst[1], double inheritrange) {
mjs_setToPosition(actuator, kp, kv, dampratio, timeconst, inheritrange);
actuator->dyntype = mjDYN_INTEGRATOR;
actuator->actlimited = 1;
actuator->actlimited = mjLIMITED_TRUE;
if (inheritrange > 0) {
if (actuator->actrange[0] || actuator->actrange[1]) {
@@ -1353,7 +1353,7 @@ const char* mjs_setToVelocity(mjsActuator* actuator, double kv) {
const char* mjs_setToDamper(mjsActuator* actuator, double kv) {
mjuu_zerovec(actuator->gainprm, mjNGAIN);
actuator->gainprm[2] = -kv;
actuator->ctrllimited = 1;
actuator->ctrllimited = mjLIMITED_TRUE;
actuator->dyntype = mjDYN_NONE;
actuator->gaintype = mjGAIN_AFFINE;
actuator->biastype = mjBIAS_NONE;
@@ -1435,7 +1435,7 @@ const char* mjs_setToMuscle(mjsActuator* actuator, double timeconst[2], double t
// Set to adhesion actuator.
const char* mjs_setToAdhesion(mjsActuator* actuator, double gain) {
actuator->gainprm[0] = gain;
actuator->ctrllimited = 1;
actuator->ctrllimited = mjLIMITED_TRUE;
actuator->gaintype = mjGAIN_FIXED;
actuator->biastype = mjBIAS_NONE;
@@ -1523,7 +1523,7 @@ const char* mjs_setToDCMotor(mjsActuator* actuator, double motorconst[2], double
}
actuator->forcerange[0] = -tau_max;
actuator->forcerange[1] = tau_max;
actuator->forcelimited = 1;
actuator->forcelimited = mjLIMITED_TRUE;
}
// saturation: [tau_max, i_max, (di/dt)_max]
@@ -1601,7 +1601,7 @@ const char* mjs_setToDCMotor(mjsActuator* actuator, double motorconst[2], double
actuator->actdim = actdim;
// enforce actlimited = 0; homogeneous bounds are invalid across DC motor states
actuator->actlimited = 0;
actuator->actlimited = mjLIMITED_FALSE;
// DC motor always uses actearly
actuator->actearly = 1;
+3 -3
View File
@@ -5045,9 +5045,9 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
// the internal compiler struct (not the spec) to avoid permanently mutating
// the spec (which would cause usethread="false" to appear in a saved XML).
struct ScopedDisableThreading {
mjtByte& ref;
mjtByte saved;
explicit ScopedDisableThreading(mjtByte& r) : ref(r), saved(r) { ref = 0; }
mjtBool& ref;
mjtBool saved;
explicit ScopedDisableThreading(mjtBool& r) : ref(r), saved(r) { ref = 0; }
~ScopedDisableThreading() { ref = saved; }
} disable_usethread(compiler.usethread);
#endif
+11
View File
@@ -179,6 +179,17 @@ class mjXUtil {
static bool MapValue(tinyxml2::XMLElement* elem, const char* attr, int* data,
const mjMap* map, int mapSz, bool required = false);
template <typename T>
static bool MapValue(tinyxml2::XMLElement* elem, const char* attr, T* data,
const mjMap* map, int mapSz, bool required = false) {
int value;
if (MapValue(elem, attr, &value, map, mapSz, required)) {
*data = static_cast<T>(value);
return true;
}
return false;
}
// find attribute, translate unique space-separated keys to data, return number of keys found
static int MapValues(tinyxml2::XMLElement* elem, const char* attr, int* data,
const mjMap* map, int mapSz, bool required = false);