Replace name attribute with setters and getters in the C API of mjSpec.

PiperOrigin-RevId: 778816015
Change-Id: Ieffb7a5bce37e887ff009f9a02d2434435e79ca1
This commit is contained in:
Alessio Quaglino
2025-07-03 02:29:49 -07:00
committed by Copybara-Service
parent 1c5d47c94b
commit 594e17074a
22 changed files with 290 additions and 400 deletions
-24
View File
@@ -205,7 +205,6 @@ typedef struct mjsPlugin_ { // plugin specification
typedef struct mjsBody_ { // body specification
mjsElement* element; // element type
mjString* name; // name
mjString* childclass; // childclass name
// body frame
@@ -233,7 +232,6 @@ typedef struct mjsBody_ { // body specification
typedef struct mjsFrame_ { // frame specification
mjsElement* element; // element type
mjString* name; // name
mjString* childclass; // childclass name
double pos[3]; // position
double quat[4]; // orientation
@@ -244,7 +242,6 @@ typedef struct mjsFrame_ { // frame specification
typedef struct mjsJoint_ { // joint specification
mjsElement* element; // element type
mjString* name; // name
mjtJoint type; // joint type
// kinematics
@@ -284,7 +281,6 @@ typedef struct mjsJoint_ { // joint specification
typedef struct mjsGeom_ { // geom specification
mjsElement* element; // element type
mjString* name; // name
mjtGeom type; // geom type
// frame, size
@@ -332,7 +328,6 @@ typedef struct mjsGeom_ { // geom specification
typedef struct mjsSite_ { // site specification
mjsElement* element; // element type
mjString* name; // name
// frame, size
double pos[3]; // position
@@ -355,7 +350,6 @@ typedef struct mjsSite_ { // site specification
typedef struct mjsCamera_ { // camera specification
mjsElement* element; // element type
mjString* name; // name
// extrinsics
double pos[3]; // position
@@ -384,7 +378,6 @@ typedef struct mjsCamera_ { // camera specification
typedef struct mjsLight_ { // light specification
mjsElement* element; // element type
mjString* name; // name
// frame
double pos[3]; // position
@@ -414,7 +407,6 @@ typedef struct mjsLight_ { // light specification
typedef struct mjsFlex_ { // flex specification
mjsElement* element; // element type
mjString* name; // name
// contact properties
int contype; // contact type
@@ -463,7 +455,6 @@ typedef struct mjsFlex_ { // flex specification
typedef struct mjsMesh_ { // mesh specification
mjsElement* element; // element type
mjString* name; // name
mjString* content_type; // content type of file
mjString* file; // mesh file
double refpos[3]; // reference position
@@ -484,7 +475,6 @@ typedef struct mjsMesh_ { // mesh specification
typedef struct mjsHField_ { // height field specification
mjsElement* element; // element type
mjString* name; // name
mjString* content_type; // content type of file
mjString* file; // file: (nrow, ncol, [elevation data])
double size[4]; // hfield size (ignore referencing geom size)
@@ -498,7 +488,6 @@ typedef struct mjsHField_ { // height field specification
typedef struct mjsSkin_ { // skin specification
mjsElement* element; // element type
mjString* name; // name
mjString* file; // skin file
mjString* material; // name of material used for rendering
float rgba[4]; // rgba when material is omitted
@@ -524,7 +513,6 @@ typedef struct mjsSkin_ { // skin specification
typedef struct mjsTexture_ { // texture specification
mjsElement* element; // element type
mjString* name; // name
mjtTexture type; // texture type
mjtColorSpace colorspace; // colorspace
@@ -562,7 +550,6 @@ typedef struct mjsTexture_ { // texture specification
typedef struct mjsMaterial_ { // material specification
mjsElement* element; // element type
mjString* name; // name
mjStringVec* textures; // names of textures (empty: none)
mjtByte texuniform; // make texture cube uniform
float texrepeat[2]; // texture repetition for 2D mapping
@@ -579,7 +566,6 @@ typedef struct mjsMaterial_ { // material specification
typedef struct mjsPair_ { // pair specification
mjsElement* element; // element type
mjString* name; // name
mjString* geomname1; // name of geom 1
mjString* geomname2; // name of geom 2
@@ -597,7 +583,6 @@ typedef struct mjsPair_ { // pair specification
typedef struct mjsExclude_ { // exclude specification
mjsElement* element; // element type
mjString* name; // name
mjString* bodyname1; // name of geom 1
mjString* bodyname2; // name of geom 2
mjString* info; // message appended to errors
@@ -606,7 +591,6 @@ typedef struct mjsExclude_ { // exclude specification
typedef struct mjsEquality_ { // equality specification
mjsElement* element; // element type
mjString* name; // name
mjtEq type; // constraint type
double data[mjNEQDATA]; // type-dependent data
mjtByte active; // is equality initially active
@@ -621,7 +605,6 @@ typedef struct mjsEquality_ { // equality specification
typedef struct mjsTendon_ { // tendon specification
mjsElement* element; // element type
mjString* name; // name
// stiffness, damping, friction, armature
double stiffness; // stiffness coefficient
@@ -661,7 +644,6 @@ typedef struct mjsWrap_ { // wrapping object specification
typedef struct mjsActuator_ { // actuator specification
mjsElement* element; // element type
mjString* name; // name
// gain, bias
mjtGain gaintype; // gain type
@@ -703,7 +685,6 @@ typedef struct mjsActuator_ { // actuator specification
typedef struct mjsSensor_ { // sensor specification
mjsElement* element; // element type
mjString* name; // name
// sensor definition
mjtSensor type; // type of sensor
@@ -730,7 +711,6 @@ typedef struct mjsSensor_ { // sensor specification
typedef struct mjsNumeric_ { // custom numeric field specification
mjsElement* element; // element type
mjString* name; // name
mjDoubleVec* data; // initialization data
int size; // array size, can be bigger than data size
mjString* info; // message appended to compiler errors
@@ -739,7 +719,6 @@ typedef struct mjsNumeric_ { // custom numeric field specification
typedef struct mjsText_ { // custom text specification
mjsElement* element; // element type
mjString* name; // name
mjString* data; // text string
mjString* info; // message appended to compiler errors
} mjsText;
@@ -747,7 +726,6 @@ typedef struct mjsText_ { // custom text specification
typedef struct mjsTuple_ { // tuple specification
mjsElement* element; // element type
mjString* name; // name
mjIntVec* objtype; // object types
mjStringVec* objname; // object names
mjDoubleVec* objprm; // object parameters
@@ -757,7 +735,6 @@ typedef struct mjsTuple_ { // tuple specification
typedef struct mjsKey_ { // keyframe specification
mjsElement* element; // element type
mjString* name; // name
double time; // time
mjDoubleVec* qpos; // qpos
mjDoubleVec* qvel; // qvel
@@ -771,7 +748,6 @@ typedef struct mjsKey_ { // keyframe specification
typedef struct mjsDefault_ { // default specification
mjsElement* element; // element type
mjString* name; // class name
mjsJoint* joint; // joint defaults
mjsGeom* geom; // geom defaults
mjsSite* site; // site defaults
+6
View File
@@ -1600,6 +1600,9 @@ MJAPI mjsElement* mjs_nextElement(mjSpec* s, mjsElement* element);
//---------------------------------- Attribute setters ---------------------------------------------
// Set element's name.
MJAPI void mjs_setName(mjsElement* element, const char* name);
// Copy buffer.
MJAPI void mjs_setBuffer(mjByteVec* dest, const void* array, int size);
@@ -1636,6 +1639,9 @@ MJAPI void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes);
//---------------------------------- Attribute getters ---------------------------------------------
// Get element's name.
MJAPI mjString* mjs_getName(mjsElement* element);
// Get string contents.
MJAPI const char* mjs_getString(const mjString* source);