diff --git a/doc/includes/references.h b/doc/includes/references.h index 1ebccb8b..af3e6271 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -16,14 +16,13 @@ // Error: C reference not found // NOLINTBEGIN -struct mjPreContact_ { // contact parameters set by narrowphase collision functions +typedef struct mjPreContact_ { // contact parameters set by narrowphase collision functions mjtNum dist; mjtNum pos[3]; mjtNum normal[3]; // contact normal of the collision mjtNum tangent[3]; // first tangent direction -}; -typedef struct mjPreContact_ mjPreContact; -struct mjContact_ { // result of collision detection functions +} mjPreContact; +typedef struct mjContact_ { // result of collision detection functions // contact parameters set by narrowphase collision function mjtNum dist; // distance between nearest points; neg: penetration mjtNum pos[3]; // position of contact point: midpoint between geoms @@ -54,29 +53,25 @@ struct mjContact_ { // result of collision detection functions // address computed by mj_instantiateContact int efc_address; // address in efc; -1: not included -}; -typedef struct mjContact_ mjContact; -struct mjWarningStat_ { // warning statistics - int lastinfo; // info from last warning - int number; // how many times was warning raised -}; -typedef struct mjWarningStat_ mjWarningStat; -struct mjTimerStat_ { // timer statistics - mjtNum duration; // cumulative duration - int number; // how many times was timer called -}; -typedef struct mjTimerStat_ mjTimerStat; -struct mjSolverStat_ { // per-iteration solver statistics - mjtNum improvement; // cost reduction, scaled by 1/trace(M(qpos0)) - mjtNum gradient; // gradient norm (primal only, scaled) - mjtNum lineslope; // slope in linesearch - int nactive; // number of active constraints - int nchange; // number of constraint state changes - int neval; // number of cost evaluations in line search - int nupdate; // number of Cholesky updates in line search -}; -typedef struct mjSolverStat_ mjSolverStat; -struct mjData_ { +} mjContact; +typedef struct mjWarningStat_ { // warning statistics + int lastinfo; // info from last warning + int number; // how many times was warning raised +} mjWarningStat; +typedef struct mjTimerStat_ { // timer statistics + mjtNum duration; // cumulative duration + int number; // how many times was timer called +} mjTimerStat; +typedef struct mjSolverStat_ { // per-iteration solver statistics + mjtNum improvement; // cost reduction, scaled by 1/trace(M(qpos0)) + mjtNum gradient; // gradient norm (primal only, scaled) + mjtNum lineslope; // slope in linesearch + int nactive; // number of active constraints + int nchange; // number of constraint state changes + int neval; // number of cost evaluations in line search + int nupdate; // number of Cholesky updates in line search +} mjSolverStat; +typedef struct mjData_ { // constant sizes mjtSize narena; // size of the arena in bytes (inclusive of the stack) mjtSize nbuffer; // size of main buffer in bytes @@ -388,9 +383,8 @@ struct mjData_ { // compilation signature uint64_t signature; // also held by the mjSpec that compiled the model -}; -typedef struct mjData_ mjData; -struct mjLROpt_ { // options for mj_setLengthRange() +} mjData; +typedef struct mjLROpt_ { // options for mj_setLengthRange() // flags int mode; // which actuators to process (mjtLRMode) int useexisting; // use existing length range if available @@ -404,17 +398,14 @@ struct mjLROpt_ { // options for mj_setLengthRange() mjtNum inttotal; // total simulation time interval mjtNum interval; // evaluation time interval (at the end) mjtNum tolrange; // convergence tolerance (relative to range) -}; -typedef struct mjLROpt_ mjLROpt; -struct mjCache_ { // asset cache used by the compiler +} mjLROpt; +typedef struct mjCache_ { // asset cache used by the compiler void* impl_; // internal pointer to cache -}; -typedef struct mjCache_ mjCache; -struct mjVFS_ { // virtual file system for loading from memory +} mjCache; +typedef struct mjVFS_ { // virtual file system for loading from memory void* impl_; // internal pointer to VFS memory -}; -typedef struct mjVFS_ mjVFS; -struct mjOption_ { // physics options +} mjVFS; +typedef struct mjOption_ { // physics options // timing parameters mjtNum timestep; // timestep @@ -457,9 +448,8 @@ struct mjOption_ { // physics options // sdf collision settings int sdf_initpoints; // number of starting points for gradient descent int sdf_iterations; // max number of iterations for gradient descent -}; -typedef struct mjOption_ mjOption; -struct mjVisual_ { // visualization options +} mjOption; +typedef struct mjVisual_ { // visualization options struct { // global parameters int cameraid; // initial camera id (-1: free) int orthographic; // is the free camera orthographic (0: no, 1: yes) @@ -554,17 +544,15 @@ struct mjVisual_ { // visualization options float bv[4]; // bounding volume float bvactive[4]; // active bounding volume } rgba; -}; -typedef struct mjVisual_ mjVisual; -struct mjStatistic_ { // model statistics (in qpos0) +} mjVisual; +typedef struct mjStatistic_ { // model statistics (in qpos0) mjtNum meaninertia; // mean diagonal inertia mjtNum meanmass; // mean body mass mjtNum meansize; // mean body size mjtNum extent; // spatial extent mjtNum center[3]; // center of model -}; -typedef struct mjStatistic_ mjStatistic; -struct mjModel_ { +} mjStatistic; +typedef struct mjModel_ { // ------------------------------- sizes // sizes needed at mjModel construction @@ -1215,17 +1203,15 @@ struct mjModel_ { // compilation signature uint64_t signature; // also held by the mjSpec that compiled this model -}; -typedef struct mjModel_ mjModel; -struct mjResource_ { +} mjModel; +typedef struct mjResource_ { char* name; // name of resource (filename, etc) void* data; // opaque data pointer mjVFS* vfs; // pointer to the VFS char timestamp[512]; // timestamp of the resource const struct mjpResourceProvider* provider; // pointer to the provider -}; -typedef struct mjResource_ mjResource; -struct mjpResourceProvider { +} mjResource; +typedef struct mjpResourceProvider { const char* prefix; // prefix for match against a resource name mjfOpenResource open; // opening callback mjfReadResource read; // reading callback @@ -1234,9 +1220,8 @@ struct mjpResourceProvider { mjfUnmountResource unmount; // unmounting callback (optional) mjfResourceModified modified; // resource modified callback (optional) void* data; // opaque data pointer (resource invariant) -}; -typedef struct mjpResourceProvider mjpResourceProvider; -struct mjpDecoder { +} mjpResourceProvider; +typedef struct mjpDecoder { const char* content_type; const char* extension; // user-facing functions @@ -1244,22 +1229,20 @@ struct mjpDecoder { mjfDecode decode; // main decoding function // the caller takes ownership of the spec returned by decode and is responsible // for cleaning it up -}; -typedef struct mjpDecoder mjpDecoder; -struct mjpEncoder { +} mjpDecoder; +typedef struct mjpEncoder { const char* content_type; const char* extension; mjfEncode encode; // Function to encode an mjSpec and mjModel to a mjResource. mjfCloseResource close_resource; // Function to close/free the resource. -}; -typedef struct mjpEncoder mjpEncoder; +} mjpEncoder; typedef enum mjtPluginCapabilityBit_ { mjPLUGIN_ACTUATOR = 1<<0, // actuator forces mjPLUGIN_SENSOR = 1<<1, // sensor measurements mjPLUGIN_PASSIVE = 1<<2, // passive forces mjPLUGIN_SDF = 1<<3, // signed distance fields } mjtPluginCapabilityBit; -struct mjpPlugin_ { +typedef struct mjpPlugin_ { const char* name; // globally unique name identifying the plugin int nattribute; // number of configuration attributes @@ -1317,17 +1300,15 @@ struct mjpPlugin_ { // bounding box of implicit surface void (*sdf_aabb)(mjtNum aabb[6], const mjtNum* attributes); -}; -typedef struct mjpPlugin_ mjpPlugin; -struct mjSDF_ { +} mjpPlugin; +typedef struct mjSDF_ { const mjpPlugin** plugin; int* id; mjtSDFType type; mjtNum* relpos; mjtNum* relmat; mjtGeom* geomtype; -}; -typedef struct mjSDF_ mjSDF; +} mjSDF; typedef enum mjtGridPos_ { // grid position for overlay mjGRID_TOPLEFT = 0, // top left mjGRID_TOPRIGHT, // top right @@ -1389,20 +1370,18 @@ typedef enum mjrMeshPrimitiveType_ { // type of mesh primitive mjMESH_PRIMITIVE_TYPE_TRIANGLES = 0, // triangles mjMESH_PRIMITIVE_TYPE_LINES, // lines } mjrMeshPrimitiveType; -struct mjrRect_ { // OpenGL rectangle +typedef struct mjrRect_ { // OpenGL rectangle int left; // left (usually 0) int bottom; // bottom (usually 0) int width; // width (usually buffer width) int height; // height (usually buffer height) -}; -typedef struct mjrRect_ mjrRect; -struct mjrVertexAttribute_ { // vertex attribute format specification - const void* bytes; // vertex data - int usage; // mjrVertexAttributeUsage; e.g. position, normal, etc. - int type; // mjrVertexAttributeType; e.g. float3, ubyte4, etc. -}; -typedef struct mjrVertexAttribute_ mjrVertexAttribute; -struct mjrContext_ { // custom OpenGL context +} mjrRect; +typedef struct mjrVertexAttribute_ { // vertex attribute format specification + const void* bytes; // vertex data + int usage; // mjrVertexAttributeUsage; e.g. position, normal, etc. + int type; // mjrVertexAttributeType; e.g. float3, ubyte4, etc. +} mjrVertexAttribute; +typedef struct mjrContext_ { // custom OpenGL context // parameters copied from mjVisual float lineWidth; // line width for wireframe rendering float shadowClip; // clipping radius for directional lights @@ -1493,19 +1472,18 @@ struct mjrContext_ { // custom OpenGL context // depth output format int readDepthMap; // depth mapping: mjDEPTH_ZERONEAR or mjDEPTH_ZEROFAR -}; -typedef struct mjrContext_ mjrContext; -typedef enum mjtGeomInertia_ { // type of inertia inference +} mjrContext; +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 +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 +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 @@ -1515,46 +1493,46 @@ typedef enum mjtMeshBuiltin_ { // type of built-in procedural mesh mjMESH_BUILTIN_WEDGE, // wedge mjMESH_BUILTIN_PLATE, // plate } mjtMeshBuiltin; -typedef enum mjtBuiltin_ { // type of built-in procedural texture +typedef enum mjtBuiltin { // type of built-in procedural texture mjBUILTIN_NONE = 0, // no built-in texture mjBUILTIN_GRADIENT, // gradient: rgb1->rgb2 mjBUILTIN_CHECKER, // checker pattern: rgb1, rgb2 mjBUILTIN_FLAT // 2d: rgb1; cube: rgb1-up, rgb2-side, rgb3-down } mjtBuiltin; -typedef enum mjtMark_ { // mark type for procedural textures +typedef enum mjtMark { // mark type for procedural textures mjMARK_NONE = 0, // no mark mjMARK_EDGE, // edges mjMARK_CROSS, // cross mjMARK_RANDOM // random dots } mjtMark; -typedef enum mjtLimited_ { // type of limit specification +typedef enum mjtLimited { // type of limit specification mjLIMITED_FALSE = 0, // not limited mjLIMITED_TRUE, // limited mjLIMITED_AUTO, // limited inferred from presence of range } mjtLimited; -typedef enum mjtAlignFree_ { // whether to align free joints with the inertial frame +typedef enum mjtAlignFree { // whether to align free joints with the inertial frame mjALIGNFREE_FALSE = 0, // don't align mjALIGNFREE_TRUE, // align mjALIGNFREE_AUTO, // respect the global compiler flag } mjtAlignFree; -typedef enum mjtInertiaFromGeom_ { // whether to infer body inertias from child geoms +typedef enum mjtInertiaFromGeom { // whether to infer body inertias from child geoms mjINERTIAFROMGEOM_FALSE = 0, // do not use; inertial element required mjINERTIAFROMGEOM_TRUE, // always use; overwrite inertial element mjINERTIAFROMGEOM_AUTO // use only if inertial element is missing } mjtInertiaFromGeom; -typedef enum mjtOrientation_ { // type of orientation specifier +typedef enum mjtOrientation { // type of orientation specifier mjORIENTATION_QUAT = 0, // quaternion mjORIENTATION_AXISANGLE, // axis and angle mjORIENTATION_XYAXES, // x and y axes mjORIENTATION_ZAXIS, // z axis (minimal rotation) mjORIENTATION_EULER, // Euler angles } mjtOrientation; -typedef enum mjtConflict_ { // conflict resolution for attach +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 @@ -1590,7 +1568,7 @@ typedef struct mjsCompiler_ { // compiler options 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) + int conflict; // conflict resolution for attach (mjtConflict) mjLROpt LRopt; // options for lengthrange computation mjString* meshdir; // mesh and hfield directory mjString* texturedir; // texture directory @@ -2193,7 +2171,7 @@ typedef struct mjsDefault_ { // default specification mjsTendon* tendon; // tendon defaults mjsActuator* actuator; // actuator defaults } mjsDefault; -typedef enum mjtDisableBit_ { // disable default feature bitflags +typedef enum mjtDisableBit { // disable default feature bitflags mjDSBL_CONSTRAINT = 1<<0, // entire constraint solver mjDSBL_EQUALITY = 1<<1, // equality constraints mjDSBL_FRICTIONLOSS = 1<<2, // joint and tendon frictionloss constraints @@ -2217,7 +2195,7 @@ typedef enum mjtDisableBit_ { // disable default feature bitflags mjNDISABLE = 20 // number of disable flags } mjtDisableBit; -typedef enum mjtEnableBit_ { // enable optional feature bitflags +typedef enum mjtEnableBit { // enable optional feature bitflags mjENBL_OVERRIDE = 1<<0, // override contact parameters mjENBL_ENERGY = 1<<1, // energy computation mjENBL_FWDINV = 1<<2, // record solver statistics @@ -2227,13 +2205,13 @@ typedef enum mjtEnableBit_ { // enable optional feature bitflags mjNENABLE = 6 // number of enable flags } mjtEnableBit; -typedef enum mjtJoint_ { // type of degree of freedom +typedef enum mjtJoint { // type of degree of freedom mjJNT_FREE = 0, // global position and orientation (quat) (7) mjJNT_BALL, // orientation (quat) relative to parent (4) mjJNT_SLIDE, // sliding distance along body-fixed axis (1) mjJNT_HINGE // rotation angle (rad) around body-fixed axis (1) } mjtJoint; -typedef enum mjtGeom_ { // type of geometric shape +typedef enum mjtGeom { // type of geometric shape // regular geom types mjGEOM_PLANE = 0, // plane mjGEOM_HFIELD, // height field @@ -2260,29 +2238,29 @@ typedef enum mjtGeom_ { // type of geometric shape mjGEOM_NONE = 1001 // missing geom type } mjtGeom; -typedef enum mjtProjection_ { // type of camera projection +typedef enum mjtProjection { // type of camera projection mjPROJ_PERSPECTIVE = 0, // perspective mjPROJ_ORTHOGRAPHIC // orthographic } mjtProjection; -typedef enum mjtCamLight_ { // tracking mode for camera and light +typedef enum mjtCamLight { // tracking mode for camera and light mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global mjCAMLIGHT_TRACKCOM, // pos tracks subtree com, rot fixed in body mjCAMLIGHT_TARGETBODY, // pos fixed in body, rot tracks target body mjCAMLIGHT_TARGETBODYCOM // pos fixed in body, rot tracks target subtree com } mjtCamLight; -typedef enum mjtLightType_ { // type of light +typedef enum mjtLightType { // type of light mjLIGHT_SPOT = 0, // spot mjLIGHT_DIRECTIONAL, // directional mjLIGHT_POINT, // point mjLIGHT_IMAGE, // image-based } mjtLightType; -typedef enum mjtTexture_ { // type of texture +typedef enum mjtTexture { // type of texture mjTEXTURE_2D = 0, // 2d texture, suitable for planes and hfields mjTEXTURE_CUBE, // cube texture, suitable for all other geom types mjTEXTURE_SKYBOX // cube texture used as skybox } mjtTexture; -typedef enum mjtTextureRole_ { // role of texture map in rendering +typedef enum mjtTextureRole { // role of texture map in rendering mjTEXROLE_USER = 0, // unspecified mjTEXROLE_RGB, // base color (albedo) mjTEXROLE_OCCLUSION, // ambient occlusion @@ -2295,32 +2273,32 @@ typedef enum mjtTextureRole_ { // role of texture map in rendering mjTEXROLE_ORM, // occlusion, roughness, metallic mjNTEXROLE } mjtTextureRole; -typedef enum mjtColorSpace_ { // type of color space encoding +typedef enum mjtColorSpace { // type of color space encoding mjCOLORSPACE_AUTO = 0, // attempts to autodetect color space, defaults to linear mjCOLORSPACE_LINEAR, // linear color space mjCOLORSPACE_SRGB // standard RGB color space } mjtColorSpace; -typedef enum mjtIntegrator_ { // integrator mode +typedef enum mjtIntegrator { // integrator mode mjINT_EULER = 0, // semi-implicit Euler mjINT_RK4, // 4th-order Runge Kutta mjINT_IMPLICIT, // implicit in velocity mjINT_IMPLICITFAST // implicit in velocity, no rne derivative } mjtIntegrator; -typedef enum mjtCone_ { // type of friction cone +typedef enum mjtCone { // type of friction cone mjCONE_PYRAMIDAL = 0, // pyramidal mjCONE_ELLIPTIC // elliptic } mjtCone; -typedef enum mjtJacobian_ { // type of constraint Jacobian +typedef enum mjtJacobian { // type of constraint Jacobian mjJAC_DENSE = 0, // dense mjJAC_SPARSE, // sparse mjJAC_AUTO // dense if nv<60, sparse otherwise } mjtJacobian; -typedef enum mjtSolver_ { // constraint solver algorithm +typedef enum mjtSolver { // constraint solver algorithm mjSOL_PGS = 0, // PGS (dual) mjSOL_CG, // CG (primal) mjSOL_NEWTON // Newton (primal) } mjtSolver; -typedef enum mjtEq_ { // type of equality constraint +typedef enum mjtEq { // type of equality constraint mjEQ_CONNECT = 0, // connect two bodies at a point (ball joint) mjEQ_WELD, // fix relative position and orientation of two bodies mjEQ_JOINT, // couple the values of two scalar joints with cubic @@ -2330,7 +2308,7 @@ typedef enum mjtEq_ { // type of equality constraint mjEQ_FLEXSTRAIN, // constrain strain of a trilinear/quadratic flex (B-bar) mjEQ_DISTANCE // unsupported, will cause an error if used } mjtEq; -typedef enum mjtWrap_ { // type of tendon wrap object +typedef enum mjtWrap { // type of tendon wrap object mjWRAP_NONE = 0, // null object mjWRAP_JOINT, // constant moment arm mjWRAP_PULLEY, // pulley used to split tendon @@ -2338,7 +2316,7 @@ typedef enum mjtWrap_ { // type of tendon wrap object mjWRAP_SPHERE, // wrap around sphere mjWRAP_CYLINDER // wrap around (infinite) cylinder } mjtWrap; -typedef enum mjtTrn_ { // type of actuator transmission +typedef enum mjtTrn { // type of actuator transmission mjTRN_JOINT = 0, // force on joint mjTRN_JOINTINPARENT, // force on joint, expressed in parent frame mjTRN_SLIDERCRANK, // force via slider-crank linkage @@ -2348,7 +2326,7 @@ typedef enum mjtTrn_ { // type of actuator transmission mjTRN_UNDEFINED = 1000 // undefined transmission type } mjtTrn; -typedef enum mjtDyn_ { // type of actuator dynamics +typedef enum mjtDyn { // type of actuator dynamics mjDYN_NONE = 0, // no internal dynamics; ctrl specifies force mjDYN_INTEGRATOR, // integrator: da/dt = u mjDYN_FILTER, // linear filter: da/dt = (u-a) / tau @@ -2357,21 +2335,21 @@ typedef enum mjtDyn_ { // type of actuator dynamics mjDYN_DCMOTOR, // DC motor electrical dynamics mjDYN_USER // user-defined dynamics type } mjtDyn; -typedef enum mjtGain_ { // type of actuator gain +typedef enum mjtGain { // type of actuator gain mjGAIN_FIXED = 0, // fixed gain mjGAIN_AFFINE, // const + kp*length + kv*velocity mjGAIN_MUSCLE, // muscle FLV curve computed by mju_muscleGain() mjGAIN_DCMOTOR, // DC motor gain: K or K/R mjGAIN_USER // user-defined gain type } mjtGain; -typedef enum mjtBias_ { // type of actuator bias +typedef enum mjtBias { // type of actuator bias mjBIAS_NONE = 0, // no bias mjBIAS_AFFINE, // const + kp*length + kv*velocity mjBIAS_MUSCLE, // muscle passive force computed by mju_muscleBias() mjBIAS_DCMOTOR, // DC motor bias: back-EMF, cogging, LuGre friction mjBIAS_USER // user-defined bias type } mjtBias; -typedef enum mjtObj_ { // type of MujoCo object +typedef enum mjtObj { // type of MujoCo object mjOBJ_UNKNOWN = 0, // unknown object type mjOBJ_BODY, // body mjOBJ_XBODY, // body, used to access regular frame instead of i-frame @@ -2406,7 +2384,7 @@ typedef enum mjtObj_ { // type of MujoCo object mjOBJ_DEFAULT, // default mjOBJ_MODEL // entire model } mjtObj; -typedef enum mjtSensor_ { // type of sensor +typedef enum mjtSensor { // type of sensor // common robotic sensors, attached to a site mjSENS_TOUCH = 0, // scalar contact normal forces summed over sensor zone mjSENS_ACCELEROMETER, // 3D linear acceleration, in local frame @@ -2480,19 +2458,19 @@ typedef enum mjtSensor_ { // type of sensor // user-defined sensor mjSENS_USER // sensor data provided by mjcb_sensor callback } mjtSensor; -typedef enum mjtStage_ { // computation stage +typedef enum mjtStage { // computation stage mjSTAGE_NONE = 0, // no computations mjSTAGE_POS, // position-dependent computations mjSTAGE_VEL, // velocity-dependent computations mjSTAGE_ACC // acceleration/force-dependent computations } mjtStage; -typedef enum mjtDataType_ { // data type for sensors +typedef enum mjtDataType { // data type for sensors mjDATATYPE_REAL = 0, // real values, no constraints mjDATATYPE_POSITIVE, // positive values; 0 or negative: inactive mjDATATYPE_AXIS, // 3D unit vector mjDATATYPE_QUATERNION // unit quaternion } mjtDataType; -typedef enum mjtConDataField_ { // data fields returned by contact sensors +typedef enum mjtConDataField { // data fields returned by contact sensors mjCONDATA_FOUND = 0, // whether a contact was found mjCONDATA_FORCE, // contact force mjCONDATA_TORQUE, // contact torque @@ -2503,7 +2481,7 @@ typedef enum mjtConDataField_ { // data fields returned by contact sensors mjNCONDATA // number of contact sensor data fields } mjtConDataField; -typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors +typedef enum mjtRayDataField { // data fields returned by rangefinder sensors mjRAYDATA_DIST = 0, // distance from ray origin to nearest surface mjRAYDATA_DIR, // normalized ray direction mjRAYDATA_ORIGIN, // ray origin @@ -2513,7 +2491,7 @@ typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors mjNRAYDATA // number of rangefinder sensor data fields } mjtRayDataField; -typedef enum mjtCamOutBit_ { // camera output type bitflags +typedef enum mjtCamOutBit { // camera output type bitflags mjCAMOUT_RGB = 1<<0, // RGB image mjCAMOUT_DEPTH = 1<<1, // depth image (distance from camera plane) mjCAMOUT_DIST = 1<<2, // distance image (distance from camera origin) @@ -2522,14 +2500,14 @@ typedef enum mjtCamOutBit_ { // camera output type bitflags mjNCAMOUT = 5 // number of camera output types } mjtCamOutBit; -typedef enum mjtSameFrame_ { // frame alignment of bodies with their children +typedef enum mjtSameFrame { // frame alignment of bodies with their children mjSAMEFRAME_NONE = 0, // no alignment mjSAMEFRAME_BODY, // frame is same as body frame mjSAMEFRAME_INERTIA, // frame is same as inertial frame mjSAMEFRAME_BODYROT, // frame orientation is same as body orientation mjSAMEFRAME_INERTIAROT // frame orientation is same as inertia orientation } mjtSameFrame; -typedef enum mjtSleepPolicy_ { // per-tree sleep policy +typedef enum mjtSleepPolicy { // per-tree sleep policy mjSLEEP_AUTO = 0, // compiler chooses sleep policy mjSLEEP_AUTO_NEVER, // compiler sleep policy: never mjSLEEP_AUTO_ALLOWED, // compiler sleep policy: allowed @@ -2537,26 +2515,26 @@ typedef enum mjtSleepPolicy_ { // per-tree sleep policy mjSLEEP_ALLOWED, // user sleep policy: allowed mjSLEEP_INIT, // user sleep policy: initialized asleep } mjtSleepPolicy; -typedef enum mjtLRMode_ { // mode for actuator length range computation +typedef enum mjtLRMode { // mode for actuator length range computation mjLRMODE_NONE = 0, // do not process any actuators mjLRMODE_MUSCLE, // process muscle actuators mjLRMODE_MUSCLEUSER, // process muscle and user actuators mjLRMODE_ALL // process all actuators } mjtLRMode; -typedef enum mjtFlexSelf_ { // mode for flex selfcollide +typedef enum mjtFlexSelf { // mode for flex selfcollide mjFLEXSELF_NONE = 0, // no self-collisions mjFLEXSELF_NARROW, // skip midphase, go directly to narrowphase mjFLEXSELF_BVH, // use BVH in midphase (if midphase enabled) mjFLEXSELF_SAP, // use SAP in midphase mjFLEXSELF_AUTO // choose between BVH and SAP automatically } mjtFlexSelf; -typedef enum mjtSDFType_ { // signed distance function (SDF) type +typedef enum mjtSDFType { // signed distance function (SDF) type mjSDFTYPE_SINGLE = 0, // single SDF mjSDFTYPE_INTERSECTION, // max(A, B) mjSDFTYPE_MIDSURFACE, // A - B mjSDFTYPE_COLLISION, // A + B + abs(max(A, B)) } mjtSDFType; -typedef enum mjtState_ { // state elements +typedef enum mjtState { // state elements mjSTATE_TIME = 1<<0, // time mjSTATE_QPOS = 1<<1, // position mjSTATE_QVEL = 1<<2, // velocity @@ -2582,7 +2560,7 @@ typedef enum mjtState_ { // state elements mjSTATE_USERDATA, mjSTATE_INTEGRATION = mjSTATE_FULLPHYSICS | mjSTATE_USER | mjSTATE_WARMSTART } mjtState; -typedef enum mjtConstraint_ { // type of constraint +typedef enum mjtConstraint { // type of constraint mjCNSTR_EQUALITY = 0, // equality constraint mjCNSTR_FRICTION_DOF, // dof friction mjCNSTR_FRICTION_TENDON, // tendon friction @@ -2592,14 +2570,14 @@ typedef enum mjtConstraint_ { // type of constraint mjCNSTR_CONTACT_PYRAMIDAL, // frictional contact, pyramidal friction cone mjCNSTR_CONTACT_ELLIPTIC // frictional contact, elliptic friction cone } mjtConstraint; -typedef enum mjtConstraintState_ { // constraint state +typedef enum mjtConstraintState { // constraint state mjCNSTRSTATE_SATISFIED = 0, // constraint satisfied, zero cost (limit, contact) mjCNSTRSTATE_QUADRATIC, // quadratic cost (equality, friction, limit, contact) mjCNSTRSTATE_LINEARNEG, // linear cost, negative side (friction) mjCNSTRSTATE_LINEARPOS, // linear cost, positive side (friction) mjCNSTRSTATE_CONE // squared distance to cone cost (elliptic contact) } mjtConstraintState; -typedef enum mjtWarning_ { // warning types +typedef enum mjtWarning { // warning types mjWARN_INERTIA = 0, // (near) singular inertia matrix mjWARN_CONTACTFULL, // too many contacts in contact list mjWARN_CNSTRFULL, // too many constraints @@ -2610,7 +2588,7 @@ typedef enum mjtWarning_ { // warning types mjNWARNING // number of warnings } mjtWarning; -typedef enum mjtTimer_ { // internal timers +typedef enum mjtTimer { // internal timers // main api mjTIMER_STEP = 0, // step mjTIMER_FORWARD, // forward @@ -2636,18 +2614,18 @@ typedef enum mjtTimer_ { // internal timers mjNTIMER // number of timers } mjtTimer; -typedef enum mjtSleepState_ { // sleep state of an object +typedef enum mjtSleepState { // sleep state of an object mjS_STATIC = -1, // object is static mjS_ASLEEP = 0, // object is asleep mjS_AWAKE = 1 // object is awake } mjtSleepState; -typedef enum mjtLogLevel_ { // log message severity +typedef enum mjtLogLevel { // log message severity mjLOG_DEBUG = 0, // internal engine debug trace (opt-in via topic filtering) mjLOG_INFO, // informational (opt-in via topic filtering) mjLOG_WARNING, // warning mjLOG_ERROR, // error } mjtLogLevel; -typedef enum mjtLogTopic_ { // log topic identifiers +typedef enum mjtLogTopic { // log topic identifiers mjTOPIC_NONE = 0, // no topic (always passes filtering) // INFO topics: mjTOPIC_TIME_STP = 1, // timing diagnostics (step) @@ -2673,13 +2651,13 @@ typedef struct mjLogConfig_ { // log handler default configuration char logfile[1024]; // log file path (default: "MUJOCO_LOG.TXT") int topics; // enabled info topic bitmask (default: 0) } mjLogConfig; -typedef enum mjtButton_ { // mouse button +typedef enum mjtButton { // mouse button mjBUTTON_NONE = 0, // no button mjBUTTON_LEFT, // left button mjBUTTON_RIGHT, // right button mjBUTTON_MIDDLE // middle button } mjtButton; -typedef enum mjtEvent_ { // mouse and keyboard event type +typedef enum mjtEvent { // mouse and keyboard event type mjEVENT_NONE = 0, // no event mjEVENT_MOVE, // mouse move mjEVENT_PRESS, // mouse button press @@ -2690,7 +2668,7 @@ typedef enum mjtEvent_ { // mouse and keyboard event type mjEVENT_REDRAW, // redraw mjEVENT_FILESDROP // files drop } mjtEvent; -typedef enum mjtItem_ { // UI item type +typedef enum mjtItem { // UI item type mjITEM_END = -2, // end of definition list (not an item) mjITEM_SECTION = -1, // section (not an item) mjITEM_SEPARATOR = 0, // separator @@ -2712,12 +2690,12 @@ typedef enum mjtItem_ { // UI item type mjNITEM // number of item types } mjtItem; -typedef enum mjtSection_ { // UI section state +typedef enum mjtSection { // UI section state mjSECT_CLOSED = 0, // closed state (regular section) mjSECT_OPEN, // open state (regular section) mjSECT_FIXED // fixed section: always open, no title } mjtSection; -struct mjuiState_ { // mouse and keyboard state +typedef struct mjuiState_ { // mouse and keyboard state // constants set by user int nrect; // number of rectangles used mjrRect rect[mjMAXUIRECT]; // rectangles (index 0: entire window) @@ -2757,25 +2735,23 @@ struct mjuiState_ { // mouse and keyboard state // files dropping (only valid when type == mjEVENT_FILESDROP) int dropcount; // number of files dropped const char** droppaths; // paths to files dropped -}; -typedef struct mjuiState_ mjuiState; -struct mjuiThemeSpacing_ { // UI visualization theme spacing - int total; // total width - int scroll; // scrollbar width - int label; // label width - int section; // section gap - int cornersect; // corner radius for section - int cornersep; // corner radius for separator - int itemside; // item side gap - int itemmid; // item middle gap - int itemver; // item vertical gap - int texthor; // text horizontal gap - int textver; // text vertical gap - int linescroll; // number of pixels to scroll - int samples; // number of multisamples -}; -typedef struct mjuiThemeSpacing_ mjuiThemeSpacing; -struct mjuiThemeColor_ { // UI visualization theme color +} mjuiState; +typedef struct mjuiThemeSpacing_ { // UI visualization theme spacing + int total; // total width + int scroll; // scrollbar width + int label; // label width + int section; // section gap + int cornersect; // corner radius for section + int cornersep; // corner radius for separator + int itemside; // item side gap + int itemmid; // item middle gap + int itemver; // item vertical gap + int texthor; // text horizontal gap + int textver; // text vertical gap + int linescroll; // number of pixels to scroll + int samples; // number of multisamples +} mjuiThemeSpacing; +typedef struct mjuiThemeColor_ { // UI visualization theme color float master[3]; // master background float thumb[3]; // scrollbar thumb float secttitle[3]; // section title @@ -2804,8 +2780,7 @@ struct mjuiThemeColor_ { // UI visualization theme color float edit[3]; // edit float edit2[3]; // edit invalid float cursor[3]; // edit cursor -}; -typedef struct mjuiThemeColor_ mjuiThemeColor; +} mjuiThemeColor; struct mjuiItemSingle_ { // check and button-related int modifier; // 0: none, 1: control, 2: shift; 4: alt int shortcut; // shortcut key; 0: undefined @@ -2830,7 +2805,7 @@ struct mjuiItemEdit_ { // edit-related }; -struct mjuiItem_ { // UI item +typedef struct mjuiItem_ { // UI item // common properties int type; // type (mjtItem) char name[mjMAXUINAME]; // name @@ -2851,9 +2826,8 @@ struct mjuiItem_ { // UI item // internal mjrRect rect; // rectangle occupied by item int skip; // item skipped due to closed separator -}; -typedef struct mjuiItem_ mjuiItem; -struct mjuiSection_ { // UI section +} mjuiItem; +typedef struct mjuiSection_ { // UI section // properties char name[mjMAXUINAME]; // name int state; // section state (mjtSection) @@ -2867,9 +2841,8 @@ struct mjuiSection_ { // UI section mjrRect rtitle; // rectangle occupied by title mjrRect rcontent; // rectangle occupied by content int lastclick; // last mouse click over this section -}; -typedef struct mjuiSection_ mjuiSection; -struct mjUI_ { // entire UI +} mjuiSection; +typedef struct mjUI_ { // entire UI // constants set by user mjuiThemeSpacing spacing; // UI theme spacing mjuiThemeColor color; // UI theme color @@ -2903,17 +2876,15 @@ struct mjUI_ { // entire UI // sections int nsect; // number of sections in use mjuiSection sect[mjMAXUISECT]; // preallocated array of sections -}; -typedef struct mjUI_ mjUI; -struct mjuiDef_ { // table passed to mjui_add() +} mjUI; +typedef struct mjuiDef_ { // table passed to mjui_add() int type; // type (mjtItem); -1: section char name[mjMAXUINAME]; // name int state; // state void* pdata; // pointer to data char other[mjMAXUITEXT]; // string with type-specific properties int otherint; // int with type-specific properties -}; -typedef struct mjuiDef_ mjuiDef; +} mjuiDef; typedef enum mjtCatBit_ { // bitflags for mjvGeom category mjCAT_STATIC = 1, // model elements in body 0 mjCAT_DYNAMIC = 2, // model elements in all other bodies @@ -3028,7 +2999,7 @@ typedef enum mjtStereo_ { // type of stereo rendering mjSTEREO_QUADBUFFERED, // quad buffered; revert to side-by-side if no hardware support mjSTEREO_SIDEBYSIDE // side-by-side } mjtStereo; -struct mjvPerturb_ { // object selection and perturbation +typedef struct mjvPerturb_ { // object selection and perturbation int select; // selected body id; non-positive: none int flexselect; // selected flex id; negative: none int skinselect; // selected skin id; negative: none @@ -3040,9 +3011,8 @@ struct mjvPerturb_ { // object selection and perturbation mjtNum localpos[3]; // selection point in object coordinates mjtNum localmass; // spatial inertia at selection point mjtNum scale; // relative mouse motion-to-space scaling (set by initPerturb) -}; -typedef struct mjvPerturb_ mjvPerturb; -struct mjvCamera_ { // abstract camera +} mjvPerturb; +typedef struct mjvCamera_ { // abstract camera // type and ids int type; // camera type (mjtCamera) int fixedcamid; // fixed camera id @@ -3056,9 +3026,8 @@ struct mjvCamera_ { // abstract camera // orthographic / perspective int orthographic; // 0: perspective; 1: orthographic -}; -typedef struct mjvCamera_ mjvCamera; -struct mjvGLCamera_ { // OpenGL camera +} mjvCamera; +typedef struct mjvGLCamera_ { // OpenGL camera // camera frame float pos[3]; // position float forward[3]; // forward direction @@ -3074,9 +3043,8 @@ struct mjvGLCamera_ { // OpenGL camera // orthographic / perspective int orthographic; // 0: perspective; 1: orthographic -}; -typedef struct mjvGLCamera_ mjvGLCamera; -struct mjvGeom_ { // abstract geom +} mjvGLCamera; +typedef struct mjvGeom_ { // abstract geom // type info int type; // geom type (mjtGeom) int dataid; // mesh, hfield or plane id; -1: none; mesh: 2*id or 2*id+1 (hull) @@ -3105,9 +3073,8 @@ struct mjvGeom_ { // abstract geom float camdist; // distance to camera (used by sorter) float modelrbound; // geom rbound from model, 0 if not model geom mjtByte transparent; // treat geom as transparent -}; -typedef struct mjvGeom_ mjvGeom; -struct mjvLight_ { // OpenGL light +} mjvGeom; +typedef struct mjvLight_ { // OpenGL light int id; // light id, -1 for headlight float pos[3]; // position rel. to body frame float dir[3]; // direction rel. to body frame @@ -3124,9 +3091,8 @@ struct mjvLight_ { // OpenGL light float bulbradius; // bulb radius for soft shadows float intensity; // intensity, in candelas float range; // range of effectiveness -}; -typedef struct mjvLight_ mjvLight; -struct mjvOption_ { // abstract visualization options +} mjvLight; +typedef struct mjvOption_ { // abstract visualization options int label; // what objects to label (mjtLabel) int frame; // which frame to show (mjtFrame) mjtByte geomgroup[mjNGROUP]; // geom visualization by group @@ -3139,9 +3105,8 @@ struct mjvOption_ { // abstract visualization options mjtByte flags[mjNVISFLAG]; // visualization flags (indexed by mjtVisFlag) int bvh_depth; // depth of the bounding volume hierarchy to be visualized int flex_layer; // element layer to be visualized for 3D flex -}; -typedef struct mjvOption_ mjvOption; -struct mjvScene_ { // abstract scene passed to OpenGL renderer +} mjvOption; +typedef struct mjvScene_ { // abstract scene passed to OpenGL renderer // abstract geoms int maxgeom; // size of allocated geom buffer int ngeom; // number of geoms currently in buffer @@ -3198,9 +3163,8 @@ struct mjvScene_ { // abstract scene passed to OpenGL renderer // geom buffer status int status; // 0: ok, 1: geoms exhausted, warning issued -}; -typedef struct mjvScene_ mjvScene; -struct mjvFigure_ { // abstract 2D figure passed to OpenGL renderer +} mjvScene; +typedef struct mjvFigure_ { // abstract 2D figure passed to OpenGL renderer // enable flags int flg_legend; // show legend int flg_ticklabel[2]; // show grid tick labels (x,y) @@ -3245,8 +3209,7 @@ struct mjvFigure_ { // abstract 2D figure passed to OpenGL rendere int yaxispixel[2]; // range of y-axis in pixels float xaxisdata[2]; // range of x-axis in data units float yaxisdata[2]; // range of y-axis in data units -}; -typedef struct mjvFigure_ mjvFigure; +} mjvFigure; //----------------------------- MJAPI FUNCTIONS -------------------------------- void mj_defaultVFS(mjVFS* vfs); diff --git a/include/mujoco/mjdata.h b/include/mujoco/mjdata.h index e0d796af..f31dc5b6 100644 --- a/include/mujoco/mjdata.h +++ b/include/mujoco/mjdata.h @@ -26,15 +26,15 @@ //------------------------------------- Contact ---------------------------------------------------- -struct mjPreContact_ { // contact parameters set by narrowphase collision functions +typedef struct mjPreContact_ { // contact parameters set by narrowphase collision functions mjtNum dist; mjtNum pos[3]; mjtNum normal[3]; // contact normal of the collision mjtNum tangent[3]; // first tangent direction -}; -typedef struct mjPreContact_ mjPreContact; +} mjPreContact; -struct mjContact_ { // result of collision detection functions + +typedef struct mjContact_ { // result of collision detection functions // contact parameters set by narrowphase collision function mjtNum dist; // distance between nearest points; neg: penetration mjtNum pos[3]; // position of contact point: midpoint between geoms @@ -65,41 +65,37 @@ struct mjContact_ { // result of collision detection functions // address computed by mj_instantiateContact int efc_address; // address in efc; -1: not included -}; -typedef struct mjContact_ mjContact; +} mjContact; //---------------------------------- diagnostics --------------------------------------------------- -struct mjWarningStat_ { // warning statistics - int lastinfo; // info from last warning - int number; // how many times was warning raised -}; -typedef struct mjWarningStat_ mjWarningStat; +typedef struct mjWarningStat_ { // warning statistics + int lastinfo; // info from last warning + int number; // how many times was warning raised +} mjWarningStat; -struct mjTimerStat_ { // timer statistics - mjtNum duration; // cumulative duration - int number; // how many times was timer called -}; -typedef struct mjTimerStat_ mjTimerStat; +typedef struct mjTimerStat_ { // timer statistics + mjtNum duration; // cumulative duration + int number; // how many times was timer called +} mjTimerStat; -struct mjSolverStat_ { // per-iteration solver statistics - mjtNum improvement; // cost reduction, scaled by 1/trace(M(qpos0)) - mjtNum gradient; // gradient norm (primal only, scaled) - mjtNum lineslope; // slope in linesearch - int nactive; // number of active constraints - int nchange; // number of constraint state changes - int neval; // number of cost evaluations in line search - int nupdate; // number of Cholesky updates in line search -}; -typedef struct mjSolverStat_ mjSolverStat; +typedef struct mjSolverStat_ { // per-iteration solver statistics + mjtNum improvement; // cost reduction, scaled by 1/trace(M(qpos0)) + mjtNum gradient; // gradient norm (primal only, scaled) + mjtNum lineslope; // slope in linesearch + int nactive; // number of active constraints + int nchange; // number of constraint state changes + int neval; // number of cost evaluations in line search + int nupdate; // number of Cholesky updates in line search +} mjSolverStat; //---------------------------------- mjData -------------------------------------------------------- -struct mjData_ { +typedef struct mjData_ { // constant sizes mjtSize narena; // size of the arena in bytes (inclusive of the stack) mjtSize nbuffer; // size of main buffer in bytes @@ -411,8 +407,7 @@ struct mjData_ { // compilation signature uint64_t signature; // also held by the mjSpec that compiled the model -}; -typedef struct mjData_ mjData; +} mjData; //---------------------------------- callback function types --------------------------------------- diff --git a/include/mujoco/mjmodel.h b/include/mujoco/mjmodel.h index 2b1e013b..6dbd3789 100644 --- a/include/mujoco/mjmodel.h +++ b/include/mujoco/mjmodel.h @@ -50,7 +50,7 @@ //---------------------------------- mjLROpt ------------------------------------------------------- -struct mjLROpt_ { // options for mj_setLengthRange() +typedef struct mjLROpt_ { // options for mj_setLengthRange() // flags int mode; // which actuators to process (mjtLRMode) int useexisting; // use existing length range if available @@ -64,26 +64,23 @@ struct mjLROpt_ { // options for mj_setLengthRange() mjtNum inttotal; // total simulation time interval mjtNum interval; // evaluation time interval (at the end) mjtNum tolrange; // convergence tolerance (relative to range) -}; -typedef struct mjLROpt_ mjLROpt; +} mjLROpt; //---------------------------------- mjCache ------------------------------------------------------- -struct mjCache_ { // asset cache used by the compiler +typedef struct mjCache_ { // asset cache used by the compiler void* impl_; // internal pointer to cache -}; -typedef struct mjCache_ mjCache; +} mjCache; //---------------------------------- mjVFS --------------------------------------------------------- -struct mjVFS_ { // virtual file system for loading from memory +typedef struct mjVFS_ { // virtual file system for loading from memory void* impl_; // internal pointer to VFS memory -}; -typedef struct mjVFS_ mjVFS; +} mjVFS; //---------------------------------- mjOption ------------------------------------------------------ -struct mjOption_ { // physics options +typedef struct mjOption_ { // physics options // timing parameters mjtNum timestep; // timestep @@ -126,13 +123,12 @@ struct mjOption_ { // physics options // sdf collision settings int sdf_initpoints; // number of starting points for gradient descent int sdf_iterations; // max number of iterations for gradient descent -}; -typedef struct mjOption_ mjOption; +} mjOption; //---------------------------------- mjVisual ------------------------------------------------------ -struct mjVisual_ { // visualization options +typedef struct mjVisual_ { // visualization options struct { // global parameters int cameraid; // initial camera id (-1: free) int orthographic; // is the free camera orthographic (0: no, 1: yes) @@ -227,25 +223,23 @@ struct mjVisual_ { // visualization options float bv[4]; // bounding volume float bvactive[4]; // active bounding volume } rgba; -}; -typedef struct mjVisual_ mjVisual; +} mjVisual; //---------------------------------- mjStatistic --------------------------------------------------- -struct mjStatistic_ { // model statistics (in qpos0) +typedef struct mjStatistic_ { // model statistics (in qpos0) mjtNum meaninertia; // mean diagonal inertia mjtNum meanmass; // mean body mass mjtNum meansize; // mean body size mjtNum extent; // spatial extent mjtNum center[3]; // center of model -}; -typedef struct mjStatistic_ mjStatistic; +} mjStatistic; //---------------------------------- mjModel ------------------------------------------------------- -struct mjModel_ { +typedef struct mjModel_ { // ------------------------------- sizes // sizes needed at mjModel construction @@ -896,7 +890,6 @@ struct mjModel_ { // compilation signature uint64_t signature; // also held by the mjSpec that compiled this model -}; -typedef struct mjModel_ mjModel; +} mjModel; #endif // MUJOCO_MJMODEL_H_ diff --git a/include/mujoco/mjplugin.h b/include/mujoco/mjplugin.h index e1656d34..ae6bfb11 100644 --- a/include/mujoco/mjplugin.h +++ b/include/mujoco/mjplugin.h @@ -24,14 +24,13 @@ //---------------------------------- Resource Provider --------------------------------------------- -struct mjResource_ { +typedef struct mjResource_ { char* name; // name of resource (filename, etc) void* data; // opaque data pointer mjVFS* vfs; // pointer to the VFS char timestamp[512]; // timestamp of the resource const struct mjpResourceProvider* provider; // pointer to the provider -}; -typedef struct mjResource_ mjResource; +} mjResource; // callback for opening a resource, returns zero on failure. // Note: If opening fails, the close callback will not be called. Therefore, the @@ -60,7 +59,7 @@ typedef int (*mjfUnmountResource)(mjResource* resource); typedef int (*mjfResourceModified)(const mjResource* resource, const char* timestamp); // struct describing a single resource provider -struct mjpResourceProvider { +typedef struct mjpResourceProvider { const char* prefix; // prefix for match against a resource name mjfOpenResource open; // opening callback mjfReadResource read; // reading callback @@ -69,8 +68,7 @@ struct mjpResourceProvider { mjfUnmountResource unmount; // unmounting callback (optional) mjfResourceModified modified; // resource modified callback (optional) void* data; // opaque data pointer (resource invariant) -}; -typedef struct mjpResourceProvider mjpResourceProvider; +} mjpResourceProvider; //---------------------------------- Decoder ------------------------------------------------------- @@ -81,7 +79,7 @@ typedef mjSpec* (*mjfDecode)(mjResource* resource, const mjVFS* vfs); typedef int (*mjfCanDecode)(const mjResource* resource); // the struct defining the decoder plugin's interface -struct mjpDecoder { +typedef struct mjpDecoder { const char* content_type; const char* extension; // user-facing functions @@ -89,21 +87,19 @@ struct mjpDecoder { mjfDecode decode; // main decoding function // the caller takes ownership of the spec returned by decode and is responsible // for cleaning it up -}; -typedef struct mjpDecoder mjpDecoder; +} mjpDecoder; //---------------------------------- Encoder ------------------------------------------------------- typedef int (*mjfEncode)(const mjSpec* s, const mjModel* m, const mjVFS* vfs, mjResource* resource); -struct mjpEncoder { +typedef struct mjpEncoder { const char* content_type; const char* extension; mjfEncode encode; // Function to encode an mjSpec and mjModel to a mjResource. mjfCloseResource close_resource; // Function to close/free the resource. -}; -typedef struct mjpEncoder mjpEncoder; +} mjpEncoder; //---------------------------------- Plugins ------------------------------------------------------- @@ -114,7 +110,7 @@ typedef enum mjtPluginCapabilityBit_ { mjPLUGIN_SDF = 1<<3, // signed distance fields } mjtPluginCapabilityBit; -struct mjpPlugin_ { +typedef struct mjpPlugin_ { const char* name; // globally unique name identifying the plugin int nattribute; // number of configuration attributes @@ -172,18 +168,16 @@ struct mjpPlugin_ { // bounding box of implicit surface void (*sdf_aabb)(mjtNum aabb[6], const mjtNum* attributes); -}; -typedef struct mjpPlugin_ mjpPlugin; +} mjpPlugin; -struct mjSDF_ { +typedef struct mjSDF_ { const mjpPlugin** plugin; int* id; mjtSDFType type; mjtNum* relpos; mjtNum* relmat; mjtGeom* geomtype; -}; -typedef struct mjSDF_ mjSDF; +} mjSDF; //------------------------------------ Initialization ---------------------------------------------- diff --git a/include/mujoco/mjrender.h b/include/mujoco/mjrender.h index 5a927c34..5e1a0d3e 100644 --- a/include/mujoco/mjrender.h +++ b/include/mujoco/mjrender.h @@ -109,21 +109,19 @@ typedef enum mjrMeshPrimitiveType_ { // type of mesh primitive } mjrMeshPrimitiveType; -struct mjrRect_ { // OpenGL rectangle +typedef struct mjrRect_ { // OpenGL rectangle int left; // left (usually 0) int bottom; // bottom (usually 0) int width; // width (usually buffer width) int height; // height (usually buffer height) -}; -typedef struct mjrRect_ mjrRect; +} mjrRect; -struct mjrVertexAttribute_ { // vertex attribute format specification - const void* bytes; // vertex data - int usage; // mjrVertexAttributeUsage; e.g. position, normal, etc. - int type; // mjrVertexAttributeType; e.g. float3, ubyte4, etc. -}; -typedef struct mjrVertexAttribute_ mjrVertexAttribute; +typedef struct mjrVertexAttribute_ { // vertex attribute format specification + const void* bytes; // vertex data + int usage; // mjrVertexAttributeUsage; e.g. position, normal, etc. + int type; // mjrVertexAttributeType; e.g. float3, ubyte4, etc. +} mjrVertexAttribute; // alias non-rendering types into mjr namespace @@ -135,7 +133,7 @@ typedef mjvGLCamera mjrCamera; //---------------------------------- mjrContext ---------------------------------------------------- -struct mjrContext_ { // custom OpenGL context +typedef struct mjrContext_ { // custom OpenGL context // parameters copied from mjVisual float lineWidth; // line width for wireframe rendering float shadowClip; // clipping radius for directional lights @@ -226,8 +224,7 @@ struct mjrContext_ { // custom OpenGL context // depth output format int readDepthMap; // depth mapping: mjDEPTH_ZERONEAR or mjDEPTH_ZEROFAR -}; -typedef struct mjrContext_ mjrContext; +} mjrContext; #if defined(__cplusplus) } diff --git a/include/mujoco/mjrfilament.h b/include/mujoco/mjrfilament.h index d6e00039..4b962c7f 100644 --- a/include/mujoco/mjrfilament.h +++ b/include/mujoco/mjrfilament.h @@ -89,12 +89,11 @@ typedef enum mjrGraphicsApi_ { // underlying graphics API to use for rendering mjGRAPHICS_API_VULKAN, // vulkan } mjrGraphicsApi; -struct mjrfContextConfig_ { // parameters for creating filament context (mjrfContext) +typedef struct mjrfContextConfig_ { // parameters for creating filament context (mjrfContext) int graphics_api; // mjrGraphicsApi; rendering graphics API mjtBool force_software_rendering; // force backend to use software rendering void* native_window; // platform-dependent window handle (or nullptr for windowless) -}; -typedef struct mjrfContextConfig_ mjrfContextConfig; +} mjrfContextConfig; // Initializes the mjrfContextConfig to default values. void mjrf_defaultContextConfig(mjrfContextConfig* config); @@ -115,29 +114,27 @@ typedef enum mjrDrawMode_ { // how to draw objects in the scene mjDRAW_MODE_SEGMENTATION_BY_COLOR, // generate visually distinct colors using segmentation id } mjrDrawMode; -struct mjrfRenderRequest_ { // a single rendering operation - mjrfScene* scene; // scene to render - mjrCamera camera; // camera (viewpoint) from which to render scene - mjrRect viewport; // viewport (rect area) into which to render - mjrfRenderTarget* target; // target used for rendering (or nullptr for window rendering) - int draw_mode; // mjrDrawMode; method to use for drawing objects - mjtBool enable_post_processing; // enable post processing, enabled by default - mjtBool enable_reflections; // enable reflections, enabled by default - mjtBool enable_shadows; // enable shadows, enabled by default -}; -typedef struct mjrfRenderRequest_ mjrfRenderRequest; +typedef struct mjrfRenderRequest_ { // a single rendering operation + mjrfScene* scene; // scene to render + mjrCamera camera; // camera (viewpoint) from which to render scene + mjrRect viewport; // viewport (rect area) into which to render + mjrfRenderTarget* target; // target used for rendering (or nullptr for window rendering) + int draw_mode; // mjrDrawMode; method to use for drawing objects + mjtBool enable_post_processing; // enable post processing, enabled by default + mjtBool enable_reflections; // enable reflections, enabled by default + mjtBool enable_shadows; // enable shadows, enabled by default +} mjrfRenderRequest; // Initializes the mjrfRenderRequest to default values. void mjrf_defaultRenderRequest(mjrfRenderRequest* request); -struct mjrfReadPixelsRequest_ { // a single read operation - mjrfRenderTarget* target; // render target from which to read the image pixels - void* output; // buffer into which the pixels will be stored - mjtSize num_bytes; // size of output buffer - mjrfCallback read_completed; // callback when read is complete; can use to free output - void* user_data; // user data for read_completed_callback -}; -typedef struct mjrfReadPixelsRequest_ mjrfReadPixelsRequest; +typedef struct mjrfReadPixelsRequest_ { // a single read operation + mjrfRenderTarget* target; // render target from which to read the image pixels + void* output; // buffer into which the pixels will be stored + mjtSize num_bytes; // size of output buffer + mjrfCallback read_completed; // callback when read is complete; can use to free output + void* user_data; // user data for read_completed_callback +} mjrfReadPixelsRequest; // Initializes the mjrfReadPixelsRequest to default values. void mjrf_defaultReadPixelsRequest(mjrfReadPixelsRequest* request); @@ -164,10 +161,9 @@ void mjrf_waitForFrame(mjrfContext* ctx, mjrfFrameHandle frame); // Sets the clear color for the renderer. void mjrf_setClearColor(mjrfContext* ctx, const float color[3]); -struct mjrfFrameStats_ { // stats for a single frame of rendering - double frame_rate; // frame rate, in frames per second -}; -typedef struct mjrfFrameStats_ mjrfFrameStats; +typedef struct mjrfFrameStats_ { // stats for a single frame of rendering + double frame_rate; // frame rate, in frames per second +} mjrfFrameStats; // Initializes the mjrFrameStats to default values. void mjrf_defaultFrameStats(mjrfFrameStats* stats); @@ -184,14 +180,13 @@ void mjrf_getFrameStats(mjrfContext* ctx, mjrfFrameHandle frame, mjrfFrameStats* // filament's `cmgen` tool to generate a KTX image from your source image. This tool will calculate // additional data (i.e. the spherical harmonics) and encode that information into the KTX file. -struct mjrfTextureConfig_ { // parameters for creating a texture (mjrfTexture) - int width; // texture width; or number of bytes for compressed data (e.g. KTX) - int height; // texture height; or 0 for compressed data (e.g. KTX) - int format; // mjrPixelFormat; (e.g. RGB8, RGBA8, KTX, etc.) - int color_space; // mjrColorSpace; (e.g. LINEAR, sRGB, etc.) - int sampler_type; // mjrSamplerType; texture sampler (e.g. 2D, cube, etc.) -}; -typedef struct mjrfTextureConfig_ mjrfTextureConfig; +typedef struct mjrfTextureConfig_ { // parameters for creating a texture (mjrfTexture) + int width; // width; or number of bytes for compressed data (e.g. KTX) + int height; // height; or 0 for compressed data (e.g. KTX) + int format; // mjrPixelFormat; (e.g. RGB8, RGBA8, KTX, etc.) + int color_space; // mjrColorSpace; (e.g. LINEAR, sRGB, etc.) + int sampler_type; // mjrSamplerType; texture sampler (e.g. 2D, cube, etc.) +} mjrfTextureConfig; // Initializes the mjrfTextureConfig to default values. void mjrf_defaultTextureConfig(mjrfTextureConfig* config); @@ -204,13 +199,12 @@ mjrfTexture* mjrf_createTexture(mjrfContext* ctx, // Destroys the texture. void mjrf_destroyTexture(mjrfTexture* texture); -struct mjrfTextureData_ { // binary data for a texture (mjrfTexture) - const void* bytes; // pointer to image data, or nullptr for empty texture - mjtSize num_bytes; // number of bytes in the image data - mjrfCallback release; // callback when data has finished uploading - void* user_data; // user data for release callback -}; -typedef struct mjrfTextureData_ mjrfTextureData; +typedef struct mjrfTextureData_ { // binary data for a texture (mjrfTexture) + const void* bytes; // pointer to image data, or nullptr for empty texture + mjtSize num_bytes; // number of bytes in the image data + mjrfCallback release; // callback when data has finished uploading + void* user_data; // user data for release callback +} mjrfTextureData; // Initializes the mjrfTextureData to default values. void mjrf_defaultTextureData(mjrfTextureData* data); @@ -252,22 +246,21 @@ int mjrf_getSamplerType(const mjrfTexture* texture); // Maximum number of vertex attributes in a mesh. enum { mjMAX_VERTEX_ATTRIBUTES = 16 }; -struct mjrfMeshData_ { // binary data for a mesh (mjrfMesh) - mjtSize num_vertices; // number of vertices; all vertex attributes share this size - int num_attributes; // number of attributes defined +typedef struct mjrfMeshData_ { // binary data for a mesh (mjrfMesh) + mjtSize num_vertices; // number of vertices; all vertex attributes share this size + int num_attributes; // number of attributes defined mjrVertexAttribute attributes[mjMAX_VERTEX_ATTRIBUTES]; // per-vertex attribute information - mjtBool interleaved; // true if vertex attributes are interleaved - mjtSize num_indices; // number of indices - const void* indices; // indices data array - int index_type; // mjrIndexType; (e.g. UINT16 or UINT32) - int primitive_type; // mjrMeshPrimitiveType; (e.g. TRIANGLES, etc.) - mjtBool compute_bounds; // if true, compute bounds from vertex positions - float bounds_min[3]; // min/max bounds; assume unset if bounds_min == bounds_max + mjtBool interleaved; // true if vertex attributes are interleaved + mjtSize num_indices; // number of indices + const void* indices; // indices data array + int index_type; // mjrIndexType; (e.g. UINT16 or UINT32) + int primitive_type; // mjrMeshPrimitiveType; (e.g. TRIANGLES, etc.) + mjtBool compute_bounds; // if true, compute bounds from vertex positions + float bounds_min[3]; // min/max bounds; assume unset if bounds_min == bounds_max float bounds_max[3]; - mjrfCallback release; // callback when data has finished uploading - void* user_data; // user data for release callback -}; -typedef struct mjrfMeshData_ mjrfMeshData; + mjrfCallback release; // callback when data has finished uploading + void* user_data; // user data for release callback +} mjrfMeshData; // Initializes the mjrfMeshData to default values. void mjrf_defaultMeshData(mjrfMeshData* data); @@ -283,9 +276,8 @@ void mjrf_destroyMesh(mjrfMesh* mesh); // A scene is a collection of entities (Lights and Renderables) that describes what is to be // rendered. -struct mjrfSceneParams_ { // parameters for creating a scene (mjrfScene) -}; -typedef struct mjrfSceneParams_ mjrfSceneParams; +typedef struct mjrfSceneParams_ { // parameters for creating a scene (mjrfScene) +} mjrfSceneParams; // Initializes the mjrfSceneParams to default values. void mjrf_defaultSceneParams(mjrfSceneParams* params); @@ -331,19 +323,18 @@ void mjrf_configureSceneFromModel(mjrfScene* scene, const mjModel* model); // lights as you want. Each light source (except image based lights) may or may not cast shadows. // Each shadow-casting light incurs a performance cost. -struct mjrfLightParams_ { // parameters for creating a light (mjrfLight) - int type; // mjrLightType; type of light (e.g. spot, point, image, etc.) - const mjrfTexture* texture; // texture; only for image lights - float color[3]; // RGB color - float intensity; // light intensity, in candela - mjtBool cast_shadows; // if true, cast shadows - float range; // effective range of light, in meters - float spot_cone_angle; // spot light cone angle, in degrees - int shadow_map_size; // size of shadow map texture, 0 to use default size - float bulb_radius; // bulb radius, used for soft shadows - float vsm_blur_width; // variance shadow map blur width -}; -typedef struct mjrfLightParams_ mjrfLightParams; +typedef struct mjrfLightParams_ { // parameters for creating a light (mjrfLight) + int type; // mjrLightType; type of light (e.g. spot, point, image, etc.) + const mjrfTexture* texture; // texture; only for image lights + float color[3]; // RGB color + float intensity; // light intensity, in candela + mjtBool cast_shadows; // if true, cast shadows + float range; // effective range of light, in meters + float spot_cone_angle; // spot light cone angle, in degrees + int shadow_map_size; // size of shadow map texture, 0 to use default size + float bulb_radius; // bulb radius, used for soft shadows + float vsm_blur_width; // variance shadow map blur width +} mjrfLightParams; // Initializes the mjrfLightParams to default values. void mjrf_defaultLightParams(mjrfLightParams* params); @@ -385,22 +376,22 @@ int mjrf_getLightType(const mjrfLight* light); // // Which lighting model is used is determined by the mjrfMaterial properties. -struct mjrfMaterial_ { // material properties for a renderable (mjrfMaterial) - float color[4]; // object color; defaults to white - int32_t segmentation_id; // ID for segmentation rendering; maps to RGB8 color (i.e. 24 bits) - int32_t island_id; // ID to which the renderable belongs - int sleep_state; // mjtSleepState; sleep state of the renderable - float uv_scale[3]; // scale applied to UV coordinates; defaults to (1,1,1) - float uv_offset[3]; // offset applied to UV coordinates; defaults to (0,0,0) - float scissor[4]; // if non-zero, applies scissor testing when rendering - float metallic; // metallic factory [0, 1]; disabled if < 0 - float roughness; // roughness factor [0, 1]; disabled if < 0 - float specular; // specular factor [0, 1]; disabled if < 0 - float glossiness; // glossiness factor [0, 1]; disabled if < 0 - float emissive; // emissive/glow factor [0, 1]; disabled if < 0 - float reflectance; // blend factor for reflective surfaces [0, 1]; applies only to planes - mjtBool decor_ux; // for ux elements, does not apply any lighting - mjtBool selected; // for "selected" ux elements, adds additional styling +typedef struct mjrfMaterial_ { // material properties for a renderable (mjrfMaterial) + float color[4]; // object color; defaults to white + int32_t segmentation_id; // ID for segmentation rendering; maps to RGB8 color (i.e. 24 bits) + int32_t island_id; // ID to which the renderable belongs + int sleep_state; // mjtSleepState; sleep state of the renderable + float uv_scale[3]; // scale applied to UV coordinates; defaults to (1,1,1) + float uv_offset[3]; // offset applied to UV coordinates; defaults to (0,0,0) + float scissor[4]; // if non-zero, applies scissor testing when rendering + float metallic; // metallic factory [0, 1]; disabled if < 0 + float roughness; // roughness factor [0, 1]; disabled if < 0 + float specular; // specular factor [0, 1]; disabled if < 0 + float glossiness; // glossiness factor [0, 1]; disabled if < 0 + float emissive; // emissive/glow factor [0, 1]; disabled if < 0 + float reflectance; // blend factor for reflective surfaces [0, 1]; only for planes + mjtBool decor_ux; // for ux elements, does not apply any lighting + mjtBool selected; // for "selected" ux elements, adds additional styling const mjrfTexture* color_texture; // color/albedo texture (RGB8) const mjrfTexture* opacity_texture; // opacity texture (A8) const mjrfTexture* normal_texture; // normal map texture (RGB8) @@ -410,18 +401,16 @@ struct mjrfMaterial_ { // material properties for a renderable (mjrfMater const mjrfTexture* orm_texture; // occlusion/roughness/metallic texture (RGB8) const mjrfTexture* emissive_texture; // emissive texture (RGB8) const mjrfTexture* reflection_texture; // reflection texture, for internal use only -}; -typedef struct mjrfMaterial_ mjrfMaterial; +} mjrfMaterial; // Initializes the mjrfMaterial to default values. void mjrf_defaultMaterial(mjrfMaterial* material); -struct mjrfRenderableParams_ { // parameters for creating a renderable (mjrfRenderable) - mjtBool cast_shadows; // if true, casts shadows - mjtBool receive_shadows; // if true, receives shadows - uint16_t blend_order; // controls draw order for transparent objects [0, 8] -}; -typedef struct mjrfRenderableParams_ mjrfRenderableParams; +typedef struct mjrfRenderableParams_ { // parameters for creating a renderable (mjrfRenderable) + mjtBool cast_shadows; // if true, casts shadows + mjtBool receive_shadows; // if true, receives shadows + uint16_t blend_order; // controls draw order for transparent objects [0, 8] +} mjrfRenderableParams; // Initializes the mjrfRenderableParams to default values. void mjrf_defaultRenderableParams(mjrfRenderableParams* params); @@ -462,13 +451,12 @@ void mjrf_setRenderableSize(mjrfRenderable* renderable, const float size[3]); // A render target is a memory buffer that holds the results of a rendering operation. (This is an // alternative to rendering directly to the screen.) See mjrf_render for more details. -struct mjrfRenderTargetConfig_ { // parameters for creating a render target (mjrfRenderTarget) - int width; // texture width - int height; // texture height - int color_format; // mjrPixelFormat; pixel format for color buffer - int depth_format; // mjrPixelFormat; pixel format for depth buffer -}; -typedef struct mjrfRenderTargetConfig_ mjrfRenderTargetConfig; +typedef struct mjrfRenderTargetConfig_ { // parameters for creating a render target + int width; // texture width + int height; // texture height + int color_format; // mjrPixelFormat; pixel format for color buffer + int depth_format; // mjrPixelFormat; pixel format for depth buffer +} mjrfRenderTargetConfig; // Initializes the RenderTargetConfig to default values. void mjrf_defaultRenderTargetConfig(mjrfRenderTargetConfig* config); diff --git a/include/mujoco/mjspec.h b/include/mujoco/mjspec.h index 6d9d6237..09f6d869 100644 --- a/include/mujoco/mjspec.h +++ b/include/mujoco/mjspec.h @@ -57,13 +57,13 @@ extern "C" { //-------------------------------- enum types (mjt) ------------------------------------------------ -typedef enum mjtGeomInertia_ { // type of inertia inference +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 +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 @@ -71,7 +71,7 @@ typedef enum mjtMeshInertia_ { // type of mesh inertia } mjtMeshInertia; -typedef enum mjtMeshBuiltin_ { // type of built-in procedural mesh +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 @@ -83,7 +83,7 @@ typedef enum mjtMeshBuiltin_ { // type of built-in procedural mesh } mjtMeshBuiltin; -typedef enum mjtBuiltin_ { // type of built-in procedural texture +typedef enum mjtBuiltin { // type of built-in procedural texture mjBUILTIN_NONE = 0, // no built-in texture mjBUILTIN_GRADIENT, // gradient: rgb1->rgb2 mjBUILTIN_CHECKER, // checker pattern: rgb1, rgb2 @@ -91,7 +91,7 @@ typedef enum mjtBuiltin_ { // type of built-in procedural texture } mjtBuiltin; -typedef enum mjtMark_ { // mark type for procedural textures +typedef enum mjtMark { // mark type for procedural textures mjMARK_NONE = 0, // no mark mjMARK_EDGE, // edges mjMARK_CROSS, // cross @@ -99,28 +99,28 @@ typedef enum mjtMark_ { // mark type for procedural textures } mjtMark; -typedef enum mjtLimited_ { // type of limit specification +typedef enum mjtLimited { // type of limit specification mjLIMITED_FALSE = 0, // not limited mjLIMITED_TRUE, // limited mjLIMITED_AUTO, // limited inferred from presence of range } mjtLimited; -typedef enum mjtAlignFree_ { // whether to align free joints with the inertial frame +typedef enum mjtAlignFree { // whether to align free joints with the inertial frame mjALIGNFREE_FALSE = 0, // don't align mjALIGNFREE_TRUE, // align mjALIGNFREE_AUTO, // respect the global compiler flag } mjtAlignFree; -typedef enum mjtInertiaFromGeom_ { // whether to infer body inertias from child geoms +typedef enum mjtInertiaFromGeom { // whether to infer body inertias from child geoms mjINERTIAFROMGEOM_FALSE = 0, // do not use; inertial element required mjINERTIAFROMGEOM_TRUE, // always use; overwrite inertial element mjINERTIAFROMGEOM_AUTO // use only if inertial element is missing } mjtInertiaFromGeom; -typedef enum mjtOrientation_ { // type of orientation specifier +typedef enum mjtOrientation { // type of orientation specifier mjORIENTATION_QUAT = 0, // quaternion mjORIENTATION_AXISANGLE, // axis and angle mjORIENTATION_XYAXES, // x and y axes @@ -128,13 +128,13 @@ typedef enum mjtOrientation_ { // type of orientation specifier mjORIENTATION_EULER, // Euler angles } mjtOrientation; -typedef enum mjtConflict_ { // conflict resolution for attach +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 @@ -176,7 +176,7 @@ typedef struct mjsCompiler_ { // compiler options 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) + int conflict; // conflict resolution for attach (mjtConflict) mjLROpt LRopt; // options for lengthrange computation mjString* meshdir; // mesh and hfield directory mjString* texturedir; // texture directory diff --git a/include/mujoco/mjtype.h b/include/mujoco/mjtype.h index c6d322aa..b46b7ae5 100644 --- a/include/mujoco/mjtype.h +++ b/include/mujoco/mjtype.h @@ -50,7 +50,7 @@ typedef int64_t mjtSize; // used for buffer sizes //---------------------------------- enum types (mjModel) ------------------------------------------ -typedef enum mjtDisableBit_ { // disable default feature bitflags +typedef enum mjtDisableBit { // disable default feature bitflags mjDSBL_CONSTRAINT = 1<<0, // entire constraint solver mjDSBL_EQUALITY = 1<<1, // equality constraints mjDSBL_FRICTIONLOSS = 1<<2, // joint and tendon frictionloss constraints @@ -76,7 +76,7 @@ typedef enum mjtDisableBit_ { // disable default feature bitflags } mjtDisableBit; -typedef enum mjtEnableBit_ { // enable optional feature bitflags +typedef enum mjtEnableBit { // enable optional feature bitflags mjENBL_OVERRIDE = 1<<0, // override contact parameters mjENBL_ENERGY = 1<<1, // energy computation mjENBL_FWDINV = 1<<2, // record solver statistics @@ -88,7 +88,7 @@ typedef enum mjtEnableBit_ { // enable optional feature bitflags } mjtEnableBit; -typedef enum mjtJoint_ { // type of degree of freedom +typedef enum mjtJoint { // type of degree of freedom mjJNT_FREE = 0, // global position and orientation (quat) (7) mjJNT_BALL, // orientation (quat) relative to parent (4) mjJNT_SLIDE, // sliding distance along body-fixed axis (1) @@ -96,7 +96,7 @@ typedef enum mjtJoint_ { // type of degree of freedom } mjtJoint; -typedef enum mjtGeom_ { // type of geometric shape +typedef enum mjtGeom { // type of geometric shape // regular geom types mjGEOM_PLANE = 0, // plane mjGEOM_HFIELD, // height field @@ -125,13 +125,13 @@ typedef enum mjtGeom_ { // type of geometric shape } mjtGeom; -typedef enum mjtProjection_ { // type of camera projection +typedef enum mjtProjection { // type of camera projection mjPROJ_PERSPECTIVE = 0, // perspective mjPROJ_ORTHOGRAPHIC // orthographic } mjtProjection; -typedef enum mjtCamLight_ { // tracking mode for camera and light +typedef enum mjtCamLight { // tracking mode for camera and light mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global mjCAMLIGHT_TRACKCOM, // pos tracks subtree com, rot fixed in body @@ -140,7 +140,7 @@ typedef enum mjtCamLight_ { // tracking mode for camera and light } mjtCamLight; -typedef enum mjtLightType_ { // type of light +typedef enum mjtLightType { // type of light mjLIGHT_SPOT = 0, // spot mjLIGHT_DIRECTIONAL, // directional mjLIGHT_POINT, // point @@ -148,14 +148,14 @@ typedef enum mjtLightType_ { // type of light } mjtLightType; -typedef enum mjtTexture_ { // type of texture +typedef enum mjtTexture { // type of texture mjTEXTURE_2D = 0, // 2d texture, suitable for planes and hfields mjTEXTURE_CUBE, // cube texture, suitable for all other geom types mjTEXTURE_SKYBOX // cube texture used as skybox } mjtTexture; -typedef enum mjtTextureRole_ { // role of texture map in rendering +typedef enum mjtTextureRole { // role of texture map in rendering mjTEXROLE_USER = 0, // unspecified mjTEXROLE_RGB, // base color (albedo) mjTEXROLE_OCCLUSION, // ambient occlusion @@ -170,14 +170,14 @@ typedef enum mjtTextureRole_ { // role of texture map in rendering } mjtTextureRole; -typedef enum mjtColorSpace_ { // type of color space encoding +typedef enum mjtColorSpace { // type of color space encoding mjCOLORSPACE_AUTO = 0, // attempts to autodetect color space, defaults to linear mjCOLORSPACE_LINEAR, // linear color space mjCOLORSPACE_SRGB // standard RGB color space } mjtColorSpace; -typedef enum mjtIntegrator_ { // integrator mode +typedef enum mjtIntegrator { // integrator mode mjINT_EULER = 0, // semi-implicit Euler mjINT_RK4, // 4th-order Runge Kutta mjINT_IMPLICIT, // implicit in velocity @@ -185,27 +185,27 @@ typedef enum mjtIntegrator_ { // integrator mode } mjtIntegrator; -typedef enum mjtCone_ { // type of friction cone +typedef enum mjtCone { // type of friction cone mjCONE_PYRAMIDAL = 0, // pyramidal mjCONE_ELLIPTIC // elliptic } mjtCone; -typedef enum mjtJacobian_ { // type of constraint Jacobian +typedef enum mjtJacobian { // type of constraint Jacobian mjJAC_DENSE = 0, // dense mjJAC_SPARSE, // sparse mjJAC_AUTO // dense if nv<60, sparse otherwise } mjtJacobian; -typedef enum mjtSolver_ { // constraint solver algorithm +typedef enum mjtSolver { // constraint solver algorithm mjSOL_PGS = 0, // PGS (dual) mjSOL_CG, // CG (primal) mjSOL_NEWTON // Newton (primal) } mjtSolver; -typedef enum mjtEq_ { // type of equality constraint +typedef enum mjtEq { // type of equality constraint mjEQ_CONNECT = 0, // connect two bodies at a point (ball joint) mjEQ_WELD, // fix relative position and orientation of two bodies mjEQ_JOINT, // couple the values of two scalar joints with cubic @@ -217,7 +217,7 @@ typedef enum mjtEq_ { // type of equality constraint } mjtEq; -typedef enum mjtWrap_ { // type of tendon wrap object +typedef enum mjtWrap { // type of tendon wrap object mjWRAP_NONE = 0, // null object mjWRAP_JOINT, // constant moment arm mjWRAP_PULLEY, // pulley used to split tendon @@ -227,7 +227,7 @@ typedef enum mjtWrap_ { // type of tendon wrap object } mjtWrap; -typedef enum mjtTrn_ { // type of actuator transmission +typedef enum mjtTrn { // type of actuator transmission mjTRN_JOINT = 0, // force on joint mjTRN_JOINTINPARENT, // force on joint, expressed in parent frame mjTRN_SLIDERCRANK, // force via slider-crank linkage @@ -239,7 +239,7 @@ typedef enum mjtTrn_ { // type of actuator transmission } mjtTrn; -typedef enum mjtDyn_ { // type of actuator dynamics +typedef enum mjtDyn { // type of actuator dynamics mjDYN_NONE = 0, // no internal dynamics; ctrl specifies force mjDYN_INTEGRATOR, // integrator: da/dt = u mjDYN_FILTER, // linear filter: da/dt = (u-a) / tau @@ -250,7 +250,7 @@ typedef enum mjtDyn_ { // type of actuator dynamics } mjtDyn; -typedef enum mjtGain_ { // type of actuator gain +typedef enum mjtGain { // type of actuator gain mjGAIN_FIXED = 0, // fixed gain mjGAIN_AFFINE, // const + kp*length + kv*velocity mjGAIN_MUSCLE, // muscle FLV curve computed by mju_muscleGain() @@ -259,7 +259,7 @@ typedef enum mjtGain_ { // type of actuator gain } mjtGain; -typedef enum mjtBias_ { // type of actuator bias +typedef enum mjtBias { // type of actuator bias mjBIAS_NONE = 0, // no bias mjBIAS_AFFINE, // const + kp*length + kv*velocity mjBIAS_MUSCLE, // muscle passive force computed by mju_muscleBias() @@ -268,7 +268,7 @@ typedef enum mjtBias_ { // type of actuator bias } mjtBias; -typedef enum mjtObj_ { // type of MujoCo object +typedef enum mjtObj { // type of MujoCo object mjOBJ_UNKNOWN = 0, // unknown object type mjOBJ_BODY, // body mjOBJ_XBODY, // body, used to access regular frame instead of i-frame @@ -305,7 +305,7 @@ typedef enum mjtObj_ { // type of MujoCo object } mjtObj; -typedef enum mjtSensor_ { // type of sensor +typedef enum mjtSensor { // type of sensor // common robotic sensors, attached to a site mjSENS_TOUCH = 0, // scalar contact normal forces summed over sensor zone mjSENS_ACCELEROMETER, // 3D linear acceleration, in local frame @@ -381,7 +381,7 @@ typedef enum mjtSensor_ { // type of sensor } mjtSensor; -typedef enum mjtStage_ { // computation stage +typedef enum mjtStage { // computation stage mjSTAGE_NONE = 0, // no computations mjSTAGE_POS, // position-dependent computations mjSTAGE_VEL, // velocity-dependent computations @@ -389,7 +389,7 @@ typedef enum mjtStage_ { // computation stage } mjtStage; -typedef enum mjtDataType_ { // data type for sensors +typedef enum mjtDataType { // data type for sensors mjDATATYPE_REAL = 0, // real values, no constraints mjDATATYPE_POSITIVE, // positive values; 0 or negative: inactive mjDATATYPE_AXIS, // 3D unit vector @@ -397,7 +397,7 @@ typedef enum mjtDataType_ { // data type for sensors } mjtDataType; -typedef enum mjtConDataField_ { // data fields returned by contact sensors +typedef enum mjtConDataField { // data fields returned by contact sensors mjCONDATA_FOUND = 0, // whether a contact was found mjCONDATA_FORCE, // contact force mjCONDATA_TORQUE, // contact torque @@ -410,7 +410,7 @@ typedef enum mjtConDataField_ { // data fields returned by contact sensors } mjtConDataField; -typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors +typedef enum mjtRayDataField { // data fields returned by rangefinder sensors mjRAYDATA_DIST = 0, // distance from ray origin to nearest surface mjRAYDATA_DIR, // normalized ray direction mjRAYDATA_ORIGIN, // ray origin @@ -422,7 +422,7 @@ typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors } mjtRayDataField; -typedef enum mjtCamOutBit_ { // camera output type bitflags +typedef enum mjtCamOutBit { // camera output type bitflags mjCAMOUT_RGB = 1<<0, // RGB image mjCAMOUT_DEPTH = 1<<1, // depth image (distance from camera plane) mjCAMOUT_DIST = 1<<2, // distance image (distance from camera origin) @@ -433,7 +433,7 @@ typedef enum mjtCamOutBit_ { // camera output type bitflags } mjtCamOutBit; -typedef enum mjtSameFrame_ { // frame alignment of bodies with their children +typedef enum mjtSameFrame { // frame alignment of bodies with their children mjSAMEFRAME_NONE = 0, // no alignment mjSAMEFRAME_BODY, // frame is same as body frame mjSAMEFRAME_INERTIA, // frame is same as inertial frame @@ -442,7 +442,7 @@ typedef enum mjtSameFrame_ { // frame alignment of bodies with their childr } mjtSameFrame; -typedef enum mjtSleepPolicy_ { // per-tree sleep policy +typedef enum mjtSleepPolicy { // per-tree sleep policy mjSLEEP_AUTO = 0, // compiler chooses sleep policy mjSLEEP_AUTO_NEVER, // compiler sleep policy: never mjSLEEP_AUTO_ALLOWED, // compiler sleep policy: allowed @@ -452,7 +452,7 @@ typedef enum mjtSleepPolicy_ { // per-tree sleep policy } mjtSleepPolicy; -typedef enum mjtLRMode_ { // mode for actuator length range computation +typedef enum mjtLRMode { // mode for actuator length range computation mjLRMODE_NONE = 0, // do not process any actuators mjLRMODE_MUSCLE, // process muscle actuators mjLRMODE_MUSCLEUSER, // process muscle and user actuators @@ -460,7 +460,7 @@ typedef enum mjtLRMode_ { // mode for actuator length range computation } mjtLRMode; -typedef enum mjtFlexSelf_ { // mode for flex selfcollide +typedef enum mjtFlexSelf { // mode for flex selfcollide mjFLEXSELF_NONE = 0, // no self-collisions mjFLEXSELF_NARROW, // skip midphase, go directly to narrowphase mjFLEXSELF_BVH, // use BVH in midphase (if midphase enabled) @@ -469,7 +469,7 @@ typedef enum mjtFlexSelf_ { // mode for flex selfcollide } mjtFlexSelf; -typedef enum mjtSDFType_ { // signed distance function (SDF) type +typedef enum mjtSDFType { // signed distance function (SDF) type mjSDFTYPE_SINGLE = 0, // single SDF mjSDFTYPE_INTERSECTION, // max(A, B) mjSDFTYPE_MIDSURFACE, // A - B @@ -480,7 +480,7 @@ typedef enum mjtSDFType_ { // signed distance function (SDF) type //---------------------------------- enum types (mjData) ------------------------------------------- -typedef enum mjtState_ { // state elements +typedef enum mjtState { // state elements mjSTATE_TIME = 1<<0, // time mjSTATE_QPOS = 1<<1, // position mjSTATE_QVEL = 1<<2, // velocity @@ -508,7 +508,7 @@ typedef enum mjtState_ { // state elements } mjtState; -typedef enum mjtConstraint_ { // type of constraint +typedef enum mjtConstraint { // type of constraint mjCNSTR_EQUALITY = 0, // equality constraint mjCNSTR_FRICTION_DOF, // dof friction mjCNSTR_FRICTION_TENDON, // tendon friction @@ -520,7 +520,7 @@ typedef enum mjtConstraint_ { // type of constraint } mjtConstraint; -typedef enum mjtConstraintState_ { // constraint state +typedef enum mjtConstraintState { // constraint state mjCNSTRSTATE_SATISFIED = 0, // constraint satisfied, zero cost (limit, contact) mjCNSTRSTATE_QUADRATIC, // quadratic cost (equality, friction, limit, contact) mjCNSTRSTATE_LINEARNEG, // linear cost, negative side (friction) @@ -529,7 +529,7 @@ typedef enum mjtConstraintState_ { // constraint state } mjtConstraintState; -typedef enum mjtWarning_ { // warning types +typedef enum mjtWarning { // warning types mjWARN_INERTIA = 0, // (near) singular inertia matrix mjWARN_CONTACTFULL, // too many contacts in contact list mjWARN_CNSTRFULL, // too many constraints @@ -542,7 +542,7 @@ typedef enum mjtWarning_ { // warning types } mjtWarning; -typedef enum mjtTimer_ { // internal timers +typedef enum mjtTimer { // internal timers // main api mjTIMER_STEP = 0, // step mjTIMER_FORWARD, // forward @@ -570,7 +570,7 @@ typedef enum mjtTimer_ { // internal timers } mjtTimer; -typedef enum mjtSleepState_ { // sleep state of an object +typedef enum mjtSleepState { // sleep state of an object mjS_STATIC = -1, // object is static mjS_ASLEEP = 0, // object is asleep mjS_AWAKE = 1 // object is awake @@ -580,14 +580,14 @@ typedef enum mjtSleepState_ { // sleep state of an object //---------------------------------- logging ------------------------------------------------------- -typedef enum mjtLogLevel_ { // log message severity +typedef enum mjtLogLevel { // log message severity mjLOG_DEBUG = 0, // internal engine debug trace (opt-in via topic filtering) mjLOG_INFO, // informational (opt-in via topic filtering) mjLOG_WARNING, // warning mjLOG_ERROR, // error } mjtLogLevel; -typedef enum mjtLogTopic_ { // log topic identifiers +typedef enum mjtLogTopic { // log topic identifiers mjTOPIC_NONE = 0, // no topic (always passes filtering) // INFO topics: mjTOPIC_TIME_STP = 1, // timing diagnostics (step) diff --git a/include/mujoco/mjui.h b/include/mujoco/mjui.h index 990bf11e..d6b7e398 100644 --- a/include/mujoco/mjui.h +++ b/include/mujoco/mjui.h @@ -62,7 +62,7 @@ //---------------------------------- primitive types (mjt) ----------------------------------------- -typedef enum mjtButton_ { // mouse button +typedef enum mjtButton { // mouse button mjBUTTON_NONE = 0, // no button mjBUTTON_LEFT, // left button mjBUTTON_RIGHT, // right button @@ -70,7 +70,7 @@ typedef enum mjtButton_ { // mouse button } mjtButton; -typedef enum mjtEvent_ { // mouse and keyboard event type +typedef enum mjtEvent { // mouse and keyboard event type mjEVENT_NONE = 0, // no event mjEVENT_MOVE, // mouse move mjEVENT_PRESS, // mouse button press @@ -83,7 +83,7 @@ typedef enum mjtEvent_ { // mouse and keyboard event type } mjtEvent; -typedef enum mjtItem_ { // UI item type +typedef enum mjtItem { // UI item type mjITEM_END = -2, // end of definition list (not an item) mjITEM_SECTION = -1, // section (not an item) mjITEM_SEPARATOR = 0, // separator @@ -107,7 +107,7 @@ typedef enum mjtItem_ { // UI item type } mjtItem; -typedef enum mjtSection_ { // UI section state +typedef enum mjtSection { // UI section state mjSECT_CLOSED = 0, // closed state (regular section) mjSECT_OPEN, // open state (regular section) mjSECT_FIXED // fixed section: always open, no title @@ -120,7 +120,7 @@ typedef int (*mjfItemEnable)(int category, void* data); //---------------------------------- mjuiState ----------------------------------------------------- -struct mjuiState_ { // mouse and keyboard state +typedef struct mjuiState_ { // mouse and keyboard state // constants set by user int nrect; // number of rectangles used mjrRect rect[mjMAXUIRECT]; // rectangles (index 0: entire window) @@ -160,33 +160,31 @@ struct mjuiState_ { // mouse and keyboard state // files dropping (only valid when type == mjEVENT_FILESDROP) int dropcount; // number of files dropped const char** droppaths; // paths to files dropped -}; -typedef struct mjuiState_ mjuiState; +} mjuiState; //---------------------------------- mjuiThemeSpacing ---------------------------------------------- -struct mjuiThemeSpacing_ { // UI visualization theme spacing - int total; // total width - int scroll; // scrollbar width - int label; // label width - int section; // section gap - int cornersect; // corner radius for section - int cornersep; // corner radius for separator - int itemside; // item side gap - int itemmid; // item middle gap - int itemver; // item vertical gap - int texthor; // text horizontal gap - int textver; // text vertical gap - int linescroll; // number of pixels to scroll - int samples; // number of multisamples -}; -typedef struct mjuiThemeSpacing_ mjuiThemeSpacing; +typedef struct mjuiThemeSpacing_ { // UI visualization theme spacing + int total; // total width + int scroll; // scrollbar width + int label; // label width + int section; // section gap + int cornersect; // corner radius for section + int cornersep; // corner radius for separator + int itemside; // item side gap + int itemmid; // item middle gap + int itemver; // item vertical gap + int texthor; // text horizontal gap + int textver; // text vertical gap + int linescroll; // number of pixels to scroll + int samples; // number of multisamples +} mjuiThemeSpacing; //---------------------------------- mjuiThemeColor ------------------------------------------------ -struct mjuiThemeColor_ { // UI visualization theme color +typedef struct mjuiThemeColor_ { // UI visualization theme color float master[3]; // master background float thumb[3]; // scrollbar thumb float secttitle[3]; // section title @@ -215,8 +213,7 @@ struct mjuiThemeColor_ { // UI visualization theme color float edit[3]; // edit float edit2[3]; // edit invalid float cursor[3]; // edit cursor -}; -typedef struct mjuiThemeColor_ mjuiThemeColor; +} mjuiThemeColor; //---------------------------------- mjuiItem ------------------------------------------------------ @@ -245,7 +242,7 @@ struct mjuiItemEdit_ { // edit-related }; -struct mjuiItem_ { // UI item +typedef struct mjuiItem_ { // UI item // common properties int type; // type (mjtItem) char name[mjMAXUINAME]; // name @@ -266,13 +263,12 @@ struct mjuiItem_ { // UI item // internal mjrRect rect; // rectangle occupied by item int skip; // item skipped due to closed separator -}; -typedef struct mjuiItem_ mjuiItem; +} mjuiItem; //---------------------------------- mjuiSection --------------------------------------------------- -struct mjuiSection_ { // UI section +typedef struct mjuiSection_ { // UI section // properties char name[mjMAXUINAME]; // name int state; // section state (mjtSection) @@ -286,13 +282,12 @@ struct mjuiSection_ { // UI section mjrRect rtitle; // rectangle occupied by title mjrRect rcontent; // rectangle occupied by content int lastclick; // last mouse click over this section -}; -typedef struct mjuiSection_ mjuiSection; +} mjuiSection; //---------------------------------- mjUI ---------------------------------------------------------- -struct mjUI_ { // entire UI +typedef struct mjUI_ { // entire UI // constants set by user mjuiThemeSpacing spacing; // UI theme spacing mjuiThemeColor color; // UI theme color @@ -326,20 +321,18 @@ struct mjUI_ { // entire UI // sections int nsect; // number of sections in use mjuiSection sect[mjMAXUISECT]; // preallocated array of sections -}; -typedef struct mjUI_ mjUI; +} mjUI; //---------------------------------- mjuiDef ------------------------------------------------------- -struct mjuiDef_ { // table passed to mjui_add() +typedef struct mjuiDef_ { // table passed to mjui_add() int type; // type (mjtItem); -1: section char name[mjMAXUINAME]; // name int state; // state void* pdata; // pointer to data char other[mjMAXUITEXT]; // string with type-specific properties int otherint; // int with type-specific properties -}; -typedef struct mjuiDef_ mjuiDef; +} mjuiDef; #endif // MUJOCO_MJUI_H_ diff --git a/include/mujoco/mjvisualize.h b/include/mujoco/mjvisualize.h index 2379f82b..b68234c0 100644 --- a/include/mujoco/mjvisualize.h +++ b/include/mujoco/mjvisualize.h @@ -164,7 +164,7 @@ typedef enum mjtStereo_ { // type of stereo rendering //---------------------------------- mjvPerturb ---------------------------------------------------- -struct mjvPerturb_ { // object selection and perturbation +typedef struct mjvPerturb_ { // object selection and perturbation int select; // selected body id; non-positive: none int flexselect; // selected flex id; negative: none int skinselect; // selected skin id; negative: none @@ -176,13 +176,12 @@ struct mjvPerturb_ { // object selection and perturbation mjtNum localpos[3]; // selection point in object coordinates mjtNum localmass; // spatial inertia at selection point mjtNum scale; // relative mouse motion-to-space scaling (set by initPerturb) -}; -typedef struct mjvPerturb_ mjvPerturb; +} mjvPerturb; //---------------------------------- mjvCamera ----------------------------------------------------- -struct mjvCamera_ { // abstract camera +typedef struct mjvCamera_ { // abstract camera // type and ids int type; // camera type (mjtCamera) int fixedcamid; // fixed camera id @@ -196,13 +195,12 @@ struct mjvCamera_ { // abstract camera // orthographic / perspective int orthographic; // 0: perspective; 1: orthographic -}; -typedef struct mjvCamera_ mjvCamera; +} mjvCamera; //---------------------------------- mjvGLCamera --------------------------------------------------- -struct mjvGLCamera_ { // OpenGL camera +typedef struct mjvGLCamera_ { // OpenGL camera // camera frame float pos[3]; // position float forward[3]; // forward direction @@ -218,13 +216,12 @@ struct mjvGLCamera_ { // OpenGL camera // orthographic / perspective int orthographic; // 0: perspective; 1: orthographic -}; -typedef struct mjvGLCamera_ mjvGLCamera; +} mjvGLCamera; //---------------------------------- mjvGeom ------------------------------------------------------- -struct mjvGeom_ { // abstract geom +typedef struct mjvGeom_ { // abstract geom // type info int type; // geom type (mjtGeom) int dataid; // mesh, hfield or plane id; -1: none; mesh: 2*id or 2*id+1 (hull) @@ -253,13 +250,12 @@ struct mjvGeom_ { // abstract geom float camdist; // distance to camera (used by sorter) float modelrbound; // geom rbound from model, 0 if not model geom mjtByte transparent; // treat geom as transparent -}; -typedef struct mjvGeom_ mjvGeom; +} mjvGeom; //---------------------------------- mjvLight ------------------------------------------------------ -struct mjvLight_ { // OpenGL light +typedef struct mjvLight_ { // OpenGL light int id; // light id, -1 for headlight float pos[3]; // position rel. to body frame float dir[3]; // direction rel. to body frame @@ -276,13 +272,12 @@ struct mjvLight_ { // OpenGL light float bulbradius; // bulb radius for soft shadows float intensity; // intensity, in candelas float range; // range of effectiveness -}; -typedef struct mjvLight_ mjvLight; +} mjvLight; //---------------------------------- mjvOption ----------------------------------------------------- -struct mjvOption_ { // abstract visualization options +typedef struct mjvOption_ { // abstract visualization options int label; // what objects to label (mjtLabel) int frame; // which frame to show (mjtFrame) mjtByte geomgroup[mjNGROUP]; // geom visualization by group @@ -295,13 +290,12 @@ struct mjvOption_ { // abstract visualization options mjtByte flags[mjNVISFLAG]; // visualization flags (indexed by mjtVisFlag) int bvh_depth; // depth of the bounding volume hierarchy to be visualized int flex_layer; // element layer to be visualized for 3D flex -}; -typedef struct mjvOption_ mjvOption; +} mjvOption; //---------------------------------- mjvScene ------------------------------------------------------ -struct mjvScene_ { // abstract scene passed to OpenGL renderer +typedef struct mjvScene_ { // abstract scene passed to OpenGL renderer // abstract geoms int maxgeom; // size of allocated geom buffer int ngeom; // number of geoms currently in buffer @@ -358,13 +352,12 @@ struct mjvScene_ { // abstract scene passed to OpenGL renderer // geom buffer status int status; // 0: ok, 1: geoms exhausted, warning issued -}; -typedef struct mjvScene_ mjvScene; +} mjvScene; //---------------------------------- mjvFigure ----------------------------------------------------- -struct mjvFigure_ { // abstract 2D figure passed to OpenGL renderer +typedef struct mjvFigure_ { // abstract 2D figure passed to OpenGL renderer // enable flags int flg_legend; // show legend int flg_ticklabel[2]; // show grid tick labels (x,y) @@ -409,7 +402,6 @@ struct mjvFigure_ { // abstract 2D figure passed to OpenGL rendere int yaxispixel[2]; // range of y-axis in pixels float xaxisdata[2]; // range of x-axis in data units float yaxisdata[2]; // range of y-axis in data units -}; -typedef struct mjvFigure_ mjvFigure; +} mjvFigure; #endif // MUJOCO_MJVISUALIZE_H_ diff --git a/python/mujoco/introspect/enums.py b/python/mujoco/introspect/enums.py index 05d8f525..ee8c706b 100644 --- a/python/mujoco/introspect/enums.py +++ b/python/mujoco/introspect/enums.py @@ -25,7 +25,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtDisableBit', EnumDecl( name='mjtDisableBit', - declname='enum mjtDisableBit_', + declname='enum mjtDisableBit', values=dict([ ('mjDSBL_CONSTRAINT', 1), ('mjDSBL_EQUALITY', 2), @@ -53,7 +53,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtEnableBit', EnumDecl( name='mjtEnableBit', - declname='enum mjtEnableBit_', + declname='enum mjtEnableBit', values=dict([ ('mjENBL_OVERRIDE', 1), ('mjENBL_ENERGY', 2), @@ -67,7 +67,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtJoint', EnumDecl( name='mjtJoint', - declname='enum mjtJoint_', + declname='enum mjtJoint', values=dict([ ('mjJNT_FREE', 0), ('mjJNT_BALL', 1), @@ -78,7 +78,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtGeom', EnumDecl( name='mjtGeom', - declname='enum mjtGeom_', + declname='enum mjtGeom', values=dict([ ('mjGEOM_PLANE', 0), ('mjGEOM_HFIELD', 1), @@ -105,7 +105,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtProjection', EnumDecl( name='mjtProjection', - declname='enum mjtProjection_', + declname='enum mjtProjection', values=dict([ ('mjPROJ_PERSPECTIVE', 0), ('mjPROJ_ORTHOGRAPHIC', 1), @@ -114,7 +114,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtCamLight', EnumDecl( name='mjtCamLight', - declname='enum mjtCamLight_', + declname='enum mjtCamLight', values=dict([ ('mjCAMLIGHT_FIXED', 0), ('mjCAMLIGHT_TRACK', 1), @@ -126,7 +126,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtLightType', EnumDecl( name='mjtLightType', - declname='enum mjtLightType_', + declname='enum mjtLightType', values=dict([ ('mjLIGHT_SPOT', 0), ('mjLIGHT_DIRECTIONAL', 1), @@ -137,7 +137,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtTexture', EnumDecl( name='mjtTexture', - declname='enum mjtTexture_', + declname='enum mjtTexture', values=dict([ ('mjTEXTURE_2D', 0), ('mjTEXTURE_CUBE', 1), @@ -147,7 +147,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtTextureRole', EnumDecl( name='mjtTextureRole', - declname='enum mjtTextureRole_', + declname='enum mjtTextureRole', values=dict([ ('mjTEXROLE_USER', 0), ('mjTEXROLE_RGB', 1), @@ -165,7 +165,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtColorSpace', EnumDecl( name='mjtColorSpace', - declname='enum mjtColorSpace_', + declname='enum mjtColorSpace', values=dict([ ('mjCOLORSPACE_AUTO', 0), ('mjCOLORSPACE_LINEAR', 1), @@ -175,7 +175,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtIntegrator', EnumDecl( name='mjtIntegrator', - declname='enum mjtIntegrator_', + declname='enum mjtIntegrator', values=dict([ ('mjINT_EULER', 0), ('mjINT_RK4', 1), @@ -186,7 +186,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtCone', EnumDecl( name='mjtCone', - declname='enum mjtCone_', + declname='enum mjtCone', values=dict([ ('mjCONE_PYRAMIDAL', 0), ('mjCONE_ELLIPTIC', 1), @@ -195,7 +195,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtJacobian', EnumDecl( name='mjtJacobian', - declname='enum mjtJacobian_', + declname='enum mjtJacobian', values=dict([ ('mjJAC_DENSE', 0), ('mjJAC_SPARSE', 1), @@ -205,7 +205,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtSolver', EnumDecl( name='mjtSolver', - declname='enum mjtSolver_', + declname='enum mjtSolver', values=dict([ ('mjSOL_PGS', 0), ('mjSOL_CG', 1), @@ -215,7 +215,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtEq', EnumDecl( name='mjtEq', - declname='enum mjtEq_', + declname='enum mjtEq', values=dict([ ('mjEQ_CONNECT', 0), ('mjEQ_WELD', 1), @@ -230,7 +230,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtWrap', EnumDecl( name='mjtWrap', - declname='enum mjtWrap_', + declname='enum mjtWrap', values=dict([ ('mjWRAP_NONE', 0), ('mjWRAP_JOINT', 1), @@ -243,7 +243,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtTrn', EnumDecl( name='mjtTrn', - declname='enum mjtTrn_', + declname='enum mjtTrn', values=dict([ ('mjTRN_JOINT', 0), ('mjTRN_JOINTINPARENT', 1), @@ -257,7 +257,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtDyn', EnumDecl( name='mjtDyn', - declname='enum mjtDyn_', + declname='enum mjtDyn', values=dict([ ('mjDYN_NONE', 0), ('mjDYN_INTEGRATOR', 1), @@ -271,7 +271,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtGain', EnumDecl( name='mjtGain', - declname='enum mjtGain_', + declname='enum mjtGain', values=dict([ ('mjGAIN_FIXED', 0), ('mjGAIN_AFFINE', 1), @@ -283,7 +283,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtBias', EnumDecl( name='mjtBias', - declname='enum mjtBias_', + declname='enum mjtBias', values=dict([ ('mjBIAS_NONE', 0), ('mjBIAS_AFFINE', 1), @@ -295,7 +295,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtObj', EnumDecl( name='mjtObj', - declname='enum mjtObj_', + declname='enum mjtObj', values=dict([ ('mjOBJ_UNKNOWN', 0), ('mjOBJ_BODY', 1), @@ -332,7 +332,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtSensor', EnumDecl( name='mjtSensor', - declname='enum mjtSensor_', + declname='enum mjtSensor', values=dict([ ('mjSENS_TOUCH', 0), ('mjSENS_ACCELEROMETER', 1), @@ -388,7 +388,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtStage', EnumDecl( name='mjtStage', - declname='enum mjtStage_', + declname='enum mjtStage', values=dict([ ('mjSTAGE_NONE', 0), ('mjSTAGE_POS', 1), @@ -399,7 +399,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtDataType', EnumDecl( name='mjtDataType', - declname='enum mjtDataType_', + declname='enum mjtDataType', values=dict([ ('mjDATATYPE_REAL', 0), ('mjDATATYPE_POSITIVE', 1), @@ -410,7 +410,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtConDataField', EnumDecl( name='mjtConDataField', - declname='enum mjtConDataField_', + declname='enum mjtConDataField', values=dict([ ('mjCONDATA_FOUND', 0), ('mjCONDATA_FORCE', 1), @@ -425,7 +425,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtRayDataField', EnumDecl( name='mjtRayDataField', - declname='enum mjtRayDataField_', + declname='enum mjtRayDataField', values=dict([ ('mjRAYDATA_DIST', 0), ('mjRAYDATA_DIR', 1), @@ -439,7 +439,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtCamOutBit', EnumDecl( name='mjtCamOutBit', - declname='enum mjtCamOutBit_', + declname='enum mjtCamOutBit', values=dict([ ('mjCAMOUT_RGB', 1), ('mjCAMOUT_DEPTH', 2), @@ -452,7 +452,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtSameFrame', EnumDecl( name='mjtSameFrame', - declname='enum mjtSameFrame_', + declname='enum mjtSameFrame', values=dict([ ('mjSAMEFRAME_NONE', 0), ('mjSAMEFRAME_BODY', 1), @@ -464,7 +464,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtSleepPolicy', EnumDecl( name='mjtSleepPolicy', - declname='enum mjtSleepPolicy_', + declname='enum mjtSleepPolicy', values=dict([ ('mjSLEEP_AUTO', 0), ('mjSLEEP_AUTO_NEVER', 1), @@ -477,7 +477,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtLRMode', EnumDecl( name='mjtLRMode', - declname='enum mjtLRMode_', + declname='enum mjtLRMode', values=dict([ ('mjLRMODE_NONE', 0), ('mjLRMODE_MUSCLE', 1), @@ -488,7 +488,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtFlexSelf', EnumDecl( name='mjtFlexSelf', - declname='enum mjtFlexSelf_', + declname='enum mjtFlexSelf', values=dict([ ('mjFLEXSELF_NONE', 0), ('mjFLEXSELF_NARROW', 1), @@ -500,7 +500,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtSDFType', EnumDecl( name='mjtSDFType', - declname='enum mjtSDFType_', + declname='enum mjtSDFType', values=dict([ ('mjSDFTYPE_SINGLE', 0), ('mjSDFTYPE_INTERSECTION', 1), @@ -511,7 +511,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtState', EnumDecl( name='mjtState', - declname='enum mjtState_', + declname='enum mjtState', values=dict([ ('mjSTATE_TIME', 1), ('mjSTATE_QPOS', 2), @@ -537,7 +537,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtConstraint', EnumDecl( name='mjtConstraint', - declname='enum mjtConstraint_', + declname='enum mjtConstraint', values=dict([ ('mjCNSTR_EQUALITY', 0), ('mjCNSTR_FRICTION_DOF', 1), @@ -552,7 +552,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtConstraintState', EnumDecl( name='mjtConstraintState', - declname='enum mjtConstraintState_', + declname='enum mjtConstraintState', values=dict([ ('mjCNSTRSTATE_SATISFIED', 0), ('mjCNSTRSTATE_QUADRATIC', 1), @@ -564,7 +564,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtWarning', EnumDecl( name='mjtWarning', - declname='enum mjtWarning_', + declname='enum mjtWarning', values=dict([ ('mjWARN_INERTIA', 0), ('mjWARN_CONTACTFULL', 1), @@ -579,7 +579,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtTimer', EnumDecl( name='mjtTimer', - declname='enum mjtTimer_', + declname='enum mjtTimer', values=dict([ ('mjTIMER_STEP', 0), ('mjTIMER_FORWARD', 1), @@ -602,7 +602,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtSleepState', EnumDecl( name='mjtSleepState', - declname='enum mjtSleepState_', + declname='enum mjtSleepState', values=dict([ ('mjS_STATIC', -1), ('mjS_ASLEEP', 0), @@ -612,7 +612,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtLogLevel', EnumDecl( name='mjtLogLevel', - declname='enum mjtLogLevel_', + declname='enum mjtLogLevel', values=dict([ ('mjLOG_DEBUG', 0), ('mjLOG_INFO', 1), @@ -623,7 +623,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtLogTopic', EnumDecl( name='mjtLogTopic', - declname='enum mjtLogTopic_', + declname='enum mjtLogTopic', values=dict([ ('mjTOPIC_NONE', 0), ('mjTOPIC_TIME_STP', 1), @@ -635,7 +635,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtGeomInertia', EnumDecl( name='mjtGeomInertia', - declname='enum mjtGeomInertia_', + declname='enum mjtGeomInertia', values=dict([ ('mjINERTIA_VOLUME', 0), ('mjINERTIA_SHELL', 1), @@ -644,7 +644,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtMeshInertia', EnumDecl( name='mjtMeshInertia', - declname='enum mjtMeshInertia_', + declname='enum mjtMeshInertia', values=dict([ ('mjMESH_INERTIA_CONVEX', 0), ('mjMESH_INERTIA_EXACT', 1), @@ -655,7 +655,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtMeshBuiltin', EnumDecl( name='mjtMeshBuiltin', - declname='enum mjtMeshBuiltin_', + declname='enum mjtMeshBuiltin', values=dict([ ('mjMESH_BUILTIN_NONE', 0), ('mjMESH_BUILTIN_SPHERE', 1), @@ -670,7 +670,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtBuiltin', EnumDecl( name='mjtBuiltin', - declname='enum mjtBuiltin_', + declname='enum mjtBuiltin', values=dict([ ('mjBUILTIN_NONE', 0), ('mjBUILTIN_GRADIENT', 1), @@ -681,7 +681,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtMark', EnumDecl( name='mjtMark', - declname='enum mjtMark_', + declname='enum mjtMark', values=dict([ ('mjMARK_NONE', 0), ('mjMARK_EDGE', 1), @@ -692,7 +692,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtLimited', EnumDecl( name='mjtLimited', - declname='enum mjtLimited_', + declname='enum mjtLimited', values=dict([ ('mjLIMITED_FALSE', 0), ('mjLIMITED_TRUE', 1), @@ -702,7 +702,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtAlignFree', EnumDecl( name='mjtAlignFree', - declname='enum mjtAlignFree_', + declname='enum mjtAlignFree', values=dict([ ('mjALIGNFREE_FALSE', 0), ('mjALIGNFREE_TRUE', 1), @@ -712,7 +712,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtInertiaFromGeom', EnumDecl( name='mjtInertiaFromGeom', - declname='enum mjtInertiaFromGeom_', + declname='enum mjtInertiaFromGeom', values=dict([ ('mjINERTIAFROMGEOM_FALSE', 0), ('mjINERTIAFROMGEOM_TRUE', 1), @@ -722,7 +722,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtOrientation', EnumDecl( name='mjtOrientation', - declname='enum mjtOrientation_', + declname='enum mjtOrientation', values=dict([ ('mjORIENTATION_QUAT', 0), ('mjORIENTATION_AXISANGLE', 1), @@ -734,7 +734,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtConflict', EnumDecl( name='mjtConflict', - declname='enum mjtConflict_', + declname='enum mjtConflict', values=dict([ ('mjCONFLICT_WARNING', 0), ('mjCONFLICT_MERGE', 1), @@ -744,7 +744,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtCTimer', EnumDecl( name='mjtCTimer', - declname='enum mjtCTimer_', + declname='enum mjtCTimer', values=dict([ ('mjCTIMER_TOTAL', 0), ('mjCTIMER_ASSETS', 1), @@ -1038,7 +1038,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtButton', EnumDecl( name='mjtButton', - declname='enum mjtButton_', + declname='enum mjtButton', values=dict([ ('mjBUTTON_NONE', 0), ('mjBUTTON_LEFT', 1), @@ -1049,7 +1049,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtEvent', EnumDecl( name='mjtEvent', - declname='enum mjtEvent_', + declname='enum mjtEvent', values=dict([ ('mjEVENT_NONE', 0), ('mjEVENT_MOVE', 1), @@ -1065,7 +1065,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtItem', EnumDecl( name='mjtItem', - declname='enum mjtItem_', + declname='enum mjtItem', values=dict([ ('mjITEM_END', -2), ('mjITEM_SECTION', -1), @@ -1089,7 +1089,7 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjtSection', EnumDecl( name='mjtSection', - declname='enum mjtSection_', + declname='enum mjtSection', values=dict([ ('mjSECT_CLOSED', 0), ('mjSECT_OPEN', 1), diff --git a/python/mujoco/introspect/enums_test.py b/python/mujoco/introspect/enums_test.py index 67b51961..6153b59a 100644 --- a/python/mujoco/introspect/enums_test.py +++ b/python/mujoco/introspect/enums_test.py @@ -25,7 +25,7 @@ class EnumsTest(absltest.TestCase): def test_mjtJoint(self): # pylint: disable=invalid-name enum_decl = enums.ENUMS['mjtJoint'] self.assertEqual(enum_decl.name, 'mjtJoint') - self.assertEqual(enum_decl.declname, 'enum mjtJoint_') + self.assertEqual(enum_decl.declname, 'enum mjtJoint') self.assertEqual( tuple(enum_decl.values.items()), (('mjJNT_FREE', 0), ('mjJNT_BALL', 1), @@ -36,7 +36,7 @@ class EnumsTest(absltest.TestCase): def test_mjtEnableBit(self): # pylint: disable=invalid-name enum_decl = enums.ENUMS['mjtEnableBit'] self.assertEqual(enum_decl.name, 'mjtEnableBit') - self.assertEqual(enum_decl.declname, 'enum mjtEnableBit_') + self.assertEqual(enum_decl.declname, 'enum mjtEnableBit') self.assertEqual( tuple(enum_decl.values.items()), (('mjENBL_OVERRIDE', 1<<0), ('mjENBL_ENERGY', 1<<1), @@ -50,7 +50,7 @@ class EnumsTest(absltest.TestCase): def test_mjtGeom(self): # pylint: disable=invalid-name enum_decl = enums.ENUMS['mjtGeom'] self.assertEqual(enum_decl.name, 'mjtGeom') - self.assertEqual(enum_decl.declname, 'enum mjtGeom_') + self.assertEqual(enum_decl.declname, 'enum mjtGeom') self.assertEqual(enum_decl.values['mjGEOM_PLANE'], 0) self.assertEqual(enum_decl.values['mjGEOM_HFIELD'], 1)