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
+59 -59
View File
@@ -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
+49 -49
View File
@@ -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 ) \