Clean-up user_api.h and user_init.cc
PiperOrigin-RevId: 605967516 Change-Id: Ieaf75d764778d81932b860ca9f16007adc0037a1
This commit is contained in:
committed by
Copybara-Service
parent
230f8c7b63
commit
cebd2a657e
+294
-223
@@ -19,299 +19,370 @@
|
|||||||
#include <mujoco/mjmodel.h>
|
#include <mujoco/mjmodel.h>
|
||||||
#include <mujoco/mjtnum.h>
|
#include <mujoco/mjtnum.h>
|
||||||
|
|
||||||
typedef struct _mjString* mjString;
|
|
||||||
typedef struct _mjDouble* mjDouble;
|
|
||||||
typedef struct _mjElement* mjElement;
|
|
||||||
|
|
||||||
|
|
||||||
// this is a C-API
|
// this is a C-API
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//---------------------------------- Public structs ------------------------------------------------
|
|
||||||
|
|
||||||
// type of mesh
|
//---------------------------------- handles to internal objects -----------------------------------
|
||||||
typedef enum _mjtGeomInertia {
|
|
||||||
mjINERTIA_VOLUME,
|
typedef struct _mjElement* mjElement;
|
||||||
mjINERTIA_SHELL,
|
typedef struct _mjString* mjString;
|
||||||
|
typedef struct _mjDouble* mjDouble;
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------- enum types (mjt) ----------------------------------------------
|
||||||
|
|
||||||
|
typedef enum _mjtGeomInertia { // type of inertia inference
|
||||||
|
mjINERTIA_VOLUME, // mass distributed in the volume
|
||||||
|
mjINERTIA_SHELL, // mass distributed on the surface
|
||||||
} mjtGeomInertia;
|
} mjtGeomInertia;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmOrientation {
|
//---------------------------------- attribute structs (mjm) ---------------------------------------
|
||||||
|
|
||||||
|
typedef struct _mjmOrientation { // alternative orientation specifiers
|
||||||
double axisangle[4]; // rotation axis and angle
|
double axisangle[4]; // rotation axis and angle
|
||||||
double xyaxes[6]; // x and y axes
|
double xyaxes[6]; // x and y axes
|
||||||
double zaxis[3]; // z axis (use minimal rotation)
|
double zaxis[3]; // z axis (use minimal rotation)
|
||||||
double euler[3]; // euler rotations
|
double euler[3]; // euler angles
|
||||||
} mjmOrientation;
|
} mjmOrientation;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmPlugin {
|
typedef struct _mjmPlugin { // plugin specification
|
||||||
bool active;
|
mjElement instance; // internal, do not modify
|
||||||
mjString name;
|
mjString name; // name
|
||||||
mjString instance_name;
|
mjString instance_name; // instance name
|
||||||
mjElement instance;
|
bool active; // is the plugin active
|
||||||
} mjmPlugin;
|
} mjmPlugin;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmBody {
|
typedef struct _mjmBody { // body specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // childclass name
|
||||||
double pos[3]; // frame position
|
|
||||||
double quat[4]; // frame orientation
|
// body frame
|
||||||
mjtByte mocap; // is this a mocap body
|
double pos[3]; // frame position
|
||||||
mjmOrientation alt; // frame alternative orientation
|
double quat[4]; // frame orientation
|
||||||
double gravcomp; // gravity compensation
|
mjmOrientation alt; // frame alternative orientation
|
||||||
mjDouble userdata; // user data
|
|
||||||
double ipos[3]; // inertial frame position
|
// inertial frame
|
||||||
double iquat[4]; // inertial frame orientation
|
double mass; // mass
|
||||||
double mass; // mass
|
double ipos[3]; // inertial frame position
|
||||||
double inertia[3]; // diagonal inertia (in i-frame)
|
double iquat[4]; // inertial frame orientation
|
||||||
mjmOrientation ialt; // inertial frame alternative orientation
|
double inertia[3]; // diagonal inertia (in i-frame)
|
||||||
double fullinertia[6]; // non-axis-aligned inertia matrix
|
mjmOrientation ialt; // inertial frame alternative orientation
|
||||||
mjtByte explicitinertial; // whether to save the body with an explicit inertial clause
|
double fullinertia[6]; // non-axis-aligned inertia matrix
|
||||||
mjmPlugin plugin; // passive force plugin
|
|
||||||
mjString info; // message appended to errors
|
// other
|
||||||
|
mjtByte mocap; // is this a mocap body
|
||||||
|
double gravcomp; // gravity compensation
|
||||||
|
mjDouble userdata; // user data
|
||||||
|
mjtByte explicitinertial; // whether to save the body with explicit inertial clause
|
||||||
|
mjmPlugin plugin; // passive force plugin
|
||||||
|
mjString info; // message appended to compiler errors
|
||||||
} mjmBody;
|
} mjmBody;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmJoint {
|
typedef struct _mjmJoint { // joint specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
|
mjtJoint type; // joint type
|
||||||
|
|
||||||
// joint properties
|
// kinematics
|
||||||
mjtJoint type; // type of Joint
|
|
||||||
int group; // used for rendering
|
|
||||||
int limited; // does joint have limits: 0 false, 1 true, 2 auto
|
|
||||||
int actfrclimited; // are actuator forces on joints limited: 0 false, 1 true, 2 auto
|
|
||||||
double pos[3]; // anchor position
|
double pos[3]; // anchor position
|
||||||
double axis[3]; // joint axis
|
double axis[3]; // joint axis
|
||||||
|
double ref; // value at reference configuration: qpos0
|
||||||
|
|
||||||
|
// stiffness
|
||||||
double stiffness; // stiffness coefficient
|
double stiffness; // stiffness coefficient
|
||||||
|
double springref; // spring reference value: qpos_spring
|
||||||
double springdamper[2]; // timeconst, dampratio
|
double springdamper[2]; // timeconst, dampratio
|
||||||
|
|
||||||
|
// limits
|
||||||
|
int limited; // does joint have limits
|
||||||
double range[2]; // joint limits
|
double range[2]; // joint limits
|
||||||
double actfrcrange[2]; // actuator force limits
|
double margin; // margin value for joint limit detection
|
||||||
mjtNum solref_limit[mjNREF]; // solver reference: joint limits
|
mjtNum solref_limit[mjNREF]; // solver reference: joint limits
|
||||||
mjtNum solimp_limit[mjNIMP]; // solver impedance: joint limits
|
mjtNum solimp_limit[mjNIMP]; // solver impedance: joint limits
|
||||||
mjtNum solref_friction[mjNREF]; // solver reference: dof friction
|
int actfrclimited; // are actuator forces on joint limited
|
||||||
mjtNum solimp_friction[mjNIMP]; // solver impedance: dof friction
|
double actfrcrange[2]; // actuator force limits
|
||||||
double margin; // margin value for joint limit detection
|
|
||||||
double ref; // value at reference configuration: qpos0
|
|
||||||
double springref; // spring reference value: qpos_spring
|
|
||||||
mjDouble userdata; // user data
|
|
||||||
|
|
||||||
// dof properties
|
// dof properties
|
||||||
double armature; // armature inertia (mass for slider)
|
double armature; // armature inertia (mass for slider)
|
||||||
double damping; // damping coefficient
|
double damping; // damping coefficient
|
||||||
double frictionloss; // friction loss
|
double frictionloss; // friction loss
|
||||||
|
mjtNum solref_friction[mjNREF]; // solver reference: dof friction
|
||||||
|
mjtNum solimp_friction[mjNIMP]; // solver impedance: dof friction
|
||||||
|
|
||||||
// other attributes
|
// other
|
||||||
mjString info; // message appended to errors
|
int group; // group
|
||||||
double urdfeffort; // store effort field from urdf
|
double urdfeffort; // effort (urdf)
|
||||||
|
mjDouble userdata; // user data
|
||||||
|
mjString info; // message appended to compiler errors
|
||||||
} mjmJoint;
|
} mjmJoint;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmGeom {
|
typedef struct _mjmGeom { // geom specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // classname
|
mjString classname; // classname
|
||||||
mjtGeom type; // geom type
|
mjtGeom type; // geom type
|
||||||
double pos[3]; // position
|
|
||||||
double quat[4]; // orientation
|
// frame, size
|
||||||
mjmOrientation alt; // alternative orientation specifications
|
double pos[3]; // position
|
||||||
int contype; // contact type
|
double quat[4]; // orientation
|
||||||
int conaffinity; // contact affinity
|
mjmOrientation alt; // alternative orientation
|
||||||
int condim; // contact dimensionality
|
double fromto[6]; // alternative for capsule, cylinder, box, ellipsoid
|
||||||
int group; // used for rendering
|
double size[3]; // type-specific size
|
||||||
int priority; // contact priority
|
|
||||||
double size[3]; // geom-specific size parameters
|
// contact related
|
||||||
double friction[3]; // one-sided friction coefficients: slide, roll, spin
|
int contype; // contact type
|
||||||
double solmix; // solver mixing for contact pairs
|
int conaffinity; // contact affinity
|
||||||
mjtNum solref[mjNREF]; // solver reference
|
int condim; // contact dimensionality
|
||||||
mjtNum solimp[mjNIMP]; // solver impedance
|
int priority; // contact priority
|
||||||
double mass; // used to compute density
|
double friction[3]; // one-sided friction coefficients: slide, roll, spin
|
||||||
double density; // used to compute mass and inertia (from volume)
|
double solmix; // solver mixing for contact pairs
|
||||||
double fromto[6]; // alternative for capsule, cylinder, box, ellipsoid
|
mjtNum solref[mjNREF]; // solver reference
|
||||||
double margin; // margin for contact detection
|
mjtNum solimp[mjNIMP]; // solver impedance
|
||||||
double gap; // include in solver if dist<margin-gap
|
double margin; // margin for contact detection
|
||||||
mjtNum fluid_ellipsoid; // whether ellipsoid-fluid model is active
|
double gap; // include in solver if dist < margin-gap
|
||||||
mjtNum fluid_coefs[5]; // ellipsoid-fluid interaction coefs
|
|
||||||
mjString material; // name of material used for rendering
|
// inertia inference
|
||||||
mjString hfieldname; // hfield attached to geom
|
double mass; // used to compute density
|
||||||
mjString meshname; // mesh attached to geom
|
double density; // used to compute mass and inertia from volume or surface
|
||||||
double fitscale; // scale mesh uniformly
|
mjtGeomInertia typeinertia; // selects between surface and volume inertia
|
||||||
mjDouble userdata; // user data
|
|
||||||
float rgba[4]; // rgba when material is omitted
|
// fluid forces
|
||||||
mjtGeomInertia typeinertia; // selects between surface and volume inertia
|
mjtNum fluid_ellipsoid; // whether ellipsoid-fluid model is active
|
||||||
mjmPlugin plugin; // sdf plugin
|
mjtNum fluid_coefs[5]; // ellipsoid-fluid interaction coefs
|
||||||
mjString info;
|
|
||||||
|
// visual
|
||||||
|
mjString material; // name of material
|
||||||
|
float rgba[4]; // rgba when material is omitted
|
||||||
|
int group; // group
|
||||||
|
|
||||||
|
// other
|
||||||
|
mjString hfieldname; // heightfield attached to geom
|
||||||
|
mjString meshname; // mesh attached to geom
|
||||||
|
double fitscale; // scale mesh uniformly
|
||||||
|
mjDouble userdata; // user data
|
||||||
|
mjmPlugin plugin; // sdf plugin
|
||||||
|
mjString info; // message appended to compiler errors
|
||||||
} mjmGeom;
|
} mjmGeom;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmSite {
|
typedef struct _mjmSite { // site specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjtGeom type; // geom type for rendering
|
|
||||||
int group; // group id, used for visualization
|
// frame, size
|
||||||
double pos[3]; // position
|
double pos[3]; // position
|
||||||
double quat[4]; // orientation
|
double quat[4]; // orientation
|
||||||
mjString material; // name of material for rendering
|
mjmOrientation alt; // alternative orientation
|
||||||
double size[3]; // geom size for rendering
|
double fromto[6]; // alternative for capsule, cylinder, box, ellipsoid
|
||||||
double fromto[6]; // alternative for capsule, cylinder, box, ellipsoid
|
double size[3]; // geom size
|
||||||
mjmOrientation alt; // alternative orientation specification
|
|
||||||
float rgba[4]; // rgba when material is omitted
|
// visual
|
||||||
mjDouble userdata; // user data
|
mjtGeom type; // geom type
|
||||||
mjString info; // message appended to errors
|
mjString material; // name of material
|
||||||
|
int group; // group
|
||||||
|
float rgba[4]; // rgba when material is omitted
|
||||||
|
|
||||||
|
// other
|
||||||
|
mjDouble userdata; // user data
|
||||||
|
mjString info; // message appended to compiler errors
|
||||||
} mjmSite;
|
} mjmSite;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmCamera {
|
typedef struct _mjmCamera { // camera specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString info; // message appended to errors
|
|
||||||
mjtCamLight mode; // tracking mode
|
// extrinsics
|
||||||
mjString targetbody; // target body for orientation
|
double pos[3]; // position
|
||||||
double fovy; // y-field of view
|
double quat[4]; // orientation
|
||||||
double ipd; // inter-pupilary distance
|
mjmOrientation alt; // alternative orientation
|
||||||
double pos[3]; // position
|
mjtCamLight mode; // tracking mode
|
||||||
double quat[4]; // orientation
|
mjString targetbody; // target body for tracking/targeting
|
||||||
float intrinsic[4]; // camera intrinsics [length]
|
|
||||||
float sensor_size[2]; // sensor size [length]
|
// intrinsics
|
||||||
float resolution[2]; // resolution [pixel]
|
double fovy; // y-field of view
|
||||||
float focal_length[2]; // focal length [length]
|
double ipd; // inter-pupilary distance
|
||||||
float focal_pixel[2]; // focal length [pixel]
|
float intrinsic[4]; // camera intrinsics (length)
|
||||||
float principal_length[2]; // principal point [length]
|
float sensor_size[2]; // sensor size (length)
|
||||||
float principal_pixel[2]; // principal point [pixel]
|
float resolution[2]; // resolution (pixel)
|
||||||
mjDouble userdata; // user data
|
float focal_length[2]; // focal length (length)
|
||||||
mjmOrientation alt; // alternative orientation specification
|
float focal_pixel[2]; // focal length (pixel)
|
||||||
|
float principal_length[2]; // principal point (length)
|
||||||
|
float principal_pixel[2]; // principal point (pixel)
|
||||||
|
|
||||||
|
// other
|
||||||
|
mjDouble userdata; // user data
|
||||||
|
mjString info; // message appended to compiler errors
|
||||||
} mjmCamera;
|
} mjmCamera;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmLight {
|
typedef struct _mjmLight { // light specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString info; // message appended to errors
|
|
||||||
mjtCamLight mode; // tracking mode
|
// frame
|
||||||
mjString targetbody; // target body for orientation
|
double pos[3]; // position
|
||||||
mjtByte directional; // directional light
|
double dir[3]; // direction
|
||||||
mjtByte castshadow; // does light cast shadows
|
mjtCamLight mode; // tracking mode
|
||||||
mjtByte active; // is light active
|
mjString targetbody; // target body for targeting
|
||||||
double pos[3]; // position
|
|
||||||
double dir[3]; // direction
|
// intrinsics
|
||||||
float attenuation[3]; // OpenGL attenuation (quadratic model)
|
mjtByte active; // is light active
|
||||||
float cutoff; // OpenGL cutoff
|
mjtByte directional; // is light directional or spot
|
||||||
float exponent; // OpenGL exponent
|
mjtByte castshadow; // does light cast shadows
|
||||||
float ambient[3]; // ambient color
|
float attenuation[3]; // OpenGL attenuation (quadratic model)
|
||||||
float diffuse[3]; // diffuse color
|
float cutoff; // OpenGL cutoff
|
||||||
float specular[3]; // specular color
|
float exponent; // OpenGL exponent
|
||||||
|
float ambient[3]; // ambient color
|
||||||
|
float diffuse[3]; // diffuse color
|
||||||
|
float specular[3]; // specular color
|
||||||
|
|
||||||
|
// other
|
||||||
|
mjString info; // message appended to compiler errors
|
||||||
} mjmLight;
|
} mjmLight;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmEquality {
|
typedef struct _mjmEquality { // equality specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjtEq type; // constraint type
|
mjtEq type; // constraint type
|
||||||
mjString name1; // name of object 1
|
double data[mjNEQDATA]; // type-dependent data
|
||||||
mjString name2; // name of object 2
|
mjtByte active; // is equality initially active
|
||||||
mjtByte active; // initial activation state
|
mjString name1; // name of object 1
|
||||||
mjtNum solref[mjNREF]; // solver reference
|
mjString name2; // name of object 2
|
||||||
mjtNum solimp[mjNIMP]; // solver impedance
|
mjtNum solref[mjNREF]; // solver reference
|
||||||
double data[mjNEQDATA]; // type-dependent data
|
mjtNum solimp[mjNIMP]; // solver impedance
|
||||||
mjString info; // message appended to errors
|
mjString info; // message appended to errors
|
||||||
} mjmEquality;
|
} mjmEquality;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmTendon {
|
typedef struct _mjmTendon { // tendon specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
int group; // group for visualization
|
|
||||||
int limited; // does tendon have limits: 0 false, 1 true, 2 auto
|
// stiffness, damping, friction
|
||||||
double width; // width for rendering
|
|
||||||
mjtNum solref_limit[mjNREF]; // solver reference: tendon limits
|
|
||||||
mjtNum solimp_limit[mjNIMP]; // solver impedance: tendon limits
|
|
||||||
mjtNum solref_friction[mjNREF]; // solver reference: tendon friction
|
|
||||||
mjtNum solimp_friction[mjNIMP]; // solver impedance: tendon friction
|
|
||||||
double range[2]; // length limits
|
|
||||||
double margin; // margin value for tendon limit detection
|
|
||||||
double stiffness; // stiffness coefficient
|
double stiffness; // stiffness coefficient
|
||||||
|
double springlength[2]; // spring resting length; {-1, -1}: use qpos_spring
|
||||||
double damping; // damping coefficient
|
double damping; // damping coefficient
|
||||||
double frictionloss; // friction loss
|
double frictionloss; // friction loss
|
||||||
double springlength[2]; // spring resting length; {-1, -1}: use qpos_spring
|
mjtNum solref_friction[mjNREF]; // solver reference: tendon friction
|
||||||
|
mjtNum solimp_friction[mjNIMP]; // solver impedance: tendon friction
|
||||||
|
|
||||||
|
// length range
|
||||||
|
int limited; // does tendon have limits: 0 false, 1 true, 2 auto
|
||||||
|
double range[2]; // length limits
|
||||||
|
double margin; // margin value for tendon limit detection
|
||||||
|
mjtNum solref_limit[mjNREF]; // solver reference: tendon limits
|
||||||
|
mjtNum solimp_limit[mjNIMP]; // solver impedance: tendon limits
|
||||||
|
|
||||||
|
// visual
|
||||||
mjString material; // name of material for rendering
|
mjString material; // name of material for rendering
|
||||||
mjDouble userdata; // user data
|
double width; // width for rendering
|
||||||
float rgba[4]; // rgba when material is omitted
|
float rgba[4]; // rgba when material is omitted
|
||||||
|
int group; // group
|
||||||
|
|
||||||
|
// other
|
||||||
|
mjDouble userdata; // user data
|
||||||
mjString info; // message appended to errors
|
mjString info; // message appended to errors
|
||||||
} mjmTendon;
|
} mjmTendon;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmWrap {
|
typedef struct _mjmWrap { // wrapping object specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString info; // message appended to errors
|
mjString info; // message appended to errors
|
||||||
} mjmWrap;
|
} mjmWrap;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmActuator {
|
typedef struct _mjmActuator { // actuator specification
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString info; // message appended to errors
|
|
||||||
int group; // group for visualization
|
// gain, bias
|
||||||
int ctrllimited; // are control limits defined: 0 false, 1 true, 2 auto
|
mjtGain gaintype; // gain type
|
||||||
int forcelimited; // are force limits defined: 0 false, 1 true, 2 auto
|
double gainprm[mjNGAIN]; // gain parameters
|
||||||
int actlimited; // are activation limits defined: 0 false, 1 true, 2 auto
|
mjtBias biastype; // bias type
|
||||||
int actdim; // dimension of associated activations
|
double biasprm[mjNGAIN]; // bias parameters
|
||||||
int plugin_actdim; // actuator state size for plugins
|
|
||||||
mjtDyn dyntype; // dynamics type
|
// activation state
|
||||||
mjtTrn trntype; // transmission type
|
mjtDyn dyntype; // dynamics type
|
||||||
mjtGain gaintype; // gain type
|
double dynprm[mjNDYN]; // dynamics parameters
|
||||||
mjtBias biastype; // bias type
|
int actdim; // number of activation variables
|
||||||
double dynprm[mjNDYN]; // dynamics parameters
|
int plugin_actdim; // actuator state size for plugins
|
||||||
double gainprm[mjNGAIN]; // gain parameters
|
mjtByte actearly; // apply next activations to qfrc
|
||||||
double biasprm[mjNGAIN]; // bias parameters
|
|
||||||
mjtByte actearly; // apply activations to qfrc instantly
|
// transmission
|
||||||
double ctrlrange[2]; // control range
|
mjtTrn trntype; // transmission type
|
||||||
double forcerange[2]; // force range
|
double gear[6]; // length and transmitted force scaling
|
||||||
double actrange[2]; // activation range
|
mjString target; // name of transmission target
|
||||||
double lengthrange[2]; // length range
|
mjString refsite; // reference site, for site transmission
|
||||||
double gear[6]; // length and transmitted force scaling
|
mjString slidersite; // site defining cylinder, for slider-crank
|
||||||
double cranklength; // crank length, for slider-crank only
|
double cranklength; // crank length, for slider-crank
|
||||||
mjDouble userdata; // user data
|
double lengthrange[2]; // transmission length range
|
||||||
mjString target; // transmission target name
|
|
||||||
mjString slidersite; // site defining cylinder, for slider-crank only
|
// input/output clamping
|
||||||
mjString refsite; // reference site, for site transmission only
|
int ctrllimited; // are control limits defined: 0 false, 1 true, 2 auto
|
||||||
mjmPlugin plugin; // actuator plugin
|
double ctrlrange[2]; // control range
|
||||||
|
int forcelimited; // are force limits defined: 0 false, 1 true, 2 auto
|
||||||
|
double forcerange[2]; // force range
|
||||||
|
int actlimited; // are activation limits defined: 0 false, 1 true, 2 auto
|
||||||
|
double actrange[2]; // activation range
|
||||||
|
|
||||||
|
// other
|
||||||
|
int group; // group
|
||||||
|
mjDouble userdata; // user data
|
||||||
|
mjmPlugin plugin; // actuator plugin
|
||||||
|
mjString info; // message appended to compiler errors
|
||||||
} mjmActuator;
|
} mjmActuator;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjmSensor {
|
typedef struct _mjmSensor { // sensor specfication
|
||||||
mjElement element; // compiler only, do not modify
|
mjElement element; // internal, do not modify
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString info; // message appended to errors
|
|
||||||
mjtSensor type; // type of sensor
|
// sensor defintion
|
||||||
mjtDataType datatype; // data type for sensor measurement
|
mjtSensor type; // type of sensor
|
||||||
mjtStage needstage; // compute stage needed to simulate sensor
|
mjtObj objtype; // type of sensorized object
|
||||||
mjtObj objtype; // type of sensorized object
|
mjString objname; // name of sensorized object
|
||||||
mjString objname; // name of sensorized object
|
mjtObj reftype; // type of referenced object
|
||||||
mjtObj reftype; // type of referenced object
|
mjString refname; // name of referenced object
|
||||||
mjString refname; // name of referenced object
|
|
||||||
int dim; // number of scalar outputs
|
// user-defined sensors
|
||||||
double cutoff; // cutoff for real and positive datatypes
|
mjtDataType datatype; // data type for sensor measurement
|
||||||
double noise; // noise stdev
|
mjtStage needstage; // compute stage needed to simulate sensor
|
||||||
mjDouble userdata; // user data
|
int dim; // number of scalar outputs
|
||||||
mjmPlugin plugin; // sensor plugin
|
|
||||||
|
// output post-processing
|
||||||
|
double cutoff; // cutoff for real and positive datatypes
|
||||||
|
double noise; // noise stdev
|
||||||
|
|
||||||
|
// other
|
||||||
|
mjDouble userdata; // user data
|
||||||
|
mjmPlugin plugin; // sensor plugin
|
||||||
|
mjString info; // message appended to compiler errors
|
||||||
} mjmSensor;
|
} mjmSensor;
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------- Public API ----------------------------------------------------
|
//---------------------------------- API functions -------------------------------------------------
|
||||||
|
|
||||||
// Create model.
|
// Create model.
|
||||||
MJAPI void* mjm_createModel();
|
MJAPI void* mjm_createModel();
|
||||||
@@ -379,19 +450,19 @@ MJAPI void* mjm_getModel(mjmBody* body);
|
|||||||
// Get default corresponding to an mjElement.
|
// Get default corresponding to an mjElement.
|
||||||
MJAPI void* mjm_getDefault(mjElement element);
|
MJAPI void* mjm_getDefault(mjElement element);
|
||||||
|
|
||||||
// Finding body with given name in model.
|
// Find body in model by name.
|
||||||
MJAPI mjmBody* mjm_findBody(void* modelspec, const char* name);
|
MJAPI mjmBody* mjm_findBody(void* modelspec, const char* name);
|
||||||
|
|
||||||
// Finding body with given name in body.
|
// Find child body by name.
|
||||||
MJAPI mjmBody* mjm_findChild(mjmBody* body, const char* name);
|
MJAPI mjmBody* mjm_findChild(mjmBody* body, const char* name);
|
||||||
|
|
||||||
// Get element id.
|
// Get element id.
|
||||||
MJAPI int mjm_getId(mjElement element);
|
MJAPI int mjm_getId(mjElement element);
|
||||||
|
|
||||||
// Copy input text to destination string.
|
// Copy text to destination string.
|
||||||
MJAPI void mjm_setString(mjString dest, const char* text);
|
MJAPI void mjm_setString(mjString dest, const char* text);
|
||||||
|
|
||||||
// Copy input array to destination vector.
|
// Copy double array to destination vector.
|
||||||
MJAPI void mjm_setDouble(mjDouble dest, const double* array, int size);
|
MJAPI void mjm_setDouble(mjDouble dest, const double* array, int size);
|
||||||
|
|
||||||
// Get string contents.
|
// Get string contents.
|
||||||
|
|||||||
+70
-57
@@ -19,22 +19,21 @@
|
|||||||
#include "user/user_util.h"
|
#include "user/user_util.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// default body attributes
|
// default body attributes
|
||||||
void mjm_defaultBody(mjmBody& body) {
|
void mjm_defaultBody(mjmBody& body) {
|
||||||
memset(&body, 0, sizeof(mjmBody));
|
memset(&body, 0, sizeof(mjmBody));
|
||||||
|
|
||||||
// set non-zero defaults
|
// body frame
|
||||||
body.fullinertia[0] = mjNAN;
|
|
||||||
body.explicitinertial = 0;
|
|
||||||
body.mocap = 0;
|
|
||||||
body.quat[0] = 1;
|
|
||||||
body.iquat[0] = 1;
|
|
||||||
body.pos[0] = mjNAN;
|
body.pos[0] = mjNAN;
|
||||||
body.ipos[0] = mjNAN;
|
body.quat[0] = 1;
|
||||||
body.alt.axisangle[0] = body.alt.xyaxes[0] = body.alt.zaxis[0] = body.alt.euler[0] = mjNAN;
|
body.alt.axisangle[0] = body.alt.xyaxes[0] = body.alt.zaxis[0] = body.alt.euler[0] = mjNAN;
|
||||||
|
|
||||||
|
// inertial frame
|
||||||
|
body.ipos[0] = mjNAN;
|
||||||
|
body.iquat[0] = 1;
|
||||||
body.ialt.axisangle[0] = body.ialt.xyaxes[0] = body.ialt.zaxis[0] = body.ialt.euler[0] = mjNAN;
|
body.ialt.axisangle[0] = body.ialt.xyaxes[0] = body.ialt.zaxis[0] = body.ialt.euler[0] = mjNAN;
|
||||||
body.plugin.active = false;
|
body.fullinertia[0] = mjNAN;
|
||||||
body.plugin.instance = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +41,7 @@ void mjm_defaultBody(mjmBody& body) {
|
|||||||
// default joint attributes
|
// default joint attributes
|
||||||
void mjm_defaultJoint(mjmJoint& joint) {
|
void mjm_defaultJoint(mjmJoint& joint) {
|
||||||
memset(&joint, 0, sizeof(mjmJoint));
|
memset(&joint, 0, sizeof(mjmJoint));
|
||||||
|
|
||||||
joint.type = mjJNT_HINGE;
|
joint.type = mjJNT_HINGE;
|
||||||
joint.axis[2] = 1;
|
joint.axis[2] = 1;
|
||||||
joint.limited = 2;
|
joint.limited = 2;
|
||||||
@@ -57,10 +57,15 @@ void mjm_defaultJoint(mjmJoint& joint) {
|
|||||||
void mjm_defaultGeom(mjmGeom& geom) {
|
void mjm_defaultGeom(mjmGeom& geom) {
|
||||||
memset(&geom, 0, sizeof(mjmGeom));
|
memset(&geom, 0, sizeof(mjmGeom));
|
||||||
|
|
||||||
// set non-zero defaults
|
// type
|
||||||
geom.fromto[0] = mjNAN;
|
|
||||||
geom.mass = mjNAN;
|
|
||||||
geom.type = mjGEOM_SPHERE;
|
geom.type = mjGEOM_SPHERE;
|
||||||
|
|
||||||
|
// frame
|
||||||
|
geom.quat[0] = 1;
|
||||||
|
geom.fromto[0] = mjNAN;
|
||||||
|
geom.alt.axisangle[0] = geom.alt.xyaxes[0] = geom.alt.zaxis[0] = geom.alt.euler[0] = mjNAN;
|
||||||
|
|
||||||
|
// contact-related
|
||||||
geom.contype = 1;
|
geom.contype = 1;
|
||||||
geom.conaffinity = 1;
|
geom.conaffinity = 1;
|
||||||
geom.condim = 3;
|
geom.condim = 3;
|
||||||
@@ -69,34 +74,44 @@ void mjm_defaultGeom(mjmGeom& geom) {
|
|||||||
geom.friction[2] = 0.0001;
|
geom.friction[2] = 0.0001;
|
||||||
geom.solmix = 1.0;
|
geom.solmix = 1.0;
|
||||||
mj_defaultSolRefImp(geom.solref, geom.solimp);
|
mj_defaultSolRefImp(geom.solref, geom.solimp);
|
||||||
geom.density = 1000; // water density (1000 kg / m^3)
|
|
||||||
geom.fitscale = 1;
|
// inertia-related
|
||||||
|
geom.mass = mjNAN;
|
||||||
|
geom.density = 1000; // water density (1000 Kg / m^3)
|
||||||
|
geom.typeinertia = mjINERTIA_VOLUME;
|
||||||
|
|
||||||
|
// color
|
||||||
geom.rgba[0] = geom.rgba[1] = geom.rgba[2] = 0.5f;
|
geom.rgba[0] = geom.rgba[1] = geom.rgba[2] = 0.5f;
|
||||||
geom.rgba[3] = 1.0f;
|
geom.rgba[3] = 1.0f;
|
||||||
geom.typeinertia = mjINERTIA_VOLUME;
|
|
||||||
geom.quat[0] = 1;
|
// fluid forces
|
||||||
geom.alt.axisangle[0] = geom.alt.xyaxes[0] = geom.alt.zaxis[0] = geom.alt.euler[0] = mjNAN;
|
geom.fluid_coefs[0] = 0.5; // blunt drag
|
||||||
geom.fluid_coefs[0] = 0.5; // blunt drag coefficient
|
geom.fluid_coefs[1] = 0.25; // slender drag
|
||||||
geom.fluid_coefs[1] = 0.25; // slender drag coefficient
|
geom.fluid_coefs[2] = 1.5; // angular drag
|
||||||
geom.fluid_coefs[2] = 1.5; // angular drag coefficient
|
geom.fluid_coefs[3] = 1.0; // kutta lift
|
||||||
geom.fluid_coefs[3] = 1.0; // kutta lift coefficient
|
geom.fluid_coefs[4] = 1.0; // magnus lift
|
||||||
geom.fluid_coefs[4] = 1.0; // magnus lift coefficient
|
|
||||||
geom.plugin.active = false;
|
// other
|
||||||
geom.plugin.instance = nullptr;
|
geom.fitscale = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// default site attributes
|
// default site attributes
|
||||||
void mjm_defaultSite(mjmSite& site) {
|
void mjm_defaultSite(mjmSite& site) {
|
||||||
|
// set everything to 0 / false / NULL
|
||||||
memset(&site, 0, sizeof(mjmSite));
|
memset(&site, 0, sizeof(mjmSite));
|
||||||
|
|
||||||
// set non-zero defaults
|
// type
|
||||||
site.type = mjGEOM_SPHERE;
|
site.type = mjGEOM_SPHERE;
|
||||||
|
|
||||||
|
// frame
|
||||||
site.quat[0] = 1;
|
site.quat[0] = 1;
|
||||||
site.size[0] = site.size[1] = site.size[2] = 0.005;
|
site.size[0] = site.size[1] = site.size[2] = 0.005;
|
||||||
site.fromto[0] = mjNAN;
|
site.fromto[0] = mjNAN;
|
||||||
site.alt.axisangle[0] = site.alt.xyaxes[0] = site.alt.zaxis[0] = site.alt.euler[0] = mjNAN;
|
site.alt.axisangle[0] = site.alt.xyaxes[0] = site.alt.zaxis[0] = site.alt.euler[0] = mjNAN;
|
||||||
|
|
||||||
|
// color
|
||||||
site.rgba[0] = site.rgba[1] = site.rgba[2] = 0.5f;
|
site.rgba[0] = site.rgba[1] = site.rgba[2] = 0.5f;
|
||||||
site.rgba[3] = 1.0f;
|
site.rgba[3] = 1.0f;
|
||||||
}
|
}
|
||||||
@@ -106,12 +121,18 @@ void mjm_defaultSite(mjmSite& site) {
|
|||||||
// default cam attributes
|
// default cam attributes
|
||||||
void mjm_defaultCamera(mjmCamera& cam) {
|
void mjm_defaultCamera(mjmCamera& cam) {
|
||||||
memset(&cam, 0, sizeof(mjmCamera));
|
memset(&cam, 0, sizeof(mjmCamera));
|
||||||
|
|
||||||
|
// type
|
||||||
cam.mode = mjCAMLIGHT_FIXED;
|
cam.mode = mjCAMLIGHT_FIXED;
|
||||||
|
|
||||||
|
// extrinsics
|
||||||
cam.quat[0] = 1;
|
cam.quat[0] = 1;
|
||||||
|
cam.alt.axisangle[0] = cam.alt.xyaxes[0] = cam.alt.zaxis[0] = cam.alt.euler[0] = mjNAN;
|
||||||
|
|
||||||
|
// intrinsics
|
||||||
cam.fovy = 45;
|
cam.fovy = 45;
|
||||||
cam.ipd = 0.068;
|
cam.ipd = 0.068;
|
||||||
cam.resolution[0] = cam.resolution[1] = 1;
|
cam.resolution[0] = cam.resolution[1] = 1;
|
||||||
cam.alt.axisangle[0] = cam.alt.xyaxes[0] = cam.alt.zaxis[0] = cam.alt.euler[0] = mjNAN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,22 +140,24 @@ void mjm_defaultCamera(mjmCamera& cam) {
|
|||||||
// default light attributes
|
// default light attributes
|
||||||
void mjm_defaultLight(mjmLight& light) {
|
void mjm_defaultLight(mjmLight& light) {
|
||||||
memset(&light, 0, sizeof(mjmLight));
|
memset(&light, 0, sizeof(mjmLight));
|
||||||
|
|
||||||
|
// mode
|
||||||
light.mode = mjCAMLIGHT_FIXED;
|
light.mode = mjCAMLIGHT_FIXED;
|
||||||
light.directional = 0;
|
|
||||||
|
// intrinsics
|
||||||
light.castshadow = 1;
|
light.castshadow = 1;
|
||||||
light.active = 1;
|
light.active = 1;
|
||||||
light.dir[2] = -1;
|
light.dir[2] = -1;
|
||||||
light.attenuation[0] = 1;
|
light.attenuation[0] = 1;
|
||||||
light.cutoff = 45;
|
light.cutoff = 45;
|
||||||
light.exponent = 10;
|
light.exponent = 10;
|
||||||
light.ambient[0] = light.ambient[1] = light.ambient[2] = 0;
|
|
||||||
light.diffuse[0] = light.diffuse[1] = light.diffuse[2] = 0.7;
|
light.diffuse[0] = light.diffuse[1] = light.diffuse[2] = 0.7;
|
||||||
light.specular[0] = light.specular[1] = light.specular[2] = 0.3;
|
light.specular[0] = light.specular[1] = light.specular[2] = 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Default equality attributes.
|
// default equality attributes
|
||||||
void mjm_defaultEquality(mjmEquality& equality) {
|
void mjm_defaultEquality(mjmEquality& equality) {
|
||||||
memset(&equality, 0, sizeof(mjmEquality));
|
memset(&equality, 0, sizeof(mjmEquality));
|
||||||
equality.type = mjEQ_CONNECT;
|
equality.type = mjEQ_CONNECT;
|
||||||
@@ -149,18 +172,11 @@ void mjm_defaultEquality(mjmEquality& equality) {
|
|||||||
// default tendon attributes
|
// default tendon attributes
|
||||||
void mjm_defaultTendon(mjmTendon& tendon) {
|
void mjm_defaultTendon(mjmTendon& tendon) {
|
||||||
memset(&tendon, 0, sizeof(mjmTendon));
|
memset(&tendon, 0, sizeof(mjmTendon));
|
||||||
tendon.group = 0;
|
|
||||||
tendon.width = 0.003;
|
|
||||||
tendon.limited = 2;
|
tendon.limited = 2;
|
||||||
tendon.range[0] = 0;
|
tendon.springlength[0] = tendon.springlength[1] = -1;
|
||||||
tendon.range[1] = 0;
|
|
||||||
mj_defaultSolRefImp(tendon.solref_limit, tendon.solimp_limit);
|
mj_defaultSolRefImp(tendon.solref_limit, tendon.solimp_limit);
|
||||||
mj_defaultSolRefImp(tendon.solref_friction, tendon.solimp_friction);
|
mj_defaultSolRefImp(tendon.solref_friction, tendon.solimp_friction);
|
||||||
tendon.margin = 0;
|
tendon.width = 0.003;
|
||||||
tendon.stiffness = 0;
|
|
||||||
tendon.damping = 0;
|
|
||||||
tendon.frictionloss = 0;
|
|
||||||
tendon.springlength[0] = tendon.springlength[1] = -1;
|
|
||||||
tendon.rgba[0] = tendon.rgba[1] = tendon.rgba[2] = 0.5f;
|
tendon.rgba[0] = tendon.rgba[1] = tendon.rgba[2] = 0.5f;
|
||||||
tendon.rgba[3] = 1.0f;
|
tendon.rgba[3] = 1.0f;
|
||||||
}
|
}
|
||||||
@@ -170,23 +186,25 @@ void mjm_defaultTendon(mjmTendon& tendon) {
|
|||||||
// default actuator attributes
|
// default actuator attributes
|
||||||
void mjm_defaultActuator(mjmActuator& actuator) {
|
void mjm_defaultActuator(mjmActuator& actuator) {
|
||||||
memset(&actuator, 0, sizeof(mjmActuator));
|
memset(&actuator, 0, sizeof(mjmActuator));
|
||||||
actuator.group = 0;
|
|
||||||
|
// gain, bias
|
||||||
|
actuator.gaintype = mjGAIN_FIXED;
|
||||||
|
actuator.gainprm[0] = 1;
|
||||||
|
actuator.biastype = mjBIAS_NONE;
|
||||||
|
|
||||||
|
// activation state
|
||||||
|
actuator.dyntype = mjDYN_NONE;
|
||||||
|
actuator.dynprm[0] = 1;
|
||||||
|
actuator.actdim = -1;
|
||||||
|
|
||||||
|
// transmission
|
||||||
|
actuator.trntype = mjTRN_UNDEFINED;
|
||||||
|
actuator.gear[0] = 1;
|
||||||
|
|
||||||
|
// input/output clamping
|
||||||
actuator.ctrllimited = 2;
|
actuator.ctrllimited = 2;
|
||||||
actuator.forcelimited = 2;
|
actuator.forcelimited = 2;
|
||||||
actuator.actlimited = 2;
|
actuator.actlimited = 2;
|
||||||
actuator.actdim = -1;
|
|
||||||
actuator.plugin_actdim = 0;
|
|
||||||
actuator.trntype = mjTRN_UNDEFINED;
|
|
||||||
actuator.dyntype = mjDYN_NONE;
|
|
||||||
actuator.gaintype = mjGAIN_FIXED;
|
|
||||||
actuator.biastype = mjBIAS_NONE;
|
|
||||||
actuator.actearly = 0;
|
|
||||||
actuator.gear[0] = 1;
|
|
||||||
actuator.dynprm[0] = 1;
|
|
||||||
actuator.gainprm[0] = 1;
|
|
||||||
actuator.cranklength = 0;
|
|
||||||
actuator.plugin.active = false;
|
|
||||||
actuator.plugin.instance = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -197,11 +215,6 @@ void mjm_defaultSensor(mjmSensor& sensor) {
|
|||||||
sensor.type = mjSENS_TOUCH;
|
sensor.type = mjSENS_TOUCH;
|
||||||
sensor.datatype = mjDATATYPE_REAL;
|
sensor.datatype = mjDATATYPE_REAL;
|
||||||
sensor.needstage = mjSTAGE_ACC;
|
sensor.needstage = mjSTAGE_ACC;
|
||||||
sensor.objtype = mjOBJ_UNKNOWN;
|
|
||||||
sensor.reftype = mjOBJ_UNKNOWN;
|
|
||||||
sensor.cutoff = 0;
|
|
||||||
sensor.noise = 0;
|
|
||||||
sensor.dim = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user