diff --git a/doc/includes/references.h b/doc/includes/references.h index 9887de34..764b9bf2 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -1476,21 +1476,21 @@ typedef enum mjtGeomInertia { // type of inertia inference mjINERTIA_VOLUME = 0, // mass distributed in the volume mjINERTIA_SHELL, // mass distributed on the surface } mjtGeomInertia; -typedef enum mjtMeshInertia { // type of mesh inertia - mjMESH_INERTIA_CONVEX = 0, // convex mesh inertia - mjMESH_INERTIA_EXACT, // exact mesh inertia - mjMESH_INERTIA_LEGACY, // legacy mesh inertia - mjMESH_INERTIA_SHELL // shell mesh inertia +typedef enum mjtMeshInertia { // type of mesh inertia + mjMESH_INERTIA_CONVEX = 0, // convex mesh inertia + mjMESH_INERTIA_EXACT, // exact mesh inertia + mjMESH_INERTIA_LEGACY, // legacy mesh inertia + mjMESH_INERTIA_SHELL // shell mesh inertia } mjtMeshInertia; -typedef enum mjtMeshBuiltin { // type of built-in procedural mesh - mjMESH_BUILTIN_NONE = 0, // no built-in mesh - mjMESH_BUILTIN_SPHERE, // sphere - mjMESH_BUILTIN_HEMISPHERE, // hemisphere - mjMESH_BUILTIN_CONE, // cone - mjMESH_BUILTIN_SUPERSPHERE, // supersphere - mjMESH_BUILTIN_SUPERTORUS, // supertorus - mjMESH_BUILTIN_WEDGE, // wedge - mjMESH_BUILTIN_PLATE, // plate +typedef enum mjtMeshBuiltin { // type of built-in procedural mesh + mjMESH_BUILTIN_NONE = 0, // no built-in mesh + mjMESH_BUILTIN_SPHERE, // sphere + mjMESH_BUILTIN_HEMISPHERE, // hemisphere + mjMESH_BUILTIN_CONE, // cone + mjMESH_BUILTIN_SUPERSPHERE, // supersphere + mjMESH_BUILTIN_SUPERTORUS, // supertorus + mjMESH_BUILTIN_WEDGE, // wedge + mjMESH_BUILTIN_PLATE, // plate } mjtMeshBuiltin; typedef enum mjtBuiltin { // type of built-in procedural texture mjBUILTIN_NONE = 0, // no built-in texture @@ -1526,12 +1526,12 @@ typedef enum mjtOrientation { // type of orientation specifier mjORIENTATION_ZAXIS, // z axis (minimal rotation) mjORIENTATION_EULER, // Euler angles } mjtOrientation; -typedef enum mjtConflict { // conflict resolution for attach - mjCONFLICT_WARNING = 0, // keep parent, warn on conflict - mjCONFLICT_MERGE, // merge: min/max/error per field - mjCONFLICT_ERROR, // error on any conflict +typedef enum mjtConflict { // conflict resolution for attach + mjCONFLICT_WARNING = 0, // keep parent, warn on conflict + mjCONFLICT_MERGE, // merge: min/max/error per field + mjCONFLICT_ERROR, // error on any conflict } mjtConflict; -typedef enum mjtCTimer { // compiler timing categories +typedef enum mjtCTimer { // compiler timing categories // top-level timers (wall-clock) mjCTIMER_TOTAL = 0, // total compile time mjCTIMER_ASSETS, // asset compilation @@ -1552,22 +1552,22 @@ typedef struct mjsElement_ { // element type, do not modify uint64_t signature; // compilation signature } mjsElement; typedef struct mjsCompiler_ { // compiler options - mjtByte autolimits; // infer "limited" attribute based on range + mjtBool autolimits; // infer "limited" attribute based on range double boundmass; // enforce minimum body mass double boundinertia; // enforce minimum body diagonal inertia double settotalmass; // rescale masses and inertias; <=0: ignore - mjtByte balanceinertia; // automatically impose A + B >= C rule - mjtByte fitaabb; // meshfit to aabb instead of inertia box - mjtByte degree; // angles in radians or degrees + mjtBool balanceinertia; // automatically impose A + B >= C rule + mjtBool fitaabb; // meshfit to aabb instead of inertia box + mjtBool degree; // angles in radians or degrees char eulerseq[3]; // sequence for euler rotations - mjtByte discardvisual; // discard visual geoms in parser - mjtByte usethread; // use multiple threads to speed up compiler - mjtByte fusestatic; // fuse static bodies with parent - int inertiafromgeom; // use geom inertias (mjtInertiaFromGeom) + mjtBool discardvisual; // discard visual geoms in parser + mjtBool usethread; // use multiple threads to speed up compiler + mjtBool fusestatic; // fuse static bodies with parent + mjtInertiaFromGeom inertiafromgeom; // use geom inertias int inertiagrouprange[2]; // range of geom groups used to compute inertia - mjtByte saveinertial; // save explicit inertial clause for all bodies to XML - int alignfree; // align free joints with inertial frame - int conflict; // conflict resolution for attach (mjtConflict) + mjtBool saveinertial; // save explicit inertial clause for all bodies to XML + mjtBool alignfree; // align free joints with inertial frame + mjtConflict conflict; // conflict resolution for attach mjLROpt LRopt; // options for lengthrange computation mjString* meshdir; // mesh and hfield directory mjString* texturedir; // texture directory @@ -1591,7 +1591,7 @@ typedef struct mjSpec_ { // model specification // compiler data mjsCompiler compiler; // compiler options - mjtByte strippath; // automatically strip paths from mesh files + mjtBool strippath; // automatically strip paths from mesh files // engine data mjOption option; // physics options @@ -1620,7 +1620,7 @@ typedef struct mjSpec_ { // model specification mjString* modelfiledir; // path to model file // other - mjtByte hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator + mjtBool hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator // authored tracking bitmasks for mjModel structs mjsAuthored authored; @@ -1636,7 +1636,7 @@ typedef struct mjsPlugin_ { // plugin specification mjsElement* element; // element type mjString* name; // instance name mjString* plugin_name; // plugin name - mjtByte active; // is the plugin active + mjtBool active; // is the plugin active mjString* info; // message appended to compiler errors } mjsPlugin; typedef struct mjsBody_ { // body specification @@ -1657,12 +1657,12 @@ typedef struct mjsBody_ { // body specification double fullinertia[6]; // non-axis-aligned inertia matrix // other - mjtByte mocap; // is this a mocap body + mjtBool mocap; // is this a mocap body double gravcomp; // gravity compensation mjtSleepPolicy sleep; // sleep policy mjtByte simple; // simple body optimization (0: false, 1: auto) mjDoubleVec* userdata; // user data - mjtByte explicitinertial; // whether to save the body with explicit inertial clause + mjtBool explicitinertial; // whether to save the body with explicit inertial clause mjsPlugin plugin; // passive force plugin mjString* info; // message appended to compiler errors } mjsBody; @@ -1682,7 +1682,7 @@ typedef struct mjsJoint_ { // joint specification double pos[3]; // anchor position double axis[3]; // joint axis double ref; // value at reference configuration: qpos0 - int align; // align free joint with body com (mjtAlignFree) + mjtAlignFree align; // align free joint with body com // stiffness double stiffness[mjNPOLY+1]; // stiffness coefficients @@ -1690,12 +1690,12 @@ typedef struct mjsJoint_ { // joint specification double springdamper[2]; // timeconst, dampratio // limits - int limited; // does joint have limits (mjtLimited) + mjtLimited limited; // does joint have limits double range[2]; // joint limits double margin; // margin value for joint limit detection mjtNum solref_limit[mjNREF]; // solver reference: joint limits mjtNum solimp_limit[mjNIMP]; // solver impedance: joint limits - int actfrclimited; // are actuator forces on joint limited (mjtLimited) + mjtLimited actfrclimited; // are actuator forces on joint limited double actfrcrange[2]; // actuator force limits // dof properties @@ -1707,7 +1707,7 @@ typedef struct mjsJoint_ { // joint specification // other int group; // group - mjtByte actgravcomp; // is gravcomp force applied via actuators + mjtBool actgravcomp; // is gravcomp force applied via actuators mjDoubleVec* userdata; // user data mjString* info; // message appended to compiler errors } mjsJoint; @@ -1813,10 +1813,10 @@ typedef struct mjsLight_ { // light specification mjString* targetbody; // target body for targeting // intrinsics - mjtByte active; // is light active + mjtBool active; // is light active mjtLightType type; // type of light mjString* texture; // texture name for image lights - mjtByte castshadow; // does light cast shadows + mjtBool castshadow; // does light cast shadows float bulbradius; // bulb radius, for soft shadows float intensity; // intensity, in candelas float range; // range of effectiveness @@ -1828,7 +1828,7 @@ typedef struct mjsLight_ { // light specification float specular[3]; // specular color // other - mjString* info; // message appended to compiler errorsx + mjString* info; // message appended to compiler errors } mjsLight; typedef struct mjsFlex_ { // flex specification mjsElement* element; // element type @@ -1849,9 +1849,9 @@ typedef struct mjsFlex_ { // flex specification int dim; // element dimensionality double radius; // radius around primitive element double size[3]; // vertex bounding box half sizes in qpos0 - mjtByte internal; // enable internal collisions - mjtByte flatskin; // render flex skin with flat shading - int selfcollide; // mode for flex self collision + mjtBool internal; // enable internal collisions + mjtBool flatskin; // render flex skin with flat shading + mjtFlexSelf selfcollide; // mode for flex self collision int passive; // mode for passive collisions int activelayers; // number of active element layers in 3D int group; // group for visualization @@ -1887,8 +1887,8 @@ typedef struct mjsMesh_ { // mesh specification double refquat[4]; // reference orientation double scale[3]; // rescale mesh mjtMeshInertia inertia; // inertia type (convex, legacy, exact, shell) - mjtByte smoothnormal; // do not exclude large-angle faces from normals - mjtByte needsdf; // compute sdf from mesh + mjtBool smoothnormal; // do not exclude large-angle faces from normals + mjtBool needsdf; // compute sdf from mesh int maxhullvert; // maximum vertex count for the convex hull mjFloatVec* uservert; // user vertex data mjFloatVec* usernormal; // user normal data @@ -1940,8 +1940,8 @@ typedef struct mjsTexture_ { // texture specification mjtColorSpace colorspace; // colorspace // method 1: builtin - int builtin; // builtin type (mjtBuiltin) - int mark; // mark type (mjtMark) + mjtBuiltin builtin; // builtin type + mjtMark mark; // mark type double rgb1[3]; // first color for builtin double rgb2[3]; // second color for builtin double markrgb[3]; // mark color @@ -1963,8 +1963,8 @@ typedef struct mjsTexture_ { // texture specification mjByteVec* data; // texture data // flip options - mjtByte hflip; // horizontal flip - mjtByte vflip; // vertical flip + mjtBool hflip; // horizontal flip + mjtBool vflip; // vertical flip // other mjString* info; // message appended to compiler errors @@ -1972,7 +1972,7 @@ typedef struct mjsTexture_ { // texture specification typedef struct mjsMaterial_ { // material specification mjsElement* element; // element type mjStringVec* textures; // names of textures (empty: none) - mjtByte texuniform; // make texture cube uniform + mjtBool texuniform; // make texture cube uniform float texrepeat[2]; // texture repetition for 2D mapping float emission; // emission float specular; // specular @@ -2008,7 +2008,7 @@ typedef struct mjsEquality_ { // equality specification mjsElement* element; // element type mjtEq type; // constraint type double data[mjNEQDATA]; // type-dependent data - mjtByte active; // is equality initially active + mjtBool active; // is equality initially active mjString* name1; // name of object 1 mjString* name2; // name of object 2 mjtObj objtype; // type of both objects @@ -2029,8 +2029,8 @@ typedef struct mjsTendon_ { // tendon specification double armature; // inertia associated with tendon velocity // length range - int limited; // does tendon have limits (mjtLimited) - int actfrclimited; // does tendon have actuator force limits + mjtLimited limited; // does tendon have limits + mjtLimited actfrclimited; // does tendon have actuator force limits double range[2]; // length limits double actfrcrange[2]; // actuator force limits double margin; // margin value for tendon limit detection @@ -2065,7 +2065,7 @@ typedef struct mjsActuator_ { // actuator specification mjtDyn dyntype; // dynamics type double dynprm[mjNDYN]; // dynamics parameters int actdim; // number of activation variables - mjtByte actearly; // apply next activations to qfrc + mjtBool actearly; // apply next activations to qfrc // transmission mjtTrn trntype; // transmission type @@ -2080,11 +2080,11 @@ typedef struct mjsActuator_ { // actuator specification double armature; // armature inertia // input/output clamping - int ctrllimited; // are control limits defined (mjtLimited) + mjtLimited ctrllimited; // are control limits defined double ctrlrange[2]; // control range - int forcelimited; // are force limits defined (mjtLimited) + mjtLimited forcelimited; // are force limits defined double forcerange[2]; // force range - int actlimited; // are activation limits defined (mjtLimited) + mjtLimited actlimited; // are activation limits defined double actrange[2]; // activation range // other diff --git a/include/mujoco/mjspec.h b/include/mujoco/mjspec.h index 40863072..e139a4ca 100644 --- a/include/mujoco/mjspec.h +++ b/include/mujoco/mjspec.h @@ -63,23 +63,23 @@ typedef enum mjtGeomInertia { // type of inertia inference } mjtGeomInertia; -typedef enum mjtMeshInertia { // type of mesh inertia - mjMESH_INERTIA_CONVEX = 0, // convex mesh inertia - mjMESH_INERTIA_EXACT, // exact mesh inertia - mjMESH_INERTIA_LEGACY, // legacy mesh inertia - mjMESH_INERTIA_SHELL // shell mesh inertia +typedef enum mjtMeshInertia { // type of mesh inertia + mjMESH_INERTIA_CONVEX = 0, // convex mesh inertia + mjMESH_INERTIA_EXACT, // exact mesh inertia + mjMESH_INERTIA_LEGACY, // legacy mesh inertia + mjMESH_INERTIA_SHELL // shell mesh inertia } mjtMeshInertia; -typedef enum mjtMeshBuiltin { // type of built-in procedural mesh - mjMESH_BUILTIN_NONE = 0, // no built-in mesh - mjMESH_BUILTIN_SPHERE, // sphere - mjMESH_BUILTIN_HEMISPHERE, // hemisphere - mjMESH_BUILTIN_CONE, // cone - mjMESH_BUILTIN_SUPERSPHERE, // supersphere - mjMESH_BUILTIN_SUPERTORUS, // supertorus - mjMESH_BUILTIN_WEDGE, // wedge - mjMESH_BUILTIN_PLATE, // plate +typedef enum mjtMeshBuiltin { // type of built-in procedural mesh + mjMESH_BUILTIN_NONE = 0, // no built-in mesh + mjMESH_BUILTIN_SPHERE, // sphere + mjMESH_BUILTIN_HEMISPHERE, // hemisphere + mjMESH_BUILTIN_CONE, // cone + mjMESH_BUILTIN_SUPERSPHERE, // supersphere + mjMESH_BUILTIN_SUPERTORUS, // supertorus + mjMESH_BUILTIN_WEDGE, // wedge + mjMESH_BUILTIN_PLATE, // plate } mjtMeshBuiltin; @@ -128,13 +128,13 @@ typedef enum mjtOrientation { // type of orientation specifier mjORIENTATION_EULER, // Euler angles } mjtOrientation; -typedef enum mjtConflict { // conflict resolution for attach - mjCONFLICT_WARNING = 0, // keep parent, warn on conflict - mjCONFLICT_MERGE, // merge: min/max/error per field - mjCONFLICT_ERROR, // error on any conflict +typedef enum mjtConflict { // conflict resolution for attach + mjCONFLICT_WARNING = 0, // keep parent, warn on conflict + mjCONFLICT_MERGE, // merge: min/max/error per field + mjCONFLICT_ERROR, // error on any conflict } mjtConflict; -typedef enum mjtCTimer { // compiler timing categories +typedef enum mjtCTimer { // compiler timing categories // top-level timers (wall-clock) mjCTIMER_TOTAL = 0, // total compile time mjCTIMER_ASSETS, // asset compilation @@ -161,22 +161,22 @@ typedef struct mjsElement_ { // element type, do not modify typedef struct mjsCompiler_ { // compiler options - mjtByte autolimits; // infer "limited" attribute based on range + mjtBool autolimits; // infer "limited" attribute based on range double boundmass; // enforce minimum body mass double boundinertia; // enforce minimum body diagonal inertia double settotalmass; // rescale masses and inertias; <=0: ignore - mjtByte balanceinertia; // automatically impose A + B >= C rule - mjtByte fitaabb; // meshfit to aabb instead of inertia box - mjtByte degree; // angles in radians or degrees + mjtBool balanceinertia; // automatically impose A + B >= C rule + mjtBool fitaabb; // meshfit to aabb instead of inertia box + mjtBool degree; // angles in radians or degrees char eulerseq[3]; // sequence for euler rotations - mjtByte discardvisual; // discard visual geoms in parser - mjtByte usethread; // use multiple threads to speed up compiler - mjtByte fusestatic; // fuse static bodies with parent - int inertiafromgeom; // use geom inertias (mjtInertiaFromGeom) + mjtBool discardvisual; // discard visual geoms in parser + mjtBool usethread; // use multiple threads to speed up compiler + mjtBool fusestatic; // fuse static bodies with parent + mjtInertiaFromGeom inertiafromgeom; // use geom inertias int inertiagrouprange[2]; // range of geom groups used to compute inertia - mjtByte saveinertial; // save explicit inertial clause for all bodies to XML - int alignfree; // align free joints with inertial frame - int conflict; // conflict resolution for attach (mjtConflict) + mjtBool saveinertial; // save explicit inertial clause for all bodies to XML + mjtBool alignfree; // align free joints with inertial frame + mjtConflict conflict; // conflict resolution for attach mjLROpt LRopt; // options for lengthrange computation mjString* meshdir; // mesh and hfield directory mjString* texturedir; // texture directory @@ -204,7 +204,7 @@ typedef struct mjSpec_ { // model specification // compiler data mjsCompiler compiler; // compiler options - mjtByte strippath; // automatically strip paths from mesh files + mjtBool strippath; // automatically strip paths from mesh files // engine data mjOption option; // physics options @@ -233,7 +233,7 @@ typedef struct mjSpec_ { // model specification mjString* modelfiledir; // path to model file // other - mjtByte hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator + mjtBool hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator // authored tracking bitmasks for mjModel structs mjsAuthored authored; @@ -253,7 +253,7 @@ typedef struct mjsPlugin_ { // plugin specification mjsElement* element; // element type mjString* name; // instance name mjString* plugin_name; // plugin name - mjtByte active; // is the plugin active + mjtBool active; // is the plugin active mjString* info; // message appended to compiler errors } mjsPlugin; @@ -276,12 +276,12 @@ typedef struct mjsBody_ { // body specification double fullinertia[6]; // non-axis-aligned inertia matrix // other - mjtByte mocap; // is this a mocap body + mjtBool mocap; // is this a mocap body double gravcomp; // gravity compensation mjtSleepPolicy sleep; // sleep policy mjtByte simple; // simple body optimization (0: false, 1: auto) mjDoubleVec* userdata; // user data - mjtByte explicitinertial; // whether to save the body with explicit inertial clause + mjtBool explicitinertial; // whether to save the body with explicit inertial clause mjsPlugin plugin; // passive force plugin mjString* info; // message appended to compiler errors } mjsBody; @@ -305,7 +305,7 @@ typedef struct mjsJoint_ { // joint specification double pos[3]; // anchor position double axis[3]; // joint axis double ref; // value at reference configuration: qpos0 - int align; // align free joint with body com (mjtAlignFree) + mjtAlignFree align; // align free joint with body com // stiffness double stiffness[mjNPOLY+1]; // stiffness coefficients @@ -313,12 +313,12 @@ typedef struct mjsJoint_ { // joint specification double springdamper[2]; // timeconst, dampratio // limits - int limited; // does joint have limits (mjtLimited) + mjtLimited limited; // does joint have limits double range[2]; // joint limits double margin; // margin value for joint limit detection mjtNum solref_limit[mjNREF]; // solver reference: joint limits mjtNum solimp_limit[mjNIMP]; // solver impedance: joint limits - int actfrclimited; // are actuator forces on joint limited (mjtLimited) + mjtLimited actfrclimited; // are actuator forces on joint limited double actfrcrange[2]; // actuator force limits // dof properties @@ -330,7 +330,7 @@ typedef struct mjsJoint_ { // joint specification // other int group; // group - mjtByte actgravcomp; // is gravcomp force applied via actuators + mjtBool actgravcomp; // is gravcomp force applied via actuators mjDoubleVec* userdata; // user data mjString* info; // message appended to compiler errors } mjsJoint; @@ -444,10 +444,10 @@ typedef struct mjsLight_ { // light specification mjString* targetbody; // target body for targeting // intrinsics - mjtByte active; // is light active + mjtBool active; // is light active mjtLightType type; // type of light mjString* texture; // texture name for image lights - mjtByte castshadow; // does light cast shadows + mjtBool castshadow; // does light cast shadows float bulbradius; // bulb radius, for soft shadows float intensity; // intensity, in candelas float range; // range of effectiveness @@ -459,7 +459,7 @@ typedef struct mjsLight_ { // light specification float specular[3]; // specular color // other - mjString* info; // message appended to compiler errorsx + mjString* info; // message appended to compiler errors } mjsLight; @@ -482,9 +482,9 @@ typedef struct mjsFlex_ { // flex specification int dim; // element dimensionality double radius; // radius around primitive element double size[3]; // vertex bounding box half sizes in qpos0 - mjtByte internal; // enable internal collisions - mjtByte flatskin; // render flex skin with flat shading - int selfcollide; // mode for flex self collision + mjtBool internal; // enable internal collisions + mjtBool flatskin; // render flex skin with flat shading + mjtFlexSelf selfcollide; // mode for flex self collision int passive; // mode for passive collisions int activelayers; // number of active element layers in 3D int group; // group for visualization @@ -522,8 +522,8 @@ typedef struct mjsMesh_ { // mesh specification double refquat[4]; // reference orientation double scale[3]; // rescale mesh mjtMeshInertia inertia; // inertia type (convex, legacy, exact, shell) - mjtByte smoothnormal; // do not exclude large-angle faces from normals - mjtByte needsdf; // compute sdf from mesh + mjtBool smoothnormal; // do not exclude large-angle faces from normals + mjtBool needsdf; // compute sdf from mesh int maxhullvert; // maximum vertex count for the convex hull mjFloatVec* uservert; // user vertex data mjFloatVec* usernormal; // user normal data @@ -582,8 +582,8 @@ typedef struct mjsTexture_ { // texture specification mjtColorSpace colorspace; // colorspace // method 1: builtin - int builtin; // builtin type (mjtBuiltin) - int mark; // mark type (mjtMark) + mjtBuiltin builtin; // builtin type + mjtMark mark; // mark type double rgb1[3]; // first color for builtin double rgb2[3]; // second color for builtin double markrgb[3]; // mark color @@ -605,8 +605,8 @@ typedef struct mjsTexture_ { // texture specification mjByteVec* data; // texture data // flip options - mjtByte hflip; // horizontal flip - mjtByte vflip; // vertical flip + mjtBool hflip; // horizontal flip + mjtBool vflip; // vertical flip // other mjString* info; // message appended to compiler errors @@ -616,7 +616,7 @@ typedef struct mjsTexture_ { // texture specification typedef struct mjsMaterial_ { // material specification mjsElement* element; // element type mjStringVec* textures; // names of textures (empty: none) - mjtByte texuniform; // make texture cube uniform + mjtBool texuniform; // make texture cube uniform float texrepeat[2]; // texture repetition for 2D mapping float emission; // emission float specular; // specular @@ -658,7 +658,7 @@ typedef struct mjsEquality_ { // equality specification mjsElement* element; // element type mjtEq type; // constraint type double data[mjNEQDATA]; // type-dependent data - mjtByte active; // is equality initially active + mjtBool active; // is equality initially active mjString* name1; // name of object 1 mjString* name2; // name of object 2 mjtObj objtype; // type of both objects @@ -681,8 +681,8 @@ typedef struct mjsTendon_ { // tendon specification double armature; // inertia associated with tendon velocity // length range - int limited; // does tendon have limits (mjtLimited) - int actfrclimited; // does tendon have actuator force limits + mjtLimited limited; // does tendon have limits + mjtLimited actfrclimited; // does tendon have actuator force limits double range[2]; // length limits double actfrcrange[2]; // actuator force limits double margin; // margin value for tendon limit detection @@ -721,7 +721,7 @@ typedef struct mjsActuator_ { // actuator specification mjtDyn dyntype; // dynamics type double dynprm[mjNDYN]; // dynamics parameters int actdim; // number of activation variables - mjtByte actearly; // apply next activations to qfrc + mjtBool actearly; // apply next activations to qfrc // transmission mjtTrn trntype; // transmission type @@ -736,11 +736,11 @@ typedef struct mjsActuator_ { // actuator specification double armature; // armature inertia // input/output clamping - int ctrllimited; // are control limits defined (mjtLimited) + mjtLimited ctrllimited; // are control limits defined double ctrlrange[2]; // control range - int forcelimited; // are force limits defined (mjtLimited) + mjtLimited forcelimited; // are force limits defined double forcerange[2]; // force range - int actlimited; // are activation limits defined (mjtLimited) + mjtLimited actlimited; // are activation limits defined double actrange[2]; // activation range // other diff --git a/include/mujoco/mjspecmacro.h b/include/mujoco/mjspecmacro.h index d5ee8f70..5ad8a057 100644 --- a/include/mujoco/mjspecmacro.h +++ b/include/mujoco/mjspecmacro.h @@ -25,27 +25,27 @@ //-------------------------------- mjsCompiler ----------------------------------------------------- -#define MJSCOMPILER_FIELDS \ - X(mjtByte, autolimits, 1) \ - X(double, boundmass, 1) \ - X(double, boundinertia, 1) \ - X(double, settotalmass, 1) \ - X(mjtByte, balanceinertia, 1) \ - X(mjtByte, fitaabb, 1) \ - X(mjtByte, degree, 1) \ - XVEC(char, eulerseq, 3) \ - X(mjtByte, discardvisual, 1) \ - X(mjtByte, usethread, 1) \ - X(mjtByte, fusestatic, 1) \ - X(int, inertiafromgeom, 1) \ - XVEC(int, inertiagrouprange, 2) \ - X(mjtByte, saveinertial, 1) \ - X(int, alignfree, 1) \ - X(int, conflict, 1) \ - X(mjLROpt, LRopt, 1) \ - X(mjString*, meshdir, 1) \ - X(mjString*, texturedir, 1) \ - X(uint64_t, authored, 1) +#define MJSCOMPILER_FIELDS \ + X(mjtBool, autolimits, 1) \ + X(double, boundmass, 1) \ + X(double, boundinertia, 1) \ + X(double, settotalmass, 1) \ + X(mjtBool, balanceinertia, 1) \ + X(mjtBool, fitaabb, 1) \ + X(mjtBool, degree, 1) \ + XVEC(char, eulerseq, 3) \ + X(mjtBool, discardvisual, 1) \ + X(mjtBool, usethread, 1) \ + X(mjtBool, fusestatic, 1) \ + X(mjtInertiaFromGeom, inertiafromgeom, 1) \ + XVEC(int, inertiagrouprange, 2) \ + X(mjtBool, saveinertial, 1) \ + X(mjtBool, alignfree, 1) \ + X(mjtConflict, conflict, 1) \ + X(mjLROpt, LRopt, 1) \ + X(mjString*, meshdir, 1) \ + X(mjString*, texturedir, 1) \ + X(uint64_t, authored, 1) //-------------------------------- mjSpec ---------------------------------------------------------- @@ -53,7 +53,7 @@ X( mjsElement*, element, 1 ) \ X( mjString*, modelname, 1 ) \ X( mjsCompiler, compiler, 1 ) \ - X( mjtByte, strippath, 1 ) \ + X( mjtBool, strippath, 1 ) \ X( mjOption, option, 1 ) \ X( mjVisual, visual, 1 ) \ X( mjStatistic, stat, 1 ) \ @@ -74,7 +74,7 @@ X( mjtSize, nstack, 1 ) \ X( mjString*, comment, 1 ) \ X( mjString*, modelfiledir, 1 ) \ - X( mjtByte, hasImplicitPluginElem, 1 ) + X( mjtBool, hasImplicitPluginElem, 1 ) //-------------------------------- mjsOrientation -------------------------------------------------- @@ -93,7 +93,7 @@ X( mjsElement*, element, 1 ) \ X( mjString*, name, 1 ) \ X( mjString*, plugin_name, 1 ) \ - X( mjtByte, active, 1 ) \ + X( mjtBool, active, 1 ) \ X( mjString*, info, 1 ) @@ -111,12 +111,12 @@ XVEC( double, inertia, 3 ) \ X ( mjsOrientation, ialt, 1 ) \ XVEC( double, fullinertia, 6 ) \ - X ( mjtByte, mocap, 1 ) \ + X ( mjtBool, mocap, 1 ) \ X ( double, gravcomp, 1 ) \ X ( mjtSleepPolicy, sleep, 1 ) \ X ( mjtByte, simple, 1 ) \ X ( mjDoubleVec*, userdata, 1 ) \ - X ( mjtByte, explicitinertial, 1 ) \ + X ( mjtBool, explicitinertial, 1 ) \ X ( mjsPlugin, plugin, 1 ) \ X ( mjString*, info, 1 ) @@ -140,16 +140,16 @@ XVEC( double, pos, 3 ) \ XVEC( double, axis, 3 ) \ X ( double, ref, 1 ) \ - X ( int, align, 1 ) \ + X ( mjtAlignFree, align, 1 ) \ XVEC( double, stiffness, mjNPOLY+1 ) \ X ( double, springref, 1 ) \ XVEC( double, springdamper, 2 ) \ - X ( int, limited, 1 ) \ + X ( mjtLimited, limited, 1 ) \ XVEC( double, range, 2 ) \ X ( double, margin, 1 ) \ XVEC( mjtNum, solref_limit, mjNREF ) \ XVEC( mjtNum, solimp_limit, mjNIMP ) \ - X ( int, actfrclimited, 1 ) \ + X ( mjtLimited, actfrclimited, 1 ) \ XVEC( double, actfrcrange, 2 ) \ X ( double, armature, 1 ) \ XVEC( double, damping, mjNPOLY+1 ) \ @@ -157,7 +157,7 @@ XVEC( mjtNum, solref_friction, mjNREF ) \ XVEC( mjtNum, solimp_friction, mjNIMP ) \ X ( int, group, 1 ) \ - X ( mjtByte, actgravcomp, 1 ) \ + X ( mjtBool, actgravcomp, 1 ) \ X ( mjDoubleVec*, userdata, 1 ) \ X ( mjString*, info, 1 ) @@ -247,10 +247,10 @@ XVEC( double, dir, 3 ) \ X ( mjtCamLight, mode, 1 ) \ X ( mjString*, targetbody, 1 ) \ - X ( mjtByte, active, 1 ) \ + X ( mjtBool, active, 1 ) \ X ( mjtLightType, type, 1 ) \ X ( mjString*, texture, 1 ) \ - X ( mjtByte, castshadow, 1 ) \ + X ( mjtBool, castshadow, 1 ) \ X ( float, bulbradius, 1 ) \ X ( float, intensity, 1 ) \ X ( float, range, 1 ) \ @@ -280,9 +280,9 @@ X ( int, dim, 1 ) \ X ( double, radius, 1 ) \ XVEC( double, size, 3 ) \ - X ( mjtByte, internal, 1 ) \ - X ( mjtByte, flatskin, 1 ) \ - X ( int, selfcollide, 1 ) \ + X ( mjtBool, internal, 1 ) \ + X ( mjtBool, flatskin, 1 ) \ + X ( mjtFlexSelf, selfcollide, 1 ) \ X ( int, passive, 1 ) \ X ( int, activelayers, 1 ) \ X ( int, group, 1 ) \ @@ -317,8 +317,8 @@ XVEC( double, refquat, 4 ) \ XVEC( double, scale, 3 ) \ X ( mjtMeshInertia, inertia, 1 ) \ - X ( mjtByte, smoothnormal, 1 ) \ - X ( mjtByte, needsdf, 1 ) \ + X ( mjtBool, smoothnormal, 1 ) \ + X ( mjtBool, needsdf, 1 ) \ X ( int, maxhullvert, 1 ) \ X ( mjFloatVec*, uservert, 1 ) \ X ( mjFloatVec*, usernormal, 1 ) \ @@ -371,8 +371,8 @@ X ( mjsElement*, element, 1 ) \ X ( mjtTexture, type, 1 ) \ X ( mjtColorSpace, colorspace, 1 ) \ - X ( int, builtin, 1 ) \ - X ( int, mark, 1 ) \ + X ( mjtBuiltin, builtin, 1 ) \ + X ( mjtMark, mark, 1 ) \ XVEC( double, rgb1, 3 ) \ XVEC( double, rgb2, 3 ) \ XVEC( double, markrgb, 3 ) \ @@ -386,8 +386,8 @@ XVEC( char, gridlayout, 12 ) \ X ( mjStringVec*, cubefiles, 1 ) \ X ( mjByteVec*, data, 1 ) \ - X ( mjtByte, hflip, 1 ) \ - X ( mjtByte, vflip, 1 ) \ + X ( mjtBool, hflip, 1 ) \ + X ( mjtBool, vflip, 1 ) \ X ( mjString*, info, 1 ) @@ -396,7 +396,7 @@ #define MJSMATERIAL_FIELDS \ X ( mjsElement*, element, 1 ) \ X ( mjStringVec*, textures, 1 ) \ - X ( mjtByte, texuniform, 1 ) \ + X ( mjtBool, texuniform, 1 ) \ XVEC( float, texrepeat, 2 ) \ X ( float, emission, 1 ) \ X ( float, specular, 1 ) \ @@ -439,7 +439,7 @@ X ( mjsElement*, element, 1 ) \ X ( mjtEq, type, 1 ) \ XVEC( double, data, mjNEQDATA ) \ - X ( mjtByte, active, 1 ) \ + X ( mjtBool, active, 1 ) \ X ( mjString*, name1, 1 ) \ X ( mjString*, name2, 1 ) \ X ( mjtObj, objtype, 1 ) \ @@ -459,8 +459,8 @@ XVEC( mjtNum, solref_friction, mjNREF ) \ XVEC( mjtNum, solimp_friction, mjNIMP ) \ X ( double, armature, 1 ) \ - X ( int, limited, 1 ) \ - X ( int, actfrclimited, 1 ) \ + X ( mjtLimited, limited, 1 ) \ + X ( mjtLimited, actfrclimited, 1 ) \ XVEC( double, range, 2 ) \ XVEC( double, actfrcrange, 2 ) \ X ( double, margin, 1 ) \ @@ -493,7 +493,7 @@ X ( mjtDyn, dyntype, 1 ) \ XVEC( double, dynprm, mjNDYN ) \ X ( int, actdim, 1 ) \ - X ( mjtByte, actearly, 1 ) \ + X ( mjtBool, actearly, 1 ) \ X ( mjtTrn, trntype, 1 ) \ XVEC( double, gear, 6 ) \ X ( mjString*, target, 1 ) \ @@ -504,11 +504,11 @@ X ( double, inheritrange, 1 ) \ XVEC( double, damping, mjNPOLY+1 ) \ X ( double, armature, 1 ) \ - X ( int, ctrllimited, 1 ) \ + X ( mjtLimited, ctrllimited, 1 ) \ XVEC( double, ctrlrange, 2 ) \ - X ( int, forcelimited, 1 ) \ + X ( mjtLimited, forcelimited, 1 ) \ XVEC( double, forcerange, 2 ) \ - X ( int, actlimited, 1 ) \ + X ( mjtLimited, actlimited, 1 ) \ XVEC( double, actrange, 2 ) \ X ( int, group, 1 ) \ X ( int, nsample, 1 ) \ diff --git a/plugin/usd_decoder/usd_decoder.cc b/plugin/usd_decoder/usd_decoder.cc index 897c547f..78171330 100644 --- a/plugin/usd_decoder/usd_decoder.cc +++ b/plugin/usd_decoder/usd_decoder.cc @@ -1426,7 +1426,7 @@ void ParseMjcPhysicsActuator(mjSpec* spec, auto setLimitedField = [](mjsActuator* mj_act, const pxr::UsdAttribute& usd_attribute, - int* mj_limited_field) { + mjtLimited* mj_limited_field) { if (usd_attribute.HasAuthoredValue()) { pxr::TfToken limited; usd_attribute.Get(&limited); diff --git a/python/mujoco/codegen/generate_cs_bindings.py b/python/mujoco/codegen/generate_cs_bindings.py index 0e0bacef..2dcc5956 100644 --- a/python/mujoco/codegen/generate_cs_bindings.py +++ b/python/mujoco/codegen/generate_cs_bindings.py @@ -304,6 +304,8 @@ def _resolve_type_name(raw_name): return C_TO_CS_TYPE[name] if name in _STRUCT_NAME_OVERRIDES: return _STRUCT_NAME_OVERRIDES[name] + if name in introspect_enums.ENUMS: + return name if name.endswith('_'): return name return name + '_' diff --git a/python/mujoco/codegen/generate_spec_bindings.py b/python/mujoco/codegen/generate_spec_bindings.py index 2728a0d5..2cef63d5 100644 --- a/python/mujoco/codegen/generate_spec_bindings.py +++ b/python/mujoco/codegen/generate_spec_bindings.py @@ -19,6 +19,7 @@ from collections.abc import Sequence from absl import app from introspect import ast_nodes +from introspect import enums from introspect import structs @@ -96,6 +97,7 @@ def _value_binding_code( fulltype = fulltype.replace('mjVisual', 'raw::MjVisual') fulltype = fulltype.replace('mjStatistic', 'raw::MjStatistic') element = '' + is_enum = field.name in enums.ENUMS if field.name == 'mjsPlugin': setter = f"""[]({rawclassname}& self, {fulltype} {varname}) {{ @@ -104,6 +106,10 @@ def _value_binding_code( self.{fullvarname}.active = {varname}.active; if (self.{fullvarname}.info && {varname}.info) *self.{fullvarname}.info = *{varname}.info; }}""" + elif is_enum: + setter = f"""[]({rawclassname}& self, int {varname}) {{ + self.{fullvarname}{element} = static_cast<{field.name}>({varname}){element}; + }}""" else: setter = f"""[]({rawclassname}& self, {fulltype} {varname}) {{ self.{fullvarname}{element} = {varname}{element}; @@ -111,13 +117,13 @@ def _value_binding_code( def_property_args = ( f'"{varname}"', - f"""[]({rawclassname}& self) -> {fulltype} {{ + f"""[]({rawclassname}& self) -> {field.name if is_enum else fulltype} {{ return self.{fullvarname}; }}""", setter, ) - if field.name not in SCALAR_TYPES: + if field.name not in SCALAR_TYPES and not is_enum: def_property_args += ('py::return_value_policy::reference_internal',) return f'{classname}.def_property({",".join(def_property_args)});' diff --git a/python/mujoco/introspect/structs.py b/python/mujoco/introspect/structs.py index f51c3926..c71b461f 100644 --- a/python/mujoco/introspect/structs.py +++ b/python/mujoco/introspect/structs.py @@ -6890,7 +6890,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ fields=( StructFieldDecl( name='autolimits', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='infer "limited" attribute based on range', ), StructFieldDecl( @@ -6910,17 +6910,17 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='balanceinertia', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='automatically impose A + B >= C rule', ), StructFieldDecl( name='fitaabb', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='meshfit to aabb instead of inertia box', ), StructFieldDecl( name='degree', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='angles in radians or degrees', ), StructFieldDecl( @@ -6933,23 +6933,23 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='discardvisual', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='discard visual geoms in parser', ), StructFieldDecl( name='usethread', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='use multiple threads to speed up compiler', ), StructFieldDecl( name='fusestatic', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='fuse static bodies with parent', ), StructFieldDecl( name='inertiafromgeom', - type=ValueType(name='int'), - doc='use geom inertias (mjtInertiaFromGeom)', + type=ValueType(name='mjtInertiaFromGeom'), + doc='use geom inertias', ), StructFieldDecl( name='inertiagrouprange', @@ -6961,18 +6961,18 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='saveinertial', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='save explicit inertial clause for all bodies to XML', ), StructFieldDecl( name='alignfree', - type=ValueType(name='int'), + type=ValueType(name='mjtBool'), doc='align free joints with inertial frame', ), StructFieldDecl( name='conflict', - type=ValueType(name='int'), - doc='conflict resolution for attach (mjtConflict)', + type=ValueType(name='mjtConflict'), + doc='conflict resolution for attach', ), StructFieldDecl( name='LRopt', @@ -7083,7 +7083,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='strippath', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='automatically strip paths from mesh files', ), StructFieldDecl( @@ -7192,7 +7192,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='hasImplicitPluginElem', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='already encountered an implicit plugin sensor/actuator', ), StructFieldDecl( @@ -7274,7 +7274,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='active', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='is the plugin active', ), StructFieldDecl( @@ -7370,7 +7370,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='mocap', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='is this a mocap body', ), StructFieldDecl( @@ -7397,7 +7397,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='explicitinertial', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='whether to save the body with explicit inertial clause', ), StructFieldDecl( @@ -7503,8 +7503,8 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='align', - type=ValueType(name='int'), - doc='align free joint with body com (mjtAlignFree)', + type=ValueType(name='mjtAlignFree'), + doc='align free joint with body com', ), StructFieldDecl( name='stiffness', @@ -7529,8 +7529,8 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='limited', - type=ValueType(name='int'), - doc='does joint have limits (mjtLimited)', + type=ValueType(name='mjtLimited'), + doc='does joint have limits', ), StructFieldDecl( name='range', @@ -7563,8 +7563,8 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='actfrclimited', - type=ValueType(name='int'), - doc='are actuator forces on joint limited (mjtLimited)', + type=ValueType(name='mjtLimited'), + doc='are actuator forces on joint limited', ), StructFieldDecl( name='actfrcrange', @@ -7615,7 +7615,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='actgravcomp', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='is gravcomp force applied via actuators', ), StructFieldDecl( @@ -8104,7 +8104,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='active', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='is light active', ), StructFieldDecl( @@ -8121,7 +8121,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='castshadow', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='does light cast shadows', ), StructFieldDecl( @@ -8186,7 +8186,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ type=PointerType( inner_type=ValueType(name='mjString'), ), - doc='message appended to compiler errorsx', + doc='message appended to compiler errors', ), ), )), @@ -8281,17 +8281,17 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='internal', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='enable internal collisions', ), StructFieldDecl( name='flatskin', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='render flex skin with flat shading', ), StructFieldDecl( name='selfcollide', - type=ValueType(name='int'), + type=ValueType(name='mjtFlexSelf'), doc='mode for flex self collision', ), StructFieldDecl( @@ -8487,12 +8487,12 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='smoothnormal', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='do not exclude large-angle faces from normals', ), StructFieldDecl( name='needsdf', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='compute sdf from mesh', ), StructFieldDecl( @@ -8761,13 +8761,13 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='builtin', - type=ValueType(name='int'), - doc='builtin type (mjtBuiltin)', + type=ValueType(name='mjtBuiltin'), + doc='builtin type', ), StructFieldDecl( name='mark', - type=ValueType(name='int'), - doc='mark type (mjtMark)', + type=ValueType(name='mjtMark'), + doc='mark type', ), StructFieldDecl( name='rgb1', @@ -8859,12 +8859,12 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='hflip', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='horizontal flip', ), StructFieldDecl( name='vflip', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='vertical flip', ), StructFieldDecl( @@ -8897,7 +8897,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='texuniform', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='make texture cube uniform', ), StructFieldDecl( @@ -9099,7 +9099,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='active', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='is equality initially active', ), StructFieldDecl( @@ -9210,12 +9210,12 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='limited', - type=ValueType(name='int'), - doc='does tendon have limits (mjtLimited)', + type=ValueType(name='mjtLimited'), + doc='does tendon have limits', ), StructFieldDecl( name='actfrclimited', - type=ValueType(name='int'), + type=ValueType(name='mjtLimited'), doc='does tendon have actuator force limits', ), StructFieldDecl( @@ -9380,7 +9380,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='actearly', - type=ValueType(name='mjtByte'), + type=ValueType(name='mjtBool'), doc='apply next activations to qfrc', ), StructFieldDecl( @@ -9450,8 +9450,8 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='ctrllimited', - type=ValueType(name='int'), - doc='are control limits defined (mjtLimited)', + type=ValueType(name='mjtLimited'), + doc='are control limits defined', ), StructFieldDecl( name='ctrlrange', @@ -9463,8 +9463,8 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='forcelimited', - type=ValueType(name='int'), - doc='are force limits defined (mjtLimited)', + type=ValueType(name='mjtLimited'), + doc='are force limits defined', ), StructFieldDecl( name='forcerange', @@ -9476,8 +9476,8 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), StructFieldDecl( name='actlimited', - type=ValueType(name='int'), - doc='are activation limits defined (mjtLimited)', + type=ValueType(name='mjtLimited'), + doc='are activation limits defined', ), StructFieldDecl( name='actrange', diff --git a/python/mujoco/specs.cc b/python/mujoco/specs.cc index 45bc46d6..17391474 100644 --- a/python/mujoco/specs.cc +++ b/python/mujoco/specs.cc @@ -777,7 +777,7 @@ PYBIND11_MODULE(_specs, m, pybind11::mod_gil_not_used()) { std::string key = py::str(item.first); if (key == "align") { try { - out->align = kwargs["align"].cast(); + out->align = static_cast(kwargs["align"].cast()); } catch (const py::cast_error& e) { throw pybind11::value_error("align is the wrong type."); } diff --git a/src/experimental/platform/ux/imgui_widgets.cc b/src/experimental/platform/ux/imgui_widgets.cc index 0a507771..f0d1eb95 100644 --- a/src/experimental/platform/ux/imgui_widgets.cc +++ b/src/experimental/platform/ux/imgui_widgets.cc @@ -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) { diff --git a/src/experimental/platform/ux/imgui_widgets.h b/src/experimental/platform/ux/imgui_widgets.h index f699acc6..df61cd73 100644 --- a/src/experimental/platform/ux/imgui_widgets.h +++ b/src/experimental/platform/ux/imgui_widgets.h @@ -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, diff --git a/src/user/user_api.cc b/src/user/user_api.cc index ca9662a4..721e90c5 100644 --- a/src/user/user_api.cc +++ b/src/user/user_api.cc @@ -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; diff --git a/src/user/user_model.cc b/src/user/user_model.cc index fd5b1f7c..add51056 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -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 diff --git a/src/xml/xml_util.h b/src/xml/xml_util.h index 6712ded5..d8af121e 100644 --- a/src/xml/xml_util.h +++ b/src/xml/xml_util.h @@ -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 + 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(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); diff --git a/unity/Runtime/Bindings/MjBindings.cs b/unity/Runtime/Bindings/MjBindings.cs index 4adfa74d..e5afb973 100644 --- a/unity/Runtime/Bindings/MjBindings.cs +++ b/unity/Runtime/Bindings/MjBindings.cs @@ -5866,11 +5866,11 @@ public unsafe struct mjsCompiler_ { public byte discardvisual; public byte usethread; public byte fusestatic; - public int inertiafromgeom; + public mjtInertiaFromGeom inertiafromgeom; public fixed int inertiagrouprange[2]; public byte saveinertial; - public int alignfree; - public int conflict; + public byte alignfree; + public mjtConflict conflict; public mjLROpt_ LRopt; public void* meshdir; public void* texturedir; diff --git a/wasm/codegen/generated/bindings.h b/wasm/codegen/generated/bindings.h index 05671f1d..9299567c 100644 --- a/wasm/codegen/generated/bindings.h +++ b/wasm/codegen/generated/bindings.h @@ -2154,10 +2154,10 @@ struct MjsCompiler { explicit MjsCompiler(mjsCompiler *ptr); mjsCompiler* get() const; void set(mjsCompiler* ptr); - mjtByte autolimits() const { + mjtBool autolimits() const { return ptr_->autolimits; } - void set_autolimits(mjtByte value) { + void set_autolimits(mjtBool value) { ptr_->autolimits = value; } double boundmass() const { @@ -2178,70 +2178,70 @@ struct MjsCompiler { void set_settotalmass(double value) { ptr_->settotalmass = value; } - mjtByte balanceinertia() const { + mjtBool balanceinertia() const { return ptr_->balanceinertia; } - void set_balanceinertia(mjtByte value) { + void set_balanceinertia(mjtBool value) { ptr_->balanceinertia = value; } - mjtByte fitaabb() const { + mjtBool fitaabb() const { return ptr_->fitaabb; } - void set_fitaabb(mjtByte value) { + void set_fitaabb(mjtBool value) { ptr_->fitaabb = value; } - mjtByte degree() const { + mjtBool degree() const { return ptr_->degree; } - void set_degree(mjtByte value) { + void set_degree(mjtBool value) { ptr_->degree = value; } emscripten::val eulerseq() const { return emscripten::val(emscripten::typed_memory_view(3, ptr_->eulerseq)); } - mjtByte discardvisual() const { + mjtBool discardvisual() const { return ptr_->discardvisual; } - void set_discardvisual(mjtByte value) { + void set_discardvisual(mjtBool value) { ptr_->discardvisual = value; } - mjtByte usethread() const { + mjtBool usethread() const { return ptr_->usethread; } - void set_usethread(mjtByte value) { + void set_usethread(mjtBool value) { ptr_->usethread = value; } - mjtByte fusestatic() const { + mjtBool fusestatic() const { return ptr_->fusestatic; } - void set_fusestatic(mjtByte value) { + void set_fusestatic(mjtBool value) { ptr_->fusestatic = value; } - int inertiafromgeom() const { + mjtInertiaFromGeom inertiafromgeom() const { return ptr_->inertiafromgeom; } - void set_inertiafromgeom(int value) { + void set_inertiafromgeom(mjtInertiaFromGeom value) { ptr_->inertiafromgeom = value; } emscripten::val inertiagrouprange() const { return emscripten::val(emscripten::typed_memory_view(2, ptr_->inertiagrouprange)); } - mjtByte saveinertial() const { + mjtBool saveinertial() const { return ptr_->saveinertial; } - void set_saveinertial(mjtByte value) { + void set_saveinertial(mjtBool value) { ptr_->saveinertial = value; } - int alignfree() const { + mjtBool alignfree() const { return ptr_->alignfree; } - void set_alignfree(int value) { + void set_alignfree(mjtBool value) { ptr_->alignfree = value; } - int conflict() const { + mjtConflict conflict() const { return ptr_->conflict; } - void set_conflict(int value) { + void set_conflict(mjtConflict value) { ptr_->conflict = value; } mjString meshdir() const { @@ -2310,10 +2310,10 @@ struct MjsEquality { emscripten::val data() const { return emscripten::val(emscripten::typed_memory_view(11, ptr_->data)); } - mjtByte active() const { + mjtBool active() const { return ptr_->active; } - void set_active(mjtByte value) { + void set_active(mjtBool value) { ptr_->active = value; } mjString name1() const { @@ -2466,22 +2466,22 @@ struct MjsFlex { emscripten::val size() const { return emscripten::val(emscripten::typed_memory_view(3, ptr_->size)); } - mjtByte internal() const { + mjtBool internal() const { return ptr_->internal; } - void set_internal(mjtByte value) { + void set_internal(mjtBool value) { ptr_->internal = value; } - mjtByte flatskin() const { + mjtBool flatskin() const { return ptr_->flatskin; } - void set_flatskin(mjtByte value) { + void set_flatskin(mjtBool value) { ptr_->flatskin = value; } - int selfcollide() const { + mjtFlexSelf selfcollide() const { return ptr_->selfcollide; } - void set_selfcollide(int value) { + void set_selfcollide(mjtFlexSelf value) { ptr_->selfcollide = value; } int passive() const { @@ -2677,10 +2677,10 @@ struct MjsJoint { void set_ref(double value) { ptr_->ref = value; } - int align() const { + mjtAlignFree align() const { return ptr_->align; } - void set_align(int value) { + void set_align(mjtAlignFree value) { ptr_->align = value; } emscripten::val stiffness() const { @@ -2695,10 +2695,10 @@ struct MjsJoint { emscripten::val springdamper() const { return emscripten::val(emscripten::typed_memory_view(2, ptr_->springdamper)); } - int limited() const { + mjtLimited limited() const { return ptr_->limited; } - void set_limited(int value) { + void set_limited(mjtLimited value) { ptr_->limited = value; } emscripten::val range() const { @@ -2716,10 +2716,10 @@ struct MjsJoint { emscripten::val solimp_limit() const { return emscripten::val(emscripten::typed_memory_view(5, ptr_->solimp_limit)); } - int actfrclimited() const { + mjtLimited actfrclimited() const { return ptr_->actfrclimited; } - void set_actfrclimited(int value) { + void set_actfrclimited(mjtLimited value) { ptr_->actfrclimited = value; } emscripten::val actfrcrange() const { @@ -2752,10 +2752,10 @@ struct MjsJoint { void set_group(int value) { ptr_->group = value; } - mjtByte actgravcomp() const { + mjtBool actgravcomp() const { return ptr_->actgravcomp; } - void set_actgravcomp(mjtByte value) { + void set_actgravcomp(mjtBool value) { ptr_->actgravcomp = value; } mjDoubleVec &userdata() const { @@ -2845,10 +2845,10 @@ struct MjsLight { *(ptr_->targetbody) = value; } } - mjtByte active() const { + mjtBool active() const { return ptr_->active; } - void set_active(mjtByte value) { + void set_active(mjtBool value) { ptr_->active = value; } mjtLightType type() const { @@ -2865,10 +2865,10 @@ struct MjsLight { *(ptr_->texture) = value; } } - mjtByte castshadow() const { + mjtBool castshadow() const { return ptr_->castshadow; } - void set_castshadow(mjtByte value) { + void set_castshadow(mjtBool value) { ptr_->castshadow = value; } float bulbradius() const { @@ -2936,10 +2936,10 @@ struct MjsMaterial { mjStringVec &textures() const { return *(ptr_->textures); } - mjtByte texuniform() const { + mjtBool texuniform() const { return ptr_->texuniform; } - void set_texuniform(mjtByte value) { + void set_texuniform(mjtBool value) { ptr_->texuniform = value; } emscripten::val texrepeat() const { @@ -3115,10 +3115,10 @@ struct MjsPlugin { *(ptr_->plugin_name) = value; } } - mjtByte active() const { + mjtBool active() const { return ptr_->active; } - void set_active(mjtByte value) { + void set_active(mjtBool value) { ptr_->active = value; } mjString info() const { @@ -3243,16 +3243,16 @@ struct MjsTendon { void set_armature(double value) { ptr_->armature = value; } - int limited() const { + mjtLimited limited() const { return ptr_->limited; } - void set_limited(int value) { + void set_limited(mjtLimited value) { ptr_->limited = value; } - int actfrclimited() const { + mjtLimited actfrclimited() const { return ptr_->actfrclimited; } - void set_actfrclimited(int value) { + void set_actfrclimited(mjtLimited value) { ptr_->actfrclimited = value; } emscripten::val range() const { @@ -3359,16 +3359,16 @@ struct MjsTexture { void set_colorspace(mjtColorSpace value) { ptr_->colorspace = value; } - int builtin() const { + mjtBuiltin builtin() const { return ptr_->builtin; } - void set_builtin(int value) { + void set_builtin(mjtBuiltin value) { ptr_->builtin = value; } - int mark() const { + mjtMark mark() const { return ptr_->mark; } - void set_mark(int value) { + void set_mark(mjtMark value) { ptr_->mark = value; } emscripten::val rgb1() const { @@ -3432,16 +3432,16 @@ struct MjsTexture { std::vector &data() const { return *(reinterpret_cast*>(ptr_->data)); } - mjtByte hflip() const { + mjtBool hflip() const { return ptr_->hflip; } - void set_hflip(mjtByte value) { + void set_hflip(mjtBool value) { ptr_->hflip = value; } - mjtByte vflip() const { + mjtBool vflip() const { return ptr_->vflip; } - void set_vflip(mjtByte value) { + void set_vflip(mjtBool value) { ptr_->vflip = value; } mjString info() const { @@ -5730,10 +5730,10 @@ struct MjSpec { *(ptr_->modelname) = value; } } - mjtByte strippath() const { + mjtBool strippath() const { return ptr_->strippath; } - void set_strippath(mjtByte value) { + void set_strippath(mjtBool value) { ptr_->strippath = value; } int memory() const { @@ -5842,10 +5842,10 @@ struct MjSpec { *(ptr_->modelfiledir) = value; } } - mjtByte hasImplicitPluginElem() const { + mjtBool hasImplicitPluginElem() const { return ptr_->hasImplicitPluginElem; } - void set_hasImplicitPluginElem(mjtByte value) { + void set_hasImplicitPluginElem(mjtBool value) { ptr_->hasImplicitPluginElem = value; } @@ -5899,10 +5899,10 @@ struct MjsActuator { void set_actdim(int value) { ptr_->actdim = value; } - mjtByte actearly() const { + mjtBool actearly() const { return ptr_->actearly; } - void set_actearly(mjtByte value) { + void set_actearly(mjtBool value) { ptr_->actearly = value; } mjtTrn trntype() const { @@ -5962,28 +5962,28 @@ struct MjsActuator { void set_armature(double value) { ptr_->armature = value; } - int ctrllimited() const { + mjtLimited ctrllimited() const { return ptr_->ctrllimited; } - void set_ctrllimited(int value) { + void set_ctrllimited(mjtLimited value) { ptr_->ctrllimited = value; } emscripten::val ctrlrange() const { return emscripten::val(emscripten::typed_memory_view(2, ptr_->ctrlrange)); } - int forcelimited() const { + mjtLimited forcelimited() const { return ptr_->forcelimited; } - void set_forcelimited(int value) { + void set_forcelimited(mjtLimited value) { ptr_->forcelimited = value; } emscripten::val forcerange() const { return emscripten::val(emscripten::typed_memory_view(2, ptr_->forcerange)); } - int actlimited() const { + mjtLimited actlimited() const { return ptr_->actlimited; } - void set_actlimited(int value) { + void set_actlimited(mjtLimited value) { ptr_->actlimited = value; } emscripten::val actrange() const { @@ -6069,10 +6069,10 @@ struct MjsBody { emscripten::val fullinertia() const { return emscripten::val(emscripten::typed_memory_view(6, ptr_->fullinertia)); } - mjtByte mocap() const { + mjtBool mocap() const { return ptr_->mocap; } - void set_mocap(mjtByte value) { + void set_mocap(mjtBool value) { ptr_->mocap = value; } double gravcomp() const { @@ -6096,10 +6096,10 @@ struct MjsBody { mjDoubleVec &userdata() const { return *(ptr_->userdata); } - mjtByte explicitinertial() const { + mjtBool explicitinertial() const { return ptr_->explicitinertial; } - void set_explicitinertial(mjtByte value) { + void set_explicitinertial(mjtBool value) { ptr_->explicitinertial = value; } mjString info() const { @@ -6316,16 +6316,16 @@ struct MjsMesh { void set_inertia(mjtMeshInertia value) { ptr_->inertia = value; } - mjtByte smoothnormal() const { + mjtBool smoothnormal() const { return ptr_->smoothnormal; } - void set_smoothnormal(mjtByte value) { + void set_smoothnormal(mjtBool value) { ptr_->smoothnormal = value; } - mjtByte needsdf() const { + mjtBool needsdf() const { return ptr_->needsdf; } - void set_needsdf(mjtByte value) { + void set_needsdf(mjtBool value) { ptr_->needsdf = value; } int maxhullvert() const {