Version 2.1.1: Binaries for ARM64, proper macOS bundles, minor bugfixes.

Closes #2
Closes #42
Closes #59

PiperOrigin-RevId: 416794598
Change-Id: I1306df1127d6acecf2323873c0da0910f35d31a0
This commit is contained in:
Saran Tunyasuvunakool
2021-12-16 14:36:53 +00:00
parent 4bf5630558
commit a499b38120
49 changed files with 6055 additions and 5712 deletions
Executable → Regular
+228 -233
View File
@@ -15,310 +15,305 @@
#ifndef MUJOCO_MJDATA_H_
#define MUJOCO_MJDATA_H_
//---------------------------- primitive types (mjt) ------------------------------------
#include "mjmodel.h"
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
mjWARN_VGEOMFULL, // too many visual geoms
mjWARN_BADQPOS, // bad number in qpos
mjWARN_BADQVEL, // bad number in qvel
mjWARN_BADQACC, // bad number in qacc
mjWARN_BADCTRL, // bad number in ctrl
//---------------------------------- primitive types (mjt) -----------------------------------------
mjNWARNING // number of warnings
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
mjWARN_VGEOMFULL, // too many visual geoms
mjWARN_BADQPOS, // bad number in qpos
mjWARN_BADQVEL, // bad number in qvel
mjWARN_BADQACC, // bad number in qacc
mjWARN_BADCTRL, // bad number in ctrl
mjNWARNING // number of warnings
} mjtWarning;
typedef enum _mjtTimer
{
// main api
mjTIMER_STEP = 0, // step
mjTIMER_FORWARD, // forward
mjTIMER_INVERSE, // inverse
typedef enum mjtTimer_ {
// main api
mjTIMER_STEP = 0, // step
mjTIMER_FORWARD, // forward
mjTIMER_INVERSE, // inverse
// breakdown of step/forward
mjTIMER_POSITION, // fwdPosition
mjTIMER_VELOCITY, // fwdVelocity
mjTIMER_ACTUATION, // fwdActuation
mjTIMER_ACCELERATION, // fwdAcceleration
mjTIMER_CONSTRAINT, // fwdConstraint
// breakdown of step/forward
mjTIMER_POSITION, // fwdPosition
mjTIMER_VELOCITY, // fwdVelocity
mjTIMER_ACTUATION, // fwdActuation
mjTIMER_ACCELERATION, // fwdAcceleration
mjTIMER_CONSTRAINT, // fwdConstraint
// breakdown of fwdPosition
mjTIMER_POS_KINEMATICS, // kinematics, com, tendon, transmission
mjTIMER_POS_INERTIA, // inertia computations
mjTIMER_POS_COLLISION, // collision detection
mjTIMER_POS_MAKE, // make constraints
mjTIMER_POS_PROJECT, // project constraints
// breakdown of fwdPosition
mjTIMER_POS_KINEMATICS, // kinematics, com, tendon, transmission
mjTIMER_POS_INERTIA, // inertia computations
mjTIMER_POS_COLLISION, // collision detection
mjTIMER_POS_MAKE, // make constraints
mjTIMER_POS_PROJECT, // project constraints
mjNTIMER // number of timers
mjNTIMER // number of timers
} mjtTimer;
//------------------------------ mjContact ----------------------------------------------
//---------------------------------- mjContact -----------------------------------------------------
struct _mjContact // result of collision detection functions
{
// contact parameters set by geom-specific collision detector
mjtNum dist; // distance between nearest points; neg: penetration
mjtNum pos[3]; // position of contact point: midpoint between geoms
mjtNum frame[9]; // normal is in [0-2]
struct mjContact_ { // result of collision detection functions
// contact parameters set by geom-specific collision detector
mjtNum dist; // distance between nearest points; neg: penetration
mjtNum pos[3]; // position of contact point: midpoint between geoms
mjtNum frame[9]; // normal is in [0-2]
// contact parameters set by mj_collideGeoms
mjtNum includemargin; // include if dist<includemargin=margin-gap
mjtNum friction[5]; // tangent1, 2, spin, roll1, 2
mjtNum solref[mjNREF]; // constraint solver reference
mjtNum solimp[mjNIMP]; // constraint solver impedance
// contact parameters set by mj_collideGeoms
mjtNum includemargin; // include if dist<includemargin=margin-gap
mjtNum friction[5]; // tangent1, 2, spin, roll1, 2
mjtNum solref[mjNREF]; // constraint solver reference
mjtNum solimp[mjNIMP]; // constraint solver impedance
// internal storage used by solver
mjtNum mu; // friction of regularized cone, set by mj_makeConstraint
mjtNum H[36]; // cone Hessian, set by mj_updateConstraint
// internal storage used by solver
mjtNum mu; // friction of regularized cone, set by mj_makeConstraint
mjtNum H[36]; // cone Hessian, set by mj_updateConstraint
// contact descriptors set by mj_collideGeoms
int dim; // contact space dimensionality: 1, 3, 4 or 6
int geom1; // id of geom 1
int geom2; // id of geom 2
// contact descriptors set by mj_collideGeoms
int dim; // contact space dimensionality: 1, 3, 4 or 6
int geom1; // id of geom 1
int geom2; // id of geom 2
// flag set by mj_fuseContact or mj_instantianteEquality
int exclude; // 0: include, 1: in gap, 2: fused, 3: equality, 4: no dofs
// flag set by mj_fuseContact or mj_instantianteEquality
int exclude; // 0: include, 1: in gap, 2: fused, 3: equality, 4: no dofs
// address computed by mj_instantiateContact
int efc_address; // address in efc; -1: not included, -2-i: distance constraint i
// address computed by mj_instantiateContact
int efc_address; // address in efc; -1: not included, -2-i: distance constraint i
};
typedef struct _mjContact mjContact;
typedef struct mjContact_ mjContact;
//------------------------------ diagnostics --------------------------------------------
//---------------------------------- diagnostics ---------------------------------------------------
struct _mjWarningStat // warning statistics
{
int lastinfo; // info from last warning
int number; // how many times was warning raised
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_ mjWarningStat;
struct _mjTimerStat // timer statistics
{
mjtNum duration; // cumulative duration
int number; // how many times was timer called
struct mjTimerStat_ { // timer statistics
mjtNum duration; // cumulative duration
int number; // how many times was timer called
};
typedef struct _mjTimerStat mjTimerStat;
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
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_ mjSolverStat;
//---------------------------------- mjData ---------------------------------------------
//---------------------------------- mjData --------------------------------------------------------
struct _mjData
{
// constant sizes
int nstack; // number of mjtNums that can fit in stack
int nbuffer; // size of main buffer in bytes
struct mjData_ {
// constant sizes
int nstack; // number of mjtNums that can fit in stack
int nbuffer; // size of main buffer in bytes
// stack pointer
int pstack; // first available mjtNum address in stack
// stack pointer
int pstack; // first available mjtNum address in stack
// memory utilization stats
int maxuse_stack; // maximum stack allocation
int maxuse_con; // maximum number of contacts
int maxuse_efc; // maximum number of scalar constraints
// memory utilization stats
int maxuse_stack; // maximum stack allocation
int maxuse_con; // maximum number of contacts
int maxuse_efc; // maximum number of scalar constraints
// diagnostics
mjWarningStat warning[mjNWARNING]; // warning statistics
mjTimerStat timer[mjNTIMER]; // timer statistics
mjSolverStat solver[mjNSOLVER]; // solver statistics per iteration
int solver_iter; // number of solver iterations
int solver_nnz; // number of non-zeros in Hessian or efc_AR
mjtNum solver_fwdinv[2]; // forward-inverse comparison: qfrc, efc
// diagnostics
mjWarningStat warning[mjNWARNING]; // warning statistics
mjTimerStat timer[mjNTIMER]; // timer statistics
mjSolverStat solver[mjNSOLVER]; // solver statistics per iteration
int solver_iter; // number of solver iterations
int solver_nnz; // number of non-zeros in Hessian or efc_AR
mjtNum solver_fwdinv[2]; // forward-inverse comparison: qfrc, efc
// variable sizes
int ne; // number of equality constraints
int nf; // number of friction constraints
int nefc; // number of constraints
int ncon; // number of detected contacts
// variable sizes
int ne; // number of equality constraints
int nf; // number of friction constraints
int nefc; // number of constraints
int ncon; // number of detected contacts
// global properties
mjtNum time; // simulation time
mjtNum energy[2]; // potential, kinetic energy
// global properties
mjtNum time; // simulation time
mjtNum energy[2]; // potential, kinetic energy
//-------------------------------- end of info header
//-------------------------------- end of info header
// buffers
void* buffer; // main buffer; all pointers point in it (nbuffer bytes)
mjtNum* stack; // stack buffer (nstack mjtNums)
// buffers
void* buffer; // main buffer; all pointers point in it (nbuffer bytes)
mjtNum* stack; // stack buffer (nstack mjtNums)
//-------------------------------- main inputs and outputs of the computation
//-------------------------------- main inputs and outputs of the computation
// state
mjtNum* qpos; // position (nq x 1)
mjtNum* qvel; // velocity (nv x 1)
mjtNum* act; // actuator activation (na x 1)
mjtNum* qacc_warmstart; // acceleration used for warmstart (nv x 1)
// state
mjtNum* qpos; // position (nq x 1)
mjtNum* qvel; // velocity (nv x 1)
mjtNum* act; // actuator activation (na x 1)
mjtNum* qacc_warmstart; // acceleration used for warmstart (nv x 1)
// control
mjtNum* ctrl; // control (nu x 1)
mjtNum* qfrc_applied; // applied generalized force (nv x 1)
mjtNum* xfrc_applied; // applied Cartesian force/torque (nbody x 6)
// control
mjtNum* ctrl; // control (nu x 1)
mjtNum* qfrc_applied; // applied generalized force (nv x 1)
mjtNum* xfrc_applied; // applied Cartesian force/torque (nbody x 6)
// dynamics
mjtNum* qacc; // acceleration (nv x 1)
mjtNum* act_dot; // time-derivative of actuator activation (na x 1)
// dynamics
mjtNum* qacc; // acceleration (nv x 1)
mjtNum* act_dot; // time-derivative of actuator activation (na x 1)
// mocap data
mjtNum* mocap_pos; // positions of mocap bodies (nmocap x 3)
mjtNum* mocap_quat; // orientations of mocap bodies (nmocap x 4)
// mocap data
mjtNum* mocap_pos; // positions of mocap bodies (nmocap x 3)
mjtNum* mocap_quat; // orientations of mocap bodies (nmocap x 4)
// user data
mjtNum* userdata; // user data, not touched by engine (nuserdata x 1)
// user data
mjtNum* userdata; // user data, not touched by engine (nuserdata x 1)
// sensors
mjtNum* sensordata; // sensor data array (nsensordata x 1)
// sensors
mjtNum* sensordata; // sensor data array (nsensordata x 1)
//-------------------------------- POSITION dependent
//-------------------------------- POSITION dependent
// computed by mj_fwdPosition/mj_kinematics
mjtNum* xpos; // Cartesian position of body frame (nbody x 3)
mjtNum* xquat; // Cartesian orientation of body frame (nbody x 4)
mjtNum* xmat; // Cartesian orientation of body frame (nbody x 9)
mjtNum* xipos; // Cartesian position of body com (nbody x 3)
mjtNum* ximat; // Cartesian orientation of body inertia (nbody x 9)
mjtNum* xanchor; // Cartesian position of joint anchor (njnt x 3)
mjtNum* xaxis; // Cartesian joint axis (njnt x 3)
mjtNum* geom_xpos; // Cartesian geom position (ngeom x 3)
mjtNum* geom_xmat; // Cartesian geom orientation (ngeom x 9)
mjtNum* site_xpos; // Cartesian site position (nsite x 3)
mjtNum* site_xmat; // Cartesian site orientation (nsite x 9)
mjtNum* cam_xpos; // Cartesian camera position (ncam x 3)
mjtNum* cam_xmat; // Cartesian camera orientation (ncam x 9)
mjtNum* light_xpos; // Cartesian light position (nlight x 3)
mjtNum* light_xdir; // Cartesian light direction (nlight x 3)
// computed by mj_fwdPosition/mj_kinematics
mjtNum* xpos; // Cartesian position of body frame (nbody x 3)
mjtNum* xquat; // Cartesian orientation of body frame (nbody x 4)
mjtNum* xmat; // Cartesian orientation of body frame (nbody x 9)
mjtNum* xipos; // Cartesian position of body com (nbody x 3)
mjtNum* ximat; // Cartesian orientation of body inertia (nbody x 9)
mjtNum* xanchor; // Cartesian position of joint anchor (njnt x 3)
mjtNum* xaxis; // Cartesian joint axis (njnt x 3)
mjtNum* geom_xpos; // Cartesian geom position (ngeom x 3)
mjtNum* geom_xmat; // Cartesian geom orientation (ngeom x 9)
mjtNum* site_xpos; // Cartesian site position (nsite x 3)
mjtNum* site_xmat; // Cartesian site orientation (nsite x 9)
mjtNum* cam_xpos; // Cartesian camera position (ncam x 3)
mjtNum* cam_xmat; // Cartesian camera orientation (ncam x 9)
mjtNum* light_xpos; // Cartesian light position (nlight x 3)
mjtNum* light_xdir; // Cartesian light direction (nlight x 3)
// computed by mj_fwdPosition/mj_comPos
mjtNum* subtree_com; // center of mass of each subtree (nbody x 3)
mjtNum* cdof; // com-based motion axis of each dof (nv x 6)
mjtNum* cinert; // com-based body inertia and mass (nbody x 10)
// computed by mj_fwdPosition/mj_comPos
mjtNum* subtree_com; // center of mass of each subtree (nbody x 3)
mjtNum* cdof; // com-based motion axis of each dof (nv x 6)
mjtNum* cinert; // com-based body inertia and mass (nbody x 10)
// computed by mj_fwdPosition/mj_tendon
int* ten_wrapadr; // start address of tendon's path (ntendon x 1)
int* ten_wrapnum; // number of wrap points in path (ntendon x 1)
int* ten_J_rownnz; // number of non-zeros in Jacobian row (ntendon x 1)
int* ten_J_rowadr; // row start address in colind array (ntendon x 1)
int* ten_J_colind; // column indices in sparse Jacobian (ntendon x nv)
mjtNum* ten_length; // tendon lengths (ntendon x 1)
mjtNum* ten_J; // tendon Jacobian (ntendon x nv)
int* wrap_obj; // geom id; -1: site; -2: pulley (nwrap*2 x 1)
mjtNum* wrap_xpos; // Cartesian 3D points in all path (nwrap*2 x 3)
// computed by mj_fwdPosition/mj_tendon
int* ten_wrapadr; // start address of tendon's path (ntendon x 1)
int* ten_wrapnum; // number of wrap points in path (ntendon x 1)
int* ten_J_rownnz; // number of non-zeros in Jacobian row (ntendon x 1)
int* ten_J_rowadr; // row start address in colind array (ntendon x 1)
int* ten_J_colind; // column indices in sparse Jacobian (ntendon x nv)
mjtNum* ten_length; // tendon lengths (ntendon x 1)
mjtNum* ten_J; // tendon Jacobian (ntendon x nv)
int* wrap_obj; // geom id; -1: site; -2: pulley (nwrap*2 x 1)
mjtNum* wrap_xpos; // Cartesian 3D points in all path (nwrap*2 x 3)
// computed by mj_fwdPosition/mj_transmission
mjtNum* actuator_length; // actuator lengths (nu x 1)
mjtNum* actuator_moment; // actuator moments (nu x nv)
// computed by mj_fwdPosition/mj_transmission
mjtNum* actuator_length; // actuator lengths (nu x 1)
mjtNum* actuator_moment; // actuator moments (nu x nv)
// computed by mj_fwdPosition/mj_crb
mjtNum* crb; // com-based composite inertia and mass (nbody x 10)
mjtNum* qM; // total inertia (nM x 1)
// computed by mj_fwdPosition/mj_crb
mjtNum* crb; // com-based composite inertia and mass (nbody x 10)
mjtNum* qM; // total inertia (nM x 1)
// computed by mj_fwdPosition/mj_factorM
mjtNum* qLD; // L'*D*L factorization of M (nM x 1)
mjtNum* qLDiagInv; // 1/diag(D) (nv x 1)
mjtNum* qLDiagSqrtInv; // 1/sqrt(diag(D)) (nv x 1)
// computed by mj_fwdPosition/mj_factorM
mjtNum* qLD; // L'*D*L factorization of M (nM x 1)
mjtNum* qLDiagInv; // 1/diag(D) (nv x 1)
mjtNum* qLDiagSqrtInv; // 1/sqrt(diag(D)) (nv x 1)
// computed by mj_fwdPosition/mj_collision
mjContact* contact; // list of all detected contacts (nconmax x 1)
// computed by mj_fwdPosition/mj_collision
mjContact* contact; // list of all detected contacts (nconmax x 1)
// computed by mj_fwdPosition/mj_makeConstraint
int* efc_type; // constraint type (mjtConstraint) (njmax x 1)
int* efc_id; // id of object of specified type (njmax x 1)
int* efc_J_rownnz; // number of non-zeros in Jacobian row (njmax x 1)
int* efc_J_rowadr; // row start address in colind array (njmax x 1)
int* efc_J_rowsuper; // number of subsequent rows in supernode (njmax x 1)
int* efc_J_colind; // column indices in Jacobian (njmax x nv)
int* efc_JT_rownnz; // number of non-zeros in Jacobian row T (nv x 1)
int* efc_JT_rowadr; // row start address in colind array T (nv x 1)
int* efc_JT_rowsuper; // number of subsequent rows in supernode T (nv x 1)
int* efc_JT_colind; // column indices in Jacobian T (nv x njmax)
mjtNum* efc_J; // constraint Jacobian (njmax x nv)
mjtNum* efc_JT; // constraint Jacobian transposed (nv x njmax)
mjtNum* efc_pos; // constraint position (equality, contact) (njmax x 1)
mjtNum* efc_margin; // inclusion margin (contact) (njmax x 1)
mjtNum* efc_frictionloss; // frictionloss (friction) (njmax x 1)
mjtNum* efc_diagApprox; // approximation to diagonal of A (njmax x 1)
mjtNum* efc_KBIP; // stiffness, damping, impedance, imp' (njmax x 4)
mjtNum* efc_D; // constraint mass (njmax x 1)
mjtNum* efc_R; // inverse constraint mass (njmax x 1)
// computed by mj_fwdPosition/mj_makeConstraint
int* efc_type; // constraint type (mjtConstraint) (njmax x 1)
int* efc_id; // id of object of specified type (njmax x 1)
int* efc_J_rownnz; // number of non-zeros in Jacobian row (njmax x 1)
int* efc_J_rowadr; // row start address in colind array (njmax x 1)
int* efc_J_rowsuper; // number of subsequent rows in supernode (njmax x 1)
int* efc_J_colind; // column indices in Jacobian (njmax x nv)
int* efc_JT_rownnz; // number of non-zeros in Jacobian row T (nv x 1)
int* efc_JT_rowadr; // row start address in colind array T (nv x 1)
int* efc_JT_rowsuper; // number of subsequent rows in supernode T (nv x 1)
int* efc_JT_colind; // column indices in Jacobian T (nv x njmax)
mjtNum* efc_J; // constraint Jacobian (njmax x nv)
mjtNum* efc_JT; // constraint Jacobian transposed (nv x njmax)
mjtNum* efc_pos; // constraint position (equality, contact) (njmax x 1)
mjtNum* efc_margin; // inclusion margin (contact) (njmax x 1)
mjtNum* efc_frictionloss; // frictionloss (friction) (njmax x 1)
mjtNum* efc_diagApprox; // approximation to diagonal of A (njmax x 1)
mjtNum* efc_KBIP; // stiffness, damping, impedance, imp' (njmax x 4)
mjtNum* efc_D; // constraint mass (njmax x 1)
mjtNum* efc_R; // inverse constraint mass (njmax x 1)
// computed by mj_fwdPosition/mj_projectConstraint
int* efc_AR_rownnz; // number of non-zeros in AR (njmax x 1)
int* efc_AR_rowadr; // row start address in colind array (njmax x 1)
int* efc_AR_colind; // column indices in sparse AR (njmax x njmax)
mjtNum* efc_AR; // J*inv(M)*J' + R (njmax x njmax)
// computed by mj_fwdPosition/mj_projectConstraint
int* efc_AR_rownnz; // number of non-zeros in AR (njmax x 1)
int* efc_AR_rowadr; // row start address in colind array (njmax x 1)
int* efc_AR_colind; // column indices in sparse AR (njmax x njmax)
mjtNum* efc_AR; // J*inv(M)*J' + R (njmax x njmax)
//-------------------------------- POSITION, VELOCITY dependent
//-------------------------------- POSITION, VELOCITY dependent
// computed by mj_fwdVelocity
mjtNum* ten_velocity; // tendon velocities (ntendon x 1)
mjtNum* actuator_velocity; // actuator velocities (nu x 1)
// computed by mj_fwdVelocity
mjtNum* ten_velocity; // tendon velocities (ntendon x 1)
mjtNum* actuator_velocity; // actuator velocities (nu x 1)
// computed by mj_fwdVelocity/mj_comVel
mjtNum* cvel; // com-based velocity [3D rot; 3D tran] (nbody x 6)
mjtNum* cdof_dot; // time-derivative of cdof (nv x 6)
// computed by mj_fwdVelocity/mj_comVel
mjtNum* cvel; // com-based velocity [3D rot; 3D tran] (nbody x 6)
mjtNum* cdof_dot; // time-derivative of cdof (nv x 6)
// computed by mj_fwdVelocity/mj_rne (without acceleration)
mjtNum* qfrc_bias; // C(qpos,qvel) (nv x 1)
// computed by mj_fwdVelocity/mj_rne (without acceleration)
mjtNum* qfrc_bias; // C(qpos,qvel) (nv x 1)
// computed by mj_fwdVelocity/mj_passive
mjtNum* qfrc_passive; // passive force (nv x 1)
// computed by mj_fwdVelocity/mj_passive
mjtNum* qfrc_passive; // passive force (nv x 1)
// computed by mj_fwdVelocity/mj_referenceConstraint
mjtNum* efc_vel; // velocity in constraint space: J*qvel (njmax x 1)
mjtNum* efc_aref; // reference pseudo-acceleration (njmax x 1)
// computed by mj_fwdVelocity/mj_referenceConstraint
mjtNum* efc_vel; // velocity in constraint space: J*qvel (njmax x 1)
mjtNum* efc_aref; // reference pseudo-acceleration (njmax x 1)
// computed by mj_sensorVel/mj_subtreeVel if needed
mjtNum* subtree_linvel; // linear velocity of subtree com (nbody x 3)
mjtNum* subtree_angmom; // angular momentum about subtree com (nbody x 3)
// computed by mj_sensorVel/mj_subtreeVel if needed
mjtNum* subtree_linvel; // linear velocity of subtree com (nbody x 3)
mjtNum* subtree_angmom; // angular momentum about subtree com (nbody x 3)
//-------------------------------- POSITION, VELOCITY, CONTROL/ACCELERATION dependent
//-------------------------------- POSITION, VELOCITY, CONTROL/ACCELERATION dependent
// computed by mj_fwdActuation
mjtNum* actuator_force; // actuator force in actuation space (nu x 1)
mjtNum* qfrc_actuator; // actuator force (nv x 1)
// computed by mj_fwdActuation
mjtNum* actuator_force; // actuator force in actuation space (nu x 1)
mjtNum* qfrc_actuator; // actuator force (nv x 1)
// computed by mj_fwdAcceleration
mjtNum* qfrc_unc; // net unconstrained force (nv x 1)
mjtNum* qacc_unc; // unconstrained acceleration (nv x 1)
// computed by mj_fwdAcceleration
mjtNum* qfrc_unc; // net unconstrained force (nv x 1)
mjtNum* qacc_unc; // unconstrained acceleration (nv x 1)
// computed by mj_fwdConstraint/mj_inverse
mjtNum* efc_b; // linear cost term: J*qacc_unc - aref (njmax x 1)
mjtNum* efc_force; // constraint force in constraint space (njmax x 1)
int* efc_state; // constraint state (mjtConstraintState) (njmax x 1)
mjtNum* qfrc_constraint; // constraint force (nv x 1)
// computed by mj_fwdConstraint/mj_inverse
mjtNum* efc_b; // linear cost term: J*qacc_unc - aref (njmax x 1)
mjtNum* efc_force; // constraint force in constraint space (njmax x 1)
int* efc_state; // constraint state (mjtConstraintState) (njmax x 1)
mjtNum* qfrc_constraint; // constraint force (nv x 1)
// computed by mj_inverse
mjtNum* qfrc_inverse; // net external force; should equal: (nv x 1)
// qfrc_applied + J'*xfrc_applied + qfrc_actuator
// computed by mj_inverse
mjtNum* qfrc_inverse; // net external force; should equal: (nv x 1)
// qfrc_applied + J'*xfrc_applied + qfrc_actuator
// computed by mj_sensorAcc/mj_rnePostConstraint if needed; rotation:translation format
mjtNum* cacc; // com-based acceleration (nbody x 6)
mjtNum* cfrc_int; // com-based interaction force with parent (nbody x 6)
mjtNum* cfrc_ext; // com-based external force on body (nbody x 6)
// computed by mj_sensorAcc/mj_rnePostConstraint if needed; rotation:translation format
mjtNum* cacc; // com-based acceleration (nbody x 6)
mjtNum* cfrc_int; // com-based interaction force with parent (nbody x 6)
mjtNum* cfrc_ext; // com-based external force on body (nbody x 6)
};
typedef struct _mjData mjData;
typedef struct mjData_ mjData;
//---------------------------------- callback function types ----------------------------
//---------------------------------- callback function types ---------------------------------------
// generic MuJoCo function
typedef void (*mjfGeneric)(const mjModel* m, mjData* d);
Executable → Regular
+733 -770
View File
File diff suppressed because it is too large Load Diff
Executable → Regular
+103 -103
View File
@@ -15,137 +15,137 @@
#ifndef MUJOCO_MJRENDER_H_
#define MUJOCO_MJRENDER_H_
#define mjNAUX 10 // number of auxiliary buffers
#define mjMAXTEXTURE 1000 // maximum number of textures
#include "mjmodel.h"
#define mjNAUX 10 // number of auxiliary buffers
#define mjMAXTEXTURE 1000 // maximum number of textures
typedef enum _mjtGridPos // grid position for overlay
{
mjGRID_TOPLEFT = 0, // top left
mjGRID_TOPRIGHT, // top right
mjGRID_BOTTOMLEFT, // bottom left
mjGRID_BOTTOMRIGHT // bottom right
//---------------------------------- primitive types (mjt) -----------------------------------------
typedef enum mjtGridPos_ { // grid position for overlay
mjGRID_TOPLEFT = 0, // top left
mjGRID_TOPRIGHT, // top right
mjGRID_BOTTOMLEFT, // bottom left
mjGRID_BOTTOMRIGHT // bottom right
} mjtGridPos;
typedef enum _mjtFramebuffer // OpenGL framebuffer option
{
mjFB_WINDOW = 0, // default/window buffer
mjFB_OFFSCREEN // offscreen buffer
typedef enum mjtFramebuffer_ { // OpenGL framebuffer option
mjFB_WINDOW = 0, // default/window buffer
mjFB_OFFSCREEN // offscreen buffer
} mjtFramebuffer;
typedef enum _mjtFontScale // font scale, used at context creation
{
mjFONTSCALE_50 = 50, // 50% scale, suitable for low-res rendering
mjFONTSCALE_100 = 100, // normal scale, suitable in the absence of DPI scaling
mjFONTSCALE_150 = 150, // 150% scale
mjFONTSCALE_200 = 200, // 200% scale
mjFONTSCALE_250 = 250, // 250% scale
mjFONTSCALE_300 = 300 // 300% scale
typedef enum mjtFontScale_ { // font scale, used at context creation
mjFONTSCALE_50 = 50, // 50% scale, suitable for low-res rendering
mjFONTSCALE_100 = 100, // normal scale, suitable in the absence of DPI scaling
mjFONTSCALE_150 = 150, // 150% scale
mjFONTSCALE_200 = 200, // 200% scale
mjFONTSCALE_250 = 250, // 250% scale
mjFONTSCALE_300 = 300 // 300% scale
} mjtFontScale;
typedef enum _mjtFont // font type, used at each text operation
{
mjFONT_NORMAL = 0, // normal font
mjFONT_SHADOW, // normal font with shadow (for higher contrast)
mjFONT_BIG // big font (for user alerts)
typedef enum mjtFont_ { // font type, used at each text operation
mjFONT_NORMAL = 0, // normal font
mjFONT_SHADOW, // normal font with shadow (for higher contrast)
mjFONT_BIG // big font (for user alerts)
} mjtFont;
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)
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;
typedef struct mjrRect_ mjrRect;
struct _mjrContext // custom OpenGL context
{
// parameters copied from mjVisual
float lineWidth; // line width for wireframe rendering
float shadowClip; // clipping radius for directional lights
float shadowScale; // fraction of light cutoff for spot lights
float fogStart; // fog start = stat.extent * vis.map.fogstart
float fogEnd; // fog end = stat.extent * vis.map.fogend
float fogRGBA[4]; // fog rgba
int shadowSize; // size of shadow map texture
int offWidth; // width of offscreen buffer
int offHeight; // height of offscreen buffer
int offSamples; // number of offscreen buffer multisamples
//---------------------------------- mjrContext ----------------------------------------------------
// parameters specified at creation
int fontScale; // font scale
int auxWidth[mjNAUX]; // auxiliary buffer width
int auxHeight[mjNAUX]; // auxiliary buffer height
int auxSamples[mjNAUX]; // auxiliary buffer multisamples
struct mjrContext_ { // custom OpenGL context
// parameters copied from mjVisual
float lineWidth; // line width for wireframe rendering
float shadowClip; // clipping radius for directional lights
float shadowScale; // fraction of light cutoff for spot lights
float fogStart; // fog start = stat.extent * vis.map.fogstart
float fogEnd; // fog end = stat.extent * vis.map.fogend
float fogRGBA[4]; // fog rgba
int shadowSize; // size of shadow map texture
int offWidth; // width of offscreen buffer
int offHeight; // height of offscreen buffer
int offSamples; // number of offscreen buffer multisamples
// offscreen rendering objects
unsigned int offFBO; // offscreen framebuffer object
unsigned int offFBO_r; // offscreen framebuffer for resolving multisamples
unsigned int offColor; // offscreen color buffer
unsigned int offColor_r; // offscreen color buffer for resolving multisamples
unsigned int offDepthStencil; // offscreen depth and stencil buffer
unsigned int offDepthStencil_r; // offscreen depth and stencil buffer for resolving multisamples
// parameters specified at creation
int fontScale; // font scale
int auxWidth[mjNAUX]; // auxiliary buffer width
int auxHeight[mjNAUX]; // auxiliary buffer height
int auxSamples[mjNAUX]; // auxiliary buffer multisamples
// shadow rendering objects
unsigned int shadowFBO; // shadow map framebuffer object
unsigned int shadowTex; // shadow map texture
// offscreen rendering objects
unsigned int offFBO; // offscreen framebuffer object
unsigned int offFBO_r; // offscreen framebuffer for resolving multisamples
unsigned int offColor; // offscreen color buffer
unsigned int offColor_r; // offscreen color buffer for resolving multisamples
unsigned int offDepthStencil; // offscreen depth and stencil buffer
unsigned int offDepthStencil_r; // offscreen depth and stencil buffer for resolving multisamples
// auxiliary buffers
unsigned int auxFBO[mjNAUX]; // auxiliary framebuffer object
unsigned int auxFBO_r[mjNAUX]; // auxiliary framebuffer object for resolving
unsigned int auxColor[mjNAUX]; // auxiliary color buffer
unsigned int auxColor_r[mjNAUX];// auxiliary color buffer for resolving
// shadow rendering objects
unsigned int shadowFBO; // shadow map framebuffer object
unsigned int shadowTex; // shadow map texture
// texture objects and info
int ntexture; // number of allocated textures
int textureType[100]; // type of texture (mjtTexture)
unsigned int texture[100]; // texture names
// auxiliary buffers
unsigned int auxFBO[mjNAUX]; // auxiliary framebuffer object
unsigned int auxFBO_r[mjNAUX]; // auxiliary framebuffer object for resolving
unsigned int auxColor[mjNAUX]; // auxiliary color buffer
unsigned int auxColor_r[mjNAUX];// auxiliary color buffer for resolving
// displaylist starting positions
unsigned int basePlane; // all planes from model
unsigned int baseMesh; // all meshes from model
unsigned int baseHField; // all hfields from model
unsigned int baseBuiltin; // all buildin geoms, with quality from model
unsigned int baseFontNormal; // normal font
unsigned int baseFontShadow; // shadow font
unsigned int baseFontBig; // big font
// texture objects and info
int ntexture; // number of allocated textures
int textureType[100]; // type of texture (mjtTexture)
unsigned int texture[100]; // texture names
// displaylist ranges
int rangePlane; // all planes from model
int rangeMesh; // all meshes from model
int rangeHField; // all hfields from model
int rangeBuiltin; // all builtin geoms, with quality from model
int rangeFont; // all characters in font
// displaylist starting positions
unsigned int basePlane; // all planes from model
unsigned int baseMesh; // all meshes from model
unsigned int baseHField; // all hfields from model
unsigned int baseBuiltin; // all buildin geoms, with quality from model
unsigned int baseFontNormal; // normal font
unsigned int baseFontShadow; // shadow font
unsigned int baseFontBig; // big font
// skin VBOs
int nskin; // number of skins
unsigned int* skinvertVBO; // skin vertex position VBOs
unsigned int* skinnormalVBO; // skin vertex normal VBOs
unsigned int* skintexcoordVBO; // skin vertex texture coordinate VBOs
unsigned int* skinfaceVBO; // skin face index VBOs
// displaylist ranges
int rangePlane; // all planes from model
int rangeMesh; // all meshes from model
int rangeHField; // all hfields from model
int rangeBuiltin; // all builtin geoms, with quality from model
int rangeFont; // all characters in font
// character info
int charWidth[127]; // character widths: normal and shadow
int charWidthBig[127]; // chacarter widths: big
int charHeight; // character heights: normal and shadow
int charHeightBig; // character heights: big
// skin VBOs
int nskin; // number of skins
unsigned int* skinvertVBO; // skin vertex position VBOs
unsigned int* skinnormalVBO; // skin vertex normal VBOs
unsigned int* skintexcoordVBO; // skin vertex texture coordinate VBOs
unsigned int* skinfaceVBO; // skin face index VBOs
// capabilities
int glewInitialized; // is glew initialized
int windowAvailable; // is default/window framebuffer available
int windowSamples; // number of samples for default/window framebuffer
int windowStereo; // is stereo available for default/window framebuffer
int windowDoublebuffer; // is default/window framebuffer double buffered
// character info
int charWidth[127]; // character widths: normal and shadow
int charWidthBig[127]; // chacarter widths: big
int charHeight; // character heights: normal and shadow
int charHeightBig; // character heights: big
// framebuffer
int currentBuffer; // currently active framebuffer: mjFB_WINDOW or mjFB_OFFSCREEN
// capabilities
int glewInitialized; // is glew initialized
int windowAvailable; // is default/window framebuffer available
int windowSamples; // number of samples for default/window framebuffer
int windowStereo; // is stereo available for default/window framebuffer
int windowDoublebuffer; // is default/window framebuffer double buffered
// framebuffer
int currentBuffer; // currently active framebuffer: mjFB_WINDOW or mjFB_OFFSCREEN
};
typedef struct _mjrContext mjrContext;
typedef struct mjrContext_ mjrContext;
#endif // MUJOCO_MJRENDER_H_
Executable → Regular
+195 -192
View File
@@ -15,6 +15,8 @@
#ifndef MUJOCO_MJUI_H_
#define MUJOCO_MJUI_H_
#include "mjrender.h"
#define mjMAXUISECT 10 // maximum number of sections
#define mjMAXUIITEM 80 // maximum number of items per section
#define mjMAXUITEXT 300 // maximum number of chars in edittext and other
@@ -55,48 +57,47 @@
#define mjKEY_F12 301
typedef enum _mjtButton // mouse button
{
mjBUTTON_NONE = 0, // no button
mjBUTTON_LEFT, // left button
mjBUTTON_RIGHT, // right button
mjBUTTON_MIDDLE // middle button
//---------------------------------- primitive types (mjt) -----------------------------------------
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
{
mjEVENT_NONE = 0, // no event
mjEVENT_MOVE, // mouse move
mjEVENT_PRESS, // mouse button press
mjEVENT_RELEASE, // mouse button release
mjEVENT_SCROLL, // scroll
mjEVENT_KEY, // key press
mjEVENT_RESIZE // resize
typedef enum mjtEvent_ { // mouse and keyboard event type
mjEVENT_NONE = 0, // no event
mjEVENT_MOVE, // mouse move
mjEVENT_PRESS, // mouse button press
mjEVENT_RELEASE, // mouse button release
mjEVENT_SCROLL, // scroll
mjEVENT_KEY, // key press
mjEVENT_RESIZE // resize
} mjtEvent;
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
mjITEM_STATIC, // static text
mjITEM_BUTTON, // button
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
mjITEM_STATIC, // static text
mjITEM_BUTTON, // button
// the rest have data pointer
mjITEM_CHECKINT, // check box, int value
mjITEM_CHECKBYTE, // check box, mjtByte value
mjITEM_RADIO, // radio group
mjITEM_RADIOLINE, // radio group, single line
mjITEM_SELECT, // selection box
mjITEM_SLIDERINT, // slider, int value
mjITEM_SLIDERNUM, // slider, mjtNum value
mjITEM_EDITINT, // editable array, int values
mjITEM_EDITNUM, // editable array, mjtNum values
mjITEM_EDITTXT, // editable text
// the rest have data pointer
mjITEM_CHECKINT, // check box, int value
mjITEM_CHECKBYTE, // check box, mjtByte value
mjITEM_RADIO, // radio group
mjITEM_RADIOLINE, // radio group, single line
mjITEM_SELECT, // selection box
mjITEM_SLIDERINT, // slider, int value
mjITEM_SLIDERNUM, // slider, mjtNum value
mjITEM_EDITINT, // editable array, int values
mjITEM_EDITNUM, // editable array, mjtNum values
mjITEM_EDITTXT, // editable text
mjNITEM // number of item types
mjNITEM // number of item types
} mjtItem;
@@ -104,206 +105,208 @@ typedef enum _mjtItem // UI item type
typedef int (*mjfItemEnable)(int category, void* data);
struct _mjuiState // mouse and keyboard state
{
// constants set by user
int nrect; // number of rectangles used
mjrRect rect[mjMAXUIRECT]; // rectangles (index 0: entire window)
void* userdata; // pointer to user data (for callbacks)
//---------------------------------- mjuiState -----------------------------------------------------
// event type
int type; // (type mjtEvent)
struct mjuiState_ { // mouse and keyboard state
// constants set by user
int nrect; // number of rectangles used
mjrRect rect[mjMAXUIRECT]; // rectangles (index 0: entire window)
void* userdata; // pointer to user data (for callbacks)
// mouse buttons
int left; // is left button down
int right; // is right button down
int middle; // is middle button down
int doubleclick; // is last press a double click
int button; // which button was pressed (mjtButton)
double buttontime; // time of last button press
// event type
int type; // (type mjtEvent)
// mouse position
double x; // x position
double y; // y position
double dx; // x displacement
double dy; // y displacement
double sx; // x scroll
double sy; // y scroll
// mouse buttons
int left; // is left button down
int right; // is right button down
int middle; // is middle button down
int doubleclick; // is last press a double click
int button; // which button was pressed (mjtButton)
double buttontime; // time of last button press
// keyboard
int control; // is control down
int shift; // is shift down
int alt; // is alt down
int key; // which key was pressed
double keytime; // time of last key press
// mouse position
double x; // x position
double y; // y position
double dx; // x displacement
double dy; // y displacement
double sx; // x scroll
double sy; // y scroll
// rectangle ownership and dragging
int mouserect; // which rectangle contains mouse
int dragrect; // which rectangle is dragged with mouse
int dragbutton; // which button started drag (mjtButton)
// keyboard
int control; // is control down
int shift; // is shift down
int alt; // is alt down
int key; // which key was pressed
double keytime; // time of last key press
// rectangle ownership and dragging
int mouserect; // which rectangle contains mouse
int dragrect; // which rectangle is dragged with mouse
int dragbutton; // which button started drag (mjtButton)
};
typedef struct _mjuiState mjuiState;
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 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 ----------------------------------------------
struct mjuiThemeSpacing_ { // UI visualization theme spacing
int total; // total width
int scroll; // scrollbar width
int label; // label width
int section; // section gap
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_ mjuiThemeSpacing;
struct _mjuiThemeColor // UI visualization theme color
{
float master[3]; // master background
float thumb[3]; // scrollbar thumb
float secttitle[3]; // section title
float sectfont[3]; // section font
float sectsymbol[3]; // section symbol
float sectpane[3]; // section pane
float shortcut[3]; // shortcut background
float fontactive[3]; // font active
float fontinactive[3]; // font inactive
float decorinactive[3]; // decor inactive
float decorinactive2[3]; // inactive slider color 2
float button[3]; // button
float check[3]; // check
float radio[3]; // radio
float select[3]; // select
float select2[3]; // select pane
float slider[3]; // slider
float slider2[3]; // slider color 2
float edit[3]; // edit
float edit2[3]; // edit invalid
float cursor[3]; // edit cursor
//---------------------------------- mjuiThemeColor ------------------------------------------------
struct mjuiThemeColor_ { // UI visualization theme color
float master[3]; // master background
float thumb[3]; // scrollbar thumb
float secttitle[3]; // section title
float sectfont[3]; // section font
float sectsymbol[3]; // section symbol
float sectpane[3]; // section pane
float shortcut[3]; // shortcut background
float fontactive[3]; // font active
float fontinactive[3]; // font inactive
float decorinactive[3]; // decor inactive
float decorinactive2[3]; // inactive slider color 2
float button[3]; // button
float check[3]; // check
float radio[3]; // radio
float select[3]; // select
float select2[3]; // select pane
float slider[3]; // slider
float slider2[3]; // slider color 2
float edit[3]; // edit
float edit2[3]; // edit invalid
float cursor[3]; // edit cursor
};
typedef struct _mjuiThemeColor mjuiThemeColor;
typedef struct mjuiThemeColor_ mjuiThemeColor;
struct _mjuiItemSingle // check and button-related
{
int modifier; // 0: none, 1: control, 2: shift; 4: alt
int shortcut; // shortcut key; 0: undefined
//---------------------------------- mjuiItem ------------------------------------------------------
struct mjuiItemSingle_ { // check and button-related
int modifier; // 0: none, 1: control, 2: shift; 4: alt
int shortcut; // shortcut key; 0: undefined
};
struct _mjuiItemMulti // static, radio and select-related
{
int nelem; // number of elements in group
char name[mjMAXUIMULTI][mjMAXUINAME]; // element names
struct mjuiItemMulti_ { // static, radio and select-related
int nelem; // number of elements in group
char name[mjMAXUIMULTI][mjMAXUINAME]; // element names
};
struct _mjuiItemSlider // slider-related
{
double range[2]; // slider range
double divisions; // number of range divisions
struct mjuiItemSlider_ { // slider-related
double range[2]; // slider range
double divisions; // number of range divisions
};
struct _mjuiItemEdit // edit-related
{
int nelem; // number of elements in list
double range[mjMAXUIEDIT][2]; // element range (min>=max: ignore)
struct mjuiItemEdit_ { // edit-related
int nelem; // number of elements in list
double range[mjMAXUIEDIT][2]; // element range (min>=max: ignore)
};
struct _mjuiItem // UI item
{
// common properties
int type; // type (mjtItem)
char name[mjMAXUINAME]; // name
int state; // 0: disable, 1: enable, 2+: use predicate
void *pdata; // data pointer (type-specific)
int sectionid; // id of section containing item
int itemid; // id of item within section
struct mjuiItem_ { // UI item
// common properties
int type; // type (mjtItem)
char name[mjMAXUINAME]; // name
int state; // 0: disable, 1: enable, 2+: use predicate
void *pdata; // data pointer (type-specific)
int sectionid; // id of section containing item
int itemid; // id of item within section
// type-specific properties
union
{
struct _mjuiItemSingle single; // check and button
struct _mjuiItemMulti multi; // static, radio and select
struct _mjuiItemSlider slider; // slider
struct _mjuiItemEdit edit; // edit
};
// type-specific properties
union {
struct mjuiItemSingle_ single; // check and button
struct mjuiItemMulti_ multi; // static, radio and select
struct mjuiItemSlider_ slider; // slider
struct mjuiItemEdit_ edit; // edit
};
// internal
mjrRect rect; // rectangle occupied by item
// internal
mjrRect rect; // rectangle occupied by item
};
typedef struct _mjuiItem mjuiItem;
typedef struct mjuiItem_ mjuiItem;
struct _mjuiSection // UI section
{
// properties
char name[mjMAXUINAME]; // name
int state; // 0: closed, 1: open
int modifier; // 0: none, 1: control, 2: shift; 4: alt
int shortcut; // shortcut key; 0: undefined
int nitem; // number of items in use
mjuiItem item[mjMAXUIITEM]; // preallocated array of items
//---------------------------------- mjuiSection ---------------------------------------------------
// internal
mjrRect rtitle; // rectangle occupied by title
mjrRect rcontent; // rectangle occupied by content
struct mjuiSection_ { // UI section
// properties
char name[mjMAXUINAME]; // name
int state; // 0: closed, 1: open
int modifier; // 0: none, 1: control, 2: shift; 4: alt
int shortcut; // shortcut key; 0: undefined
int nitem; // number of items in use
mjuiItem item[mjMAXUIITEM]; // preallocated array of items
// internal
mjrRect rtitle; // rectangle occupied by title
mjrRect rcontent; // rectangle occupied by content
};
typedef struct _mjuiSection mjuiSection;
typedef struct mjuiSection_ mjuiSection;
struct _mjUI // entire UI
{
// constants set by user
mjuiThemeSpacing spacing; // UI theme spacing
mjuiThemeColor color; // UI theme color
mjfItemEnable predicate; // callback to set item state programmatically
void* userdata; // pointer to user data (passed to predicate)
int rectid; // index of this ui rectangle in mjuiState
int auxid; // aux buffer index of this ui
int radiocol; // number of radio columns (0 defaults to 2)
//---------------------------------- mjUI ----------------------------------------------------------
// UI sizes (framebuffer units)
int width; // width
int height; // current heigth
int maxheight; // height when all sections open
int scroll; // scroll from top of UI
struct mjUI_ { // entire UI
// constants set by user
mjuiThemeSpacing spacing; // UI theme spacing
mjuiThemeColor color; // UI theme color
mjfItemEnable predicate; // callback to set item state programmatically
void* userdata; // pointer to user data (passed to predicate)
int rectid; // index of this ui rectangle in mjuiState
int auxid; // aux buffer index of this ui
int radiocol; // number of radio columns (0 defaults to 2)
// mouse focus
int mousesect; // 0: none, -1: scroll, otherwise 1+section
int mouseitem; // item within section
int mousehelp; // help button down: print shortcuts
// UI sizes (framebuffer units)
int width; // width
int height; // current heigth
int maxheight; // height when all sections open
int scroll; // scroll from top of UI
// keyboard focus and edit
int editsect; // 0: none, otherwise 1+section
int edititem; // item within section
int editcursor; // cursor position
int editscroll; // horizontal scroll
char edittext[mjMAXUITEXT]; // current text
mjuiItem* editchanged; // pointer to changed edit in last mjui_event
// mouse focus
int mousesect; // 0: none, -1: scroll, otherwise 1+section
int mouseitem; // item within section
int mousehelp; // help button down: print shortcuts
// sections
int nsect; // number of sections in use
mjuiSection sect[mjMAXUISECT]; // preallocated array of sections
// keyboard focus and edit
int editsect; // 0: none, otherwise 1+section
int edititem; // item within section
int editcursor; // cursor position
int editscroll; // horizontal scroll
char edittext[mjMAXUITEXT]; // current text
mjuiItem* editchanged; // pointer to changed edit in last mjui_event
// sections
int nsect; // number of sections in use
mjuiSection sect[mjMAXUISECT]; // preallocated array of sections
};
typedef struct _mjUI mjUI;
typedef struct mjUI_ mjUI;
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
//---------------------------------- mjuiDef -------------------------------------------------------
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
};
typedef struct _mjuiDef mjuiDef;
typedef struct mjuiDef_ mjuiDef;
#endif // MUJOCO_MJUI_H_
Executable → Regular
+264 -261
View File
@@ -15,336 +15,339 @@
#ifndef MUJOCO_MJVISUALIZE_H_
#define MUJOCO_MJVISUALIZE_H_
#define mjNGROUP 6 // number of geom, site, joint groups with visflags
#define mjMAXOVERLAY 500 // maximum number of characters in overlay text
#define mjMAXLINE 100 // maximum number of lines per plot
#define mjMAXLINEPNT 1000 // maximum number points per line
#define mjMAXPLANEGRID 200 // maximum number of grid divisions for plane
#include "mjmodel.h"
#define mjNGROUP 6 // number of geom, site, joint groups with visflags
#define mjMAXOVERLAY 500 // maximum number of characters in overlay text
#define mjMAXLINE 100 // maximum number of lines per plot
#define mjMAXLINEPNT 1000 // maximum number points per line
#define mjMAXPLANEGRID 200 // maximum number of grid divisions for plane
typedef enum _mjtCatBit // bitflags for mjvGeom category
{
mjCAT_STATIC = 1, // model elements in body 0
mjCAT_DYNAMIC = 2, // model elements in all other bodies
mjCAT_DECOR = 4, // decorative geoms
mjCAT_ALL = 7 // select all categories
//---------------------------------- primitive types (mjt) -----------------------------------------
typedef enum mjtCatBit_ { // bitflags for mjvGeom category
mjCAT_STATIC = 1, // model elements in body 0
mjCAT_DYNAMIC = 2, // model elements in all other bodies
mjCAT_DECOR = 4, // decorative geoms
mjCAT_ALL = 7 // select all categories
} mjtCatBit;
typedef enum _mjtMouse // mouse interaction mode
{
mjMOUSE_NONE = 0, // no action
mjMOUSE_ROTATE_V, // rotate, vertical plane
mjMOUSE_ROTATE_H, // rotate, horizontal plane
mjMOUSE_MOVE_V, // move, vertical plane
mjMOUSE_MOVE_H, // move, horizontal plane
mjMOUSE_ZOOM, // zoom
mjMOUSE_SELECT // selection
typedef enum mjtMouse_ { // mouse interaction mode
mjMOUSE_NONE = 0, // no action
mjMOUSE_ROTATE_V, // rotate, vertical plane
mjMOUSE_ROTATE_H, // rotate, horizontal plane
mjMOUSE_MOVE_V, // move, vertical plane
mjMOUSE_MOVE_H, // move, horizontal plane
mjMOUSE_ZOOM, // zoom
mjMOUSE_SELECT // selection
} mjtMouse;
typedef enum _mjtPertBit // mouse perturbations
{
mjPERT_TRANSLATE = 1, // translation
mjPERT_ROTATE = 2 // rotation
typedef enum mjtPertBit_ { // mouse perturbations
mjPERT_TRANSLATE = 1, // translation
mjPERT_ROTATE = 2 // rotation
} mjtPertBit;
typedef enum _mjtCamera // abstract camera type
{
mjCAMERA_FREE = 0, // free camera
mjCAMERA_TRACKING, // tracking camera; uses trackbodyid
mjCAMERA_FIXED, // fixed camera; uses fixedcamid
mjCAMERA_USER // user is responsible for setting OpenGL camera
typedef enum mjtCamera_ { // abstract camera type
mjCAMERA_FREE = 0, // free camera
mjCAMERA_TRACKING, // tracking camera; uses trackbodyid
mjCAMERA_FIXED, // fixed camera; uses fixedcamid
mjCAMERA_USER // user is responsible for setting OpenGL camera
} mjtCamera;
typedef enum _mjtLabel // object labeling
{
mjLABEL_NONE = 0, // nothing
mjLABEL_BODY, // body labels
mjLABEL_JOINT, // joint labels
mjLABEL_GEOM, // geom labels
mjLABEL_SITE, // site labels
mjLABEL_CAMERA, // camera labels
mjLABEL_LIGHT, // light labels
mjLABEL_TENDON, // tendon labels
mjLABEL_ACTUATOR, // actuator labels
mjLABEL_CONSTRAINT, // constraint labels
mjLABEL_SKIN, // skin labels
mjLABEL_SELECTION, // selected object
mjLABEL_SELPNT, // coordinates of selection point
mjLABEL_CONTACTFORCE, // magnitude of contact force
typedef enum mjtLabel_ { // object labeling
mjLABEL_NONE = 0, // nothing
mjLABEL_BODY, // body labels
mjLABEL_JOINT, // joint labels
mjLABEL_GEOM, // geom labels
mjLABEL_SITE, // site labels
mjLABEL_CAMERA, // camera labels
mjLABEL_LIGHT, // light labels
mjLABEL_TENDON, // tendon labels
mjLABEL_ACTUATOR, // actuator labels
mjLABEL_CONSTRAINT, // constraint labels
mjLABEL_SKIN, // skin labels
mjLABEL_SELECTION, // selected object
mjLABEL_SELPNT, // coordinates of selection point
mjLABEL_CONTACTFORCE, // magnitude of contact force
mjNLABEL // number of label types
mjNLABEL // number of label types
} mjtLabel;
typedef enum _mjtFrame // frame visualization
{
mjFRAME_NONE = 0, // no frames
mjFRAME_BODY, // body frames
mjFRAME_GEOM, // geom frames
mjFRAME_SITE, // site frames
mjFRAME_CAMERA, // camera frames
mjFRAME_LIGHT, // light frames
mjFRAME_WORLD, // world frame
typedef enum mjtFrame_ { // frame visualization
mjFRAME_NONE = 0, // no frames
mjFRAME_BODY, // body frames
mjFRAME_GEOM, // geom frames
mjFRAME_SITE, // site frames
mjFRAME_CAMERA, // camera frames
mjFRAME_LIGHT, // light frames
mjFRAME_WORLD, // world frame
mjNFRAME // number of visualization frames
mjNFRAME // number of visualization frames
} mjtFrame;
typedef enum _mjtVisFlag // flags enabling model element visualization
{
mjVIS_CONVEXHULL = 0, // mesh convex hull
mjVIS_TEXTURE, // textures
mjVIS_JOINT, // joints
mjVIS_ACTUATOR, // actuators
mjVIS_CAMERA, // cameras
mjVIS_LIGHT, // lights
mjVIS_TENDON, // tendons
mjVIS_RANGEFINDER, // rangefinder sensors
mjVIS_CONSTRAINT, // point constraints
mjVIS_INERTIA, // equivalent inertia boxes
mjVIS_SCLINERTIA, // scale equivalent inertia boxes with mass
mjVIS_PERTFORCE, // perturbation force
mjVIS_PERTOBJ, // perturbation object
mjVIS_CONTACTPOINT, // contact points
mjVIS_CONTACTFORCE, // contact force
mjVIS_CONTACTSPLIT, // split contact force into normal and tanget
mjVIS_TRANSPARENT, // make dynamic geoms more transparent
mjVIS_AUTOCONNECT, // auto connect joints and body coms
mjVIS_COM, // center of mass
mjVIS_SELECT, // selection point
mjVIS_STATIC, // static bodies
mjVIS_SKIN, // skin
typedef enum mjtVisFlag_ { // flags enabling model element visualization
mjVIS_CONVEXHULL = 0, // mesh convex hull
mjVIS_TEXTURE, // textures
mjVIS_JOINT, // joints
mjVIS_ACTUATOR, // actuators
mjVIS_CAMERA, // cameras
mjVIS_LIGHT, // lights
mjVIS_TENDON, // tendons
mjVIS_RANGEFINDER, // rangefinder sensors
mjVIS_CONSTRAINT, // point constraints
mjVIS_INERTIA, // equivalent inertia boxes
mjVIS_SCLINERTIA, // scale equivalent inertia boxes with mass
mjVIS_PERTFORCE, // perturbation force
mjVIS_PERTOBJ, // perturbation object
mjVIS_CONTACTPOINT, // contact points
mjVIS_CONTACTFORCE, // contact force
mjVIS_CONTACTSPLIT, // split contact force into normal and tanget
mjVIS_TRANSPARENT, // make dynamic geoms more transparent
mjVIS_AUTOCONNECT, // auto connect joints and body coms
mjVIS_COM, // center of mass
mjVIS_SELECT, // selection point
mjVIS_STATIC, // static bodies
mjVIS_SKIN, // skin
mjNVISFLAG // number of visualization flags
mjNVISFLAG // number of visualization flags
} mjtVisFlag;
typedef enum _mjtRndFlag // flags enabling rendering effects
{
mjRND_SHADOW = 0, // shadows
mjRND_WIREFRAME, // wireframe
mjRND_REFLECTION, // reflections
mjRND_ADDITIVE, // additive transparency
mjRND_SKYBOX, // skybox
mjRND_FOG, // fog
mjRND_HAZE, // haze
mjRND_SEGMENT, // segmentation with random color
mjRND_IDCOLOR, // segmentation with segid color
typedef enum mjtRndFlag_ { // flags enabling rendering effects
mjRND_SHADOW = 0, // shadows
mjRND_WIREFRAME, // wireframe
mjRND_REFLECTION, // reflections
mjRND_ADDITIVE, // additive transparency
mjRND_SKYBOX, // skybox
mjRND_FOG, // fog
mjRND_HAZE, // haze
mjRND_SEGMENT, // segmentation with random color
mjRND_IDCOLOR, // segmentation with segid color
mjNRNDFLAG // number of rendering flags
mjNRNDFLAG // number of rendering flags
} mjtRndFlag;
typedef enum _mjtStereo // type of stereo rendering
{
mjSTEREO_NONE = 0, // no stereo; use left eye only
mjSTEREO_QUADBUFFERED, // quad buffered; revert to side-by-side if no hardware support
mjSTEREO_SIDEBYSIDE // side-by-side
typedef enum mjtStereo_ { // type of stereo rendering
mjSTEREO_NONE = 0, // no stereo; use left eye only
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
{
int select; // selected body id; non-positive: none
int skinselect; // selected skin id; negative: none
int active; // perturbation bitmask (mjtPertBit)
int active2; // secondary perturbation bitmask (mjtPertBit)
mjtNum refpos[3]; // desired position for selected object
mjtNum refquat[4]; // desired orientation for selected object
mjtNum localpos[3]; // selection point in object coordinates
mjtNum scale; // relative mouse motion-to-space scaling (set by initPerturb)
//---------------------------------- mjvPerturb ----------------------------------------------------
struct mjvPerturb_ { // object selection and perturbation
int select; // selected body id; non-positive: none
int skinselect; // selected skin id; negative: none
int active; // perturbation bitmask (mjtPertBit)
int active2; // secondary perturbation bitmask (mjtPertBit)
mjtNum refpos[3]; // desired position for selected object
mjtNum refquat[4]; // desired orientation for selected object
mjtNum localpos[3]; // selection point in object coordinates
mjtNum scale; // relative mouse motion-to-space scaling (set by initPerturb)
};
typedef struct _mjvPerturb mjvPerturb;
typedef struct mjvPerturb_ mjvPerturb;
struct _mjvCamera // abstract camera
{
// type and ids
int type; // camera type (mjtCamera)
int fixedcamid; // fixed camera id
int trackbodyid; // body id to track
//---------------------------------- mjvCamera -----------------------------------------------------
// abstract camera pose specification
mjtNum lookat[3]; // lookat point
mjtNum distance; // distance to lookat point or tracked body
mjtNum azimuth; // camera azimuth (deg)
mjtNum elevation; // camera elevation (deg)
struct mjvCamera_ { // abstract camera
// type and ids
int type; // camera type (mjtCamera)
int fixedcamid; // fixed camera id
int trackbodyid; // body id to track
// abstract camera pose specification
mjtNum lookat[3]; // lookat point
mjtNum distance; // distance to lookat point or tracked body
mjtNum azimuth; // camera azimuth (deg)
mjtNum elevation; // camera elevation (deg)
};
typedef struct _mjvCamera mjvCamera;
typedef struct mjvCamera_ mjvCamera;
struct _mjvGLCamera // OpenGL camera
{
// camera frame
float pos[3]; // position
float forward[3]; // forward direction
float up[3]; // up direction
//---------------------------------- mjvGLCamera ---------------------------------------------------
// camera projection
float frustum_center; // hor. center (left,right set to match aspect)
float frustum_bottom; // bottom
float frustum_top; // top
float frustum_near; // near
float frustum_far; // far
struct mjvGLCamera_ { // OpenGL camera
// camera frame
float pos[3]; // position
float forward[3]; // forward direction
float up[3]; // up direction
// camera projection
float frustum_center; // hor. center (left,right set to match aspect)
float frustum_bottom; // bottom
float frustum_top; // top
float frustum_near; // near
float frustum_far; // far
};
typedef struct _mjvGLCamera mjvGLCamera;
typedef struct mjvGLCamera_ mjvGLCamera;
struct _mjvGeom // abstract geom
{
// type info
int type; // geom type (mjtGeom)
int dataid; // mesh, hfield or plane id; -1: none
int objtype; // mujoco object type; mjOBJ_UNKNOWN for decor
int objid; // mujoco object id; -1 for decor
int category; // visual category
int texid; // texture id; -1: no texture
int texuniform; // uniform cube mapping
int texcoord; // mesh geom has texture coordinates
int segid; // segmentation id; -1: not shown
//---------------------------------- mjvGeom -------------------------------------------------------
// OpenGL info
float texrepeat[2]; // texture repetition for 2D mapping
float size[3]; // size parameters
float pos[3]; // Cartesian position
float mat[9]; // Cartesian orientation
float rgba[4]; // color and transparency
float emission; // emission coef
float specular; // specular coef
float shininess; // shininess coef
float reflectance; // reflectance coef
char label[100]; // text label
struct mjvGeom_ { // abstract geom
// type info
int type; // geom type (mjtGeom)
int dataid; // mesh, hfield or plane id; -1: none
int objtype; // mujoco object type; mjOBJ_UNKNOWN for decor
int objid; // mujoco object id; -1 for decor
int category; // visual category
int texid; // texture id; -1: no texture
int texuniform; // uniform cube mapping
int texcoord; // mesh geom has texture coordinates
int segid; // segmentation id; -1: not shown
// transparency rendering (set internally)
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
// OpenGL info
float texrepeat[2]; // texture repetition for 2D mapping
float size[3]; // size parameters
float pos[3]; // Cartesian position
float mat[9]; // Cartesian orientation
float rgba[4]; // color and transparency
float emission; // emission coef
float specular; // specular coef
float shininess; // shininess coef
float reflectance; // reflectance coef
char label[100]; // text label
// transparency rendering (set internally)
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;
typedef struct mjvGeom_ mjvGeom;
struct _mjvLight // OpenGL light
{
float pos[3]; // position rel. to body frame
float dir[3]; // direction rel. to body frame
float attenuation[3]; // OpenGL attenuation (quadratic model)
float cutoff; // OpenGL cutoff
float exponent; // OpenGL exponent
float ambient[3]; // ambient rgb (alpha=1)
float diffuse[3]; // diffuse rgb (alpha=1)
float specular[3]; // specular rgb (alpha=1)
mjtByte headlight; // headlight
mjtByte directional; // directional light
mjtByte castshadow; // does light cast shadows
//---------------------------------- mjvLight ------------------------------------------------------
struct mjvLight_ { // OpenGL light
float pos[3]; // position rel. to body frame
float dir[3]; // direction rel. to body frame
float attenuation[3]; // OpenGL attenuation (quadratic model)
float cutoff; // OpenGL cutoff
float exponent; // OpenGL exponent
float ambient[3]; // ambient rgb (alpha=1)
float diffuse[3]; // diffuse rgb (alpha=1)
float specular[3]; // specular rgb (alpha=1)
mjtByte headlight; // headlight
mjtByte directional; // directional light
mjtByte castshadow; // does light cast shadows
};
typedef struct _mjvLight mjvLight;
typedef struct mjvLight_ mjvLight;
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
mjtByte sitegroup[mjNGROUP]; // site visualization by group
mjtByte jointgroup[mjNGROUP]; // joint visualization by group
mjtByte tendongroup[mjNGROUP]; // tendon visualization by group
mjtByte actuatorgroup[mjNGROUP]; // actuator visualization by group
mjtByte flags[mjNVISFLAG]; // visualization flags (indexed by mjtVisFlag)
//---------------------------------- mjvOption -----------------------------------------------------
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
mjtByte sitegroup[mjNGROUP]; // site visualization by group
mjtByte jointgroup[mjNGROUP]; // joint visualization by group
mjtByte tendongroup[mjNGROUP]; // tendon visualization by group
mjtByte actuatorgroup[mjNGROUP]; // actuator visualization by group
mjtByte flags[mjNVISFLAG]; // visualization flags (indexed by mjtVisFlag)
};
typedef struct _mjvOption mjvOption;
typedef struct mjvOption_ mjvOption;
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
mjvGeom* geoms; // buffer for geoms
int* geomorder; // buffer for ordering geoms by distance to camera
//---------------------------------- mjvScene ------------------------------------------------------
// skin data
int nskin; // number of skins
int* skinfacenum; // number of faces in skin
int* skinvertadr; // address of skin vertices
int* skinvertnum; // number of vertices in skin
float* skinvert; // skin vertex data
float* skinnormal; // skin normal data
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
mjvGeom* geoms; // buffer for geoms
int* geomorder; // buffer for ordering geoms by distance to camera
// OpenGL lights
int nlight; // number of lights currently in buffer
mjvLight lights[8]; // buffer for lights
// skin data
int nskin; // number of skins
int* skinfacenum; // number of faces in skin
int* skinvertadr; // address of skin vertices
int* skinvertnum; // number of vertices in skin
float* skinvert; // skin vertex data
float* skinnormal; // skin normal data
// OpenGL cameras
mjvGLCamera camera[2]; // left and right camera
// OpenGL lights
int nlight; // number of lights currently in buffer
mjvLight lights[8]; // buffer for lights
// OpenGL model transformation
mjtByte enabletransform; // enable model transformation
float translate[3]; // model translation
float rotate[4]; // model quaternion rotation
float scale; // model scaling
// OpenGL cameras
mjvGLCamera camera[2]; // left and right camera
// OpenGL rendering effects
int stereo; // stereoscopic rendering (mjtStereo)
mjtByte flags[mjNRNDFLAG]; // rendering flags (indexed by mjtRndFlag)
// OpenGL model transformation
mjtByte enabletransform; // enable model transformation
float translate[3]; // model translation
float rotate[4]; // model quaternion rotation
float scale; // model scaling
// framing
int framewidth; // frame pixel width; 0: disable framing
float framergb[3]; // frame color
// OpenGL rendering effects
int stereo; // stereoscopic rendering (mjtStereo)
mjtByte flags[mjNRNDFLAG]; // rendering flags (indexed by mjtRndFlag)
// framing
int framewidth; // frame pixel width; 0: disable framing
float framergb[3]; // frame color
};
typedef struct _mjvScene mjvScene;
typedef struct mjvScene_ mjvScene;
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)
int flg_extend; // automatically extend axis ranges to fit data
int flg_barplot; // isolated line segments (i.e. GL_LINES)
int flg_selection; // vertical selection line
int flg_symmetric; // symmetric y-axis
//---------------------------------- mjvFigure -----------------------------------------------------
// style settings
float linewidth; // line width
float gridwidth; // grid line width
int gridsize[2]; // number of grid points in (x,y)
float gridrgb[3]; // grid line rgb
float figurergba[4]; // figure color and alpha
float panergba[4]; // pane color and alpha
float legendrgba[4]; // legend color and alpha
float textrgb[3]; // text color
float linergb[mjMAXLINE][3]; // line colors
float range[2][2]; // axis ranges; (min>=max) automatic
char xformat[20]; // x-tick label format for sprintf
char yformat[20]; // y-tick label format for sprintf
char minwidth[20]; // string used to determine min y-tick width
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)
int flg_extend; // automatically extend axis ranges to fit data
int flg_barplot; // isolated line segments (i.e. GL_LINES)
int flg_selection; // vertical selection line
int flg_symmetric; // symmetric y-axis
// text labels
char title[1000]; // figure title; subplots separated with 2+ spaces
char xlabel[100]; // x-axis label
char linename[mjMAXLINE][100]; // line names for legend
// style settings
float linewidth; // line width
float gridwidth; // grid line width
int gridsize[2]; // number of grid points in (x,y)
float gridrgb[3]; // grid line rgb
float figurergba[4]; // figure color and alpha
float panergba[4]; // pane color and alpha
float legendrgba[4]; // legend color and alpha
float textrgb[3]; // text color
float linergb[mjMAXLINE][3]; // line colors
float range[2][2]; // axis ranges; (min>=max) automatic
char xformat[20]; // x-tick label format for sprintf
char yformat[20]; // y-tick label format for sprintf
char minwidth[20]; // string used to determine min y-tick width
// dynamic settings
int legendoffset; // number of lines to offset legend
int subplot; // selected subplot (for title rendering)
int highlight[2]; // if point is in legend rect, highlight line
int highlightid; // if id>=0 and no point, highlight id
float selection; // selection line x-value
// text labels
char title[1000]; // figure title; subplots separated with 2+ spaces
char xlabel[100]; // x-axis label
char linename[mjMAXLINE][100]; // line names for legend
// line data
int linepnt[mjMAXLINE]; // number of points in line; (0) disable
float linedata[mjMAXLINE][2*mjMAXLINEPNT]; // line data (x,y)
// dynamic settings
int legendoffset; // number of lines to offset legend
int subplot; // selected subplot (for title rendering)
int highlight[2]; // if point is in legend rect, highlight line
int highlightid; // if id>=0 and no point, highlight id
float selection; // selection line x-value
// output from renderer
int xaxispixel[2]; // range of x-axis in pixels
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
// line data
int linepnt[mjMAXLINE]; // number of points in line; (0) disable
float linedata[mjMAXLINE][2*mjMAXLINEPNT]; // line data (x,y)
// output from renderer
int xaxispixel[2]; // range of x-axis in pixels
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;
typedef struct mjvFigure_ mjvFigure;
#endif // MUJOCO_MJVISUALIZE_H_
Executable → Regular
+32 -1
View File
@@ -18,7 +18,7 @@
//-------------------------------- mjOption ---------------------------------------------
// scalar fields of mjOption
#define MJOPTION_SCALARS \
#define MJOPTION_FLOATS \
X( mjtNum, timestep ) \
X( mjtNum, apirate ) \
X( mjtNum, impratio ) \
@@ -28,6 +28,9 @@
X( mjtNum, density ) \
X( mjtNum, viscosity ) \
X( mjtNum, o_margin ) \
#define MJOPTION_INTS \
X( int, integrator ) \
X( int, collision ) \
X( int, cone ) \
@@ -40,6 +43,11 @@
X( int, enableflags )
#define MJOPTION_SCALARS \
MJOPTION_FLOATS \
MJOPTION_INTS
// vector fields of mjOption
#define MJOPTION_VECTORS \
X( gravity, 3 ) \
@@ -113,6 +121,23 @@
X( nbuffer )
// define symbols needed in MJMODEL_POINTERS (corresponding to number of columns)
#define MJMODEL_POINTERS_PREAMBLE( m ) \
int nuser_body = m->nuser_body; \
int nuser_jnt = m->nuser_jnt; \
int nuser_geom = m->nuser_geom; \
int nuser_site = m->nuser_site; \
int nuser_cam = m->nuser_cam; \
int nuser_tendon = m->nuser_tendon; \
int nuser_actuator = m->nuser_actuator; \
int nuser_sensor = m->nuser_sensor; \
int nq = m->nq; \
int nv = m->nv; \
int na = m->na; \
int nmocap3 = 3*m->nmocap; \
int nmocap4 = 4*m->nmocap;
// pointer fields of mjModel
#define MJMODEL_POINTERS \
X( mjtNum, qpos0, nq, 1 ) \
@@ -386,6 +411,12 @@
//-------------------------------- mjData -----------------------------------------------
// define symbols needed in MJDATA_POINTERS (corresponding to number of columns)
#define MJDATA_POINTERS_PREAMBLE( m ) \
int nv = m->nv; \
int njmax = m->njmax;
// pointer fields of mjData
#define MJDATA_POINTERS \
X( mjtNum, qpos, nq, 1 ) \
Executable → Regular
+62 -65
View File
@@ -15,27 +15,16 @@
#ifndef MUJOCO_MUJOCO_H_
#define MUJOCO_MUJOCO_H_
// cross-platform import
#if defined(MJ_STATIC)
#define MJAPI
#else
#if defined(_WIN32)
#define MJAPI __declspec(dllimport)
#else
#define MJAPI
#endif
#endif
#include "mujoco_export.h"
// this is a C-API
#if defined(__cplusplus)
extern "C"
{
extern "C" {
#endif
// header version; should match the library version as returned by mj_version()
#define mjVERSION_HEADER 210
#define mjVERSION_HEADER 211
// needed to define size_t, fabs and log10
#include "stdlib.h"
@@ -89,7 +78,7 @@ MJAPI extern const char* mjVISSTRING[mjNVISFLAG][3];
MJAPI extern const char* mjRNDSTRING[mjNRNDFLAG][3];
//---------------------- Activation -----------------------------------------------------
//---------------------------------- Activation ----------------------------------------------------
// Return 1 (for backward compatibility).
MJAPI int mj_activate(const char* filename);
@@ -98,7 +87,7 @@ MJAPI int mj_activate(const char* filename);
MJAPI void mj_deactivate(void);
//---------------------- Virtual file system --------------------------------------------
//---------------------------------- Virtual file system -------------------------------------------
// Initialize VFS to empty (no deallocation).
MJAPI void mj_defaultVFS(mjVFS* vfs);
@@ -119,7 +108,7 @@ MJAPI int mj_deleteFileVFS(mjVFS* vfs, const char* filename);
MJAPI void mj_deleteVFS(mjVFS* vfs);
//---------------------- Parse and compile ----------------------------------------------
//---------------------------------- Parse and compile ---------------------------------------------
// Parse XML file in MJCF or URDF format, compile it, return low-level model.
// If vfs is not NULL, look up files in vfs before reading from disk.
@@ -140,7 +129,7 @@ MJAPI int mj_printSchema(const char* filename, char* buffer, int buffer_sz,
int flg_html, int flg_pad);
//---------------------- Main simulation ------------------------------------------------
//---------------------------------- Main simulation -----------------------------------------------
// Advance simulation, use control callback to obtain external force and control.
MJAPI void mj_step(const mjModel* m, mjData* d);
@@ -166,7 +155,7 @@ MJAPI void mj_inverseSkip(const mjModel* m, mjData* d,
int skipstage, int skipsensor);
//---------------------- Initialization -------------------------------------------------
//---------------------------------- Initialization ------------------------------------------------
// Set default options for length range computation.
MJAPI void mj_defaultLROpt(mjLROpt* opt);
@@ -228,7 +217,12 @@ MJAPI int mj_setLengthRange(mjModel* m, mjData* d, int index,
const mjLROpt* opt, char* error, int error_sz);
//---------------------- Printing -------------------------------------------------------
//---------------------------------- Printing ------------------------------------------------------
// Print mjModel to text file, specifying format.
// float_format_str must be a valid printf-style format string for a single float value.
MJAPI void mj_printFormattedModel(const mjModel* m, const char* filename,
const char* float_format_str);
// Print model to text file.
MJAPI void mj_printModel(const mjModel* m, const char* filename);
@@ -245,7 +239,7 @@ MJAPI void mju_printMatSparse(const mjtNum* mat, int nr,
const int* colind);
//---------------------- Components -----------------------------------------------------
//---------------------------------- Components ----------------------------------------------------
// Run position-dependent computations.
MJAPI void mj_fwdPosition(const mjModel* m, mjData* d);
@@ -281,7 +275,7 @@ MJAPI void mj_invConstraint(const mjModel* m, mjData* d);
MJAPI void mj_compareFwdInv(const mjModel* m, mjData* d);
//---------------------- Sub components -------------------------------------------------
//---------------------------------- Sub components ------------------------------------------------
// Evaluate position-dependent sensors.
MJAPI void mj_sensorPos(const mjModel* m, mjData* d);
@@ -367,7 +361,7 @@ MJAPI void mj_constraintUpdate(const mjModel* m, mjData* d, const mjtNum* jar,
mjtNum* cost, int flg_coneHessian);
//---------------------- Support --------------------------------------------------------
//---------------------------------- Support -------------------------------------------------------
// Add contact to d->contact list; return 0 if success; 1 if buffer full.
MJAPI int mj_addContact(const mjModel* m, mjData* d, const mjContact* con);
@@ -473,8 +467,11 @@ MJAPI void mj_setTotalmass(mjModel* m, mjtNum newmass);
// Return version number: 1.0.2 is encoded as 102.
MJAPI int mj_version(void);
// Return the current version of MuJoCo as a null-terminated string.
MJAPI const char* mj_versionString();
//---------------------- Ray collisions -------------------------------------------------
//---------------------------------- Ray collisions ------------------------------------------------
// Intersect ray (pnt+x*vec, x>=0) with visible geoms, except geoms in bodyexclude.
// Return geomid and distance (x) to nearest surface, or -1 if no intersection.
@@ -500,7 +497,7 @@ MJAPI mjtNum mju_raySkin(int nface, int nvert, const int* face, const float* ver
const mjtNum* pnt, const mjtNum* vec, int* vertid);
//---------------------- Interaction ----------------------------------------------------
//---------------------------------- Interaction ---------------------------------------------------
// Set default camera.
MJAPI void mjv_defaultCamera(mjvCamera* cam);
@@ -563,7 +560,7 @@ MJAPI int mjv_select(const mjModel* m, const mjData* d, const mjvOption* vopt,
const mjvScene* scn, mjtNum* selpnt, int* geomid, int* skinid);
//---------------------- Visualization --------------------------------------------------
//---------------------------------- Visualization -------------------------------------------------
// Set default visualization options.
MJAPI void mjv_defaultOption(mjvOption* opt);
@@ -608,7 +605,7 @@ MJAPI void mjv_updateCamera(const mjModel* m, mjData* d, mjvCamera* cam, mjvScen
MJAPI void mjv_updateSkin(const mjModel* m, mjData* d, mjvScene* scn);
//---------------------- OpenGL rendering -----------------------------------------------
//---------------------------------- OpenGL rendering ----------------------------------------------
// Set default mjrContext.
MJAPI void mjr_defaultContext(mjrContext* con);
@@ -680,7 +677,7 @@ MJAPI void mjr_rectangle(mjrRect viewport, float r, float g, float b, float a);
// Draw rectangle with centered text.
MJAPI void mjr_label(mjrRect viewport, int font, const char* txt,
float r, float g, float b, float a, float rt, float gt, float bt,
const mjrContext* con);
const mjrContext* con);
// Draw 2D figure.
MJAPI void mjr_figure(mjrRect viewport, mjvFigure* fig, const mjrContext* con);
@@ -698,7 +695,7 @@ MJAPI int mjr_getError(void);
MJAPI int mjr_findRect(int x, int y, int nrect, const mjrRect* rect);
//---------------------- UI framework ---------------------------------------------------
//---------------------------------- UI framework --------------------------------------------------
// Get builtin UI theme spacing (ind: 0-1).
MJAPI mjuiThemeSpacing mjui_themeSpacing(int ind);
@@ -726,7 +723,7 @@ MJAPI mjuiItem* mjui_event(mjUI* ui, mjuiState* state, const mjrContext* con);
MJAPI void mjui_render(mjUI* ui, const mjuiState* state, const mjrContext* con);
//---------------------- Error and memory -----------------------------------------------
//---------------------------------- Error and memory ----------------------------------------------
// Main error function; does not return to caller.
MJAPI void mju_error(const char* msg);
@@ -762,48 +759,48 @@ MJAPI void mj_warning(mjData* d, int warning, int info);
MJAPI void mju_writeLog(const char* type, const char* msg);
//---------------------- Standard math --------------------------------------------------
//---------------------------------- Standard math -------------------------------------------------
#define mjMAX(a,b) (((a) > (b)) ? (a) : (b))
#define mjMIN(a,b) (((a) < (b)) ? (a) : (b))
#ifdef mjUSEDOUBLE
#define mju_sqrt sqrt
#define mju_exp exp
#define mju_sin sin
#define mju_cos cos
#define mju_tan tan
#define mju_asin asin
#define mju_acos acos
#define mju_atan2 atan2
#define mju_tanh tanh
#define mju_pow pow
#define mju_abs fabs
#define mju_log log
#define mju_log10 log10
#define mju_floor floor
#define mju_ceil ceil
#define mju_sqrt sqrt
#define mju_exp exp
#define mju_sin sin
#define mju_cos cos
#define mju_tan tan
#define mju_asin asin
#define mju_acos acos
#define mju_atan2 atan2
#define mju_tanh tanh
#define mju_pow pow
#define mju_abs fabs
#define mju_log log
#define mju_log10 log10
#define mju_floor floor
#define mju_ceil ceil
#else
#define mju_sqrt sqrtf
#define mju_exp expf
#define mju_sin sinf
#define mju_cos cosf
#define mju_tan tanf
#define mju_asin asinf
#define mju_acos acosf
#define mju_atan2 atan2f
#define mju_tanh tanhf
#define mju_pow powf
#define mju_abs fabsf
#define mju_log logf
#define mju_log10 log10f
#define mju_floor floorf
#define mju_ceil ceilf
#define mju_sqrt sqrtf
#define mju_exp expf
#define mju_sin sinf
#define mju_cos cosf
#define mju_tan tanf
#define mju_asin asinf
#define mju_acos acosf
#define mju_atan2 atan2f
#define mju_tanh tanhf
#define mju_pow powf
#define mju_abs fabsf
#define mju_log logf
#define mju_log10 log10f
#define mju_floor floorf
#define mju_ceil ceilf
#endif
//------------------------------ Vector math --------------------------------------------
//---------------------------------- Vector math ---------------------------------------------------
// Set res = 0.
MJAPI void mju_zero3(mjtNum res[3]);
@@ -940,7 +937,7 @@ MJAPI void mju_transformSpatial(mjtNum res[6], const mjtNum vec[6], int flg_forc
const mjtNum rotnew2old[9]);
//---------------------- Quaternions ----------------------------------------------------
//---------------------------------- Quaternions ---------------------------------------------------
// Rotate vector by quaternion.
MJAPI void mju_rotVecQuat(mjtNum res[3], const mjtNum vec[3], const mjtNum quat[4]);
@@ -979,7 +976,7 @@ MJAPI void mju_quatIntegrate(mjtNum quat[4], const mjtNum vel[3], mjtNum scale);
MJAPI void mju_quatZ2Vec(mjtNum quat[4], const mjtNum vec[3]);
//---------------------- Poses ----------------------------------------------------------
//---------------------------------- Poses ---------------------------------------------------------
// Multiply two poses.
MJAPI void mju_mulPose(mjtNum posres[3], mjtNum quatres[4],
@@ -995,7 +992,7 @@ MJAPI void mju_trnVecPose(mjtNum res[3], const mjtNum pos[3], const mjtNum quat[
const mjtNum vec[3]);
//---------------------- Decompositions --------------------------------------------------
//--------------------------------- Decompositions -------------------------------------------------
// Cholesky decomposition: mat = L*L'; return rank.
MJAPI int mju_cholFactor(mjtNum* mat, int n, mjtNum mindiag);
+47
View File
@@ -0,0 +1,47 @@
// Copyright 2021 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_MUJOCO_EXPORT_H_
#define MUJOCO_MUJOCO_EXPORT_H_
#if defined _WIN32 || defined __CYGWIN__
#define MUJOCO_HELPER_DLL_IMPORT __declspec(dllimport)
#define MUJOCO_HELPER_DLL_EXPORT __declspec(dllexport)
#define MUJOCO_HELPER_DLL_LOCAL
#else
#if __GNUC__ >= 4
#define MUJOCO_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
#define MUJOCO_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
#define MUJOCO_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden")))
#else
#define MUJOCO_HELPER_DLL_IMPORT
#define MUJOCO_HELPER_DLL_EXPORT
#define MUJOCO_HELPER_DLL_LOCAL
#endif
#endif
#ifdef MJ_STATIC
// static library
#define MJAPI
#define MJLOCAL
#else
#ifdef MUJOCO_DLL_EXPORTS
#define MJAPI MUJOCO_HELPER_DLL_EXPORT
#else
#define MJAPI MUJOCO_HELPER_DLL_IMPORT
#endif
#define MJLOCAL MUJOCO_HELPER_DLL_LOCAL
#endif
#endif // MUJOCO_MUJOCO_EXPORT_H_