Initial open sourcing of MuJoCo.
PiperOrigin-RevId: 450374687 Change-Id: Ie3225a46ce095fc28ae8e63c326a640261f562bb
This commit is contained in:
committed by
Copybara-Service
parent
0e5d062302
commit
1913a02b40
@@ -15,8 +15,8 @@
|
||||
#ifndef MUJOCO_MJDATA_H_
|
||||
#define MUJOCO_MJDATA_H_
|
||||
|
||||
#include <mjtnum.h>
|
||||
#include <mjmodel.h>
|
||||
#include <mujoco/mjtnum.h>
|
||||
#include <mujoco/mjmodel.h>
|
||||
|
||||
//---------------------------------- primitive types (mjt) -----------------------------------------
|
||||
|
||||
@@ -293,11 +293,11 @@ struct mjData_ {
|
||||
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)
|
||||
mjtNum* qfrc_smooth; // net unconstrained force (nv x 1)
|
||||
mjtNum* qacc_smooth; // 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_b; // linear cost term: J*qacc_smooth - 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)
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef MUJOCO_MJMODEL_H_
|
||||
#define MUJOCO_MJMODEL_H_
|
||||
|
||||
#include <mjtnum.h>
|
||||
#include <mujoco/mjtnum.h>
|
||||
|
||||
// global constants
|
||||
#define mjPI 3.14159265358979323846
|
||||
@@ -68,9 +68,8 @@ typedef enum mjtEnableBit_ { // enable optional feature bitflags
|
||||
mjENBL_ENERGY = 1<<1, // energy computation
|
||||
mjENBL_FWDINV = 1<<2, // record solver statistics
|
||||
mjENBL_SENSORNOISE = 1<<3, // add noise to sensor data
|
||||
|
||||
// experimental features:
|
||||
mjENBL_MULTICCD = 1<<30, // multi-point convex collision detection
|
||||
mjENBL_MULTICCD = 1<<4, // multi-point convex collision detection
|
||||
|
||||
mjNENABLE = 5 // number of enable flags
|
||||
} mjtEnableBit;
|
||||
@@ -833,11 +832,13 @@ struct mjModel_ {
|
||||
int* actuator_group; // group for visibility (nu x 1)
|
||||
mjtByte* actuator_ctrllimited; // is control limited (nu x 1)
|
||||
mjtByte* actuator_forcelimited;// is force limited (nu x 1)
|
||||
mjtByte* actuator_actlimited; // is activation limited (nu x 1)
|
||||
mjtNum* actuator_dynprm; // dynamics parameters (nu x mjNDYN)
|
||||
mjtNum* actuator_gainprm; // gain parameters (nu x mjNGAIN)
|
||||
mjtNum* actuator_biasprm; // bias parameters (nu x mjNBIAS)
|
||||
mjtNum* actuator_ctrlrange; // range of controls (nu x 2)
|
||||
mjtNum* actuator_forcerange; // range of forces (nu x 2)
|
||||
mjtNum* actuator_actrange; // range of activations (nu x 2)
|
||||
mjtNum* actuator_gear; // scale length and transmitted force (nu x 6)
|
||||
mjtNum* actuator_cranklength; // crank length for slider-crank (nu x 1)
|
||||
mjtNum* actuator_acc0; // acceleration from unit force in qpos0 (nu x 1)
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef MUJOCO_MJRENDER_H_
|
||||
#define MUJOCO_MJRENDER_H_
|
||||
|
||||
#include <mjmodel.h>
|
||||
#include <mujoco/mjmodel.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef MUJOCO_MJUI_H_
|
||||
#define MUJOCO_MJUI_H_
|
||||
|
||||
#include <mjrender.h>
|
||||
#include <mujoco/mjrender.h>
|
||||
|
||||
#define mjMAXUISECT 10 // maximum number of sections
|
||||
#define mjMAXUIITEM 80 // maximum number of items per section
|
||||
@@ -15,8 +15,8 @@
|
||||
#ifndef MUJOCO_MJVISUALIZE_H_
|
||||
#define MUJOCO_MJVISUALIZE_H_
|
||||
|
||||
#include <mjtnum.h>
|
||||
#include <mjmodel.h>
|
||||
#include <mujoco/mjtnum.h>
|
||||
#include <mujoco/mjmodel.h>
|
||||
|
||||
#define mjNGROUP 6 // number of geom, site, joint groups with visflags
|
||||
#define mjMAXLIGHT 100 // maximum number of lights in a scene
|
||||
@@ -20,28 +20,28 @@
|
||||
|
||||
// scalar fields of mjOption
|
||||
#define MJOPTION_FLOATS \
|
||||
X( mjtNum, timestep ) \
|
||||
X( mjtNum, apirate ) \
|
||||
X( mjtNum, impratio ) \
|
||||
X( mjtNum, tolerance ) \
|
||||
X( mjtNum, timestep ) \
|
||||
X( mjtNum, apirate ) \
|
||||
X( mjtNum, impratio ) \
|
||||
X( mjtNum, tolerance ) \
|
||||
X( mjtNum, noslip_tolerance ) \
|
||||
X( mjtNum, mpr_tolerance ) \
|
||||
X( mjtNum, density ) \
|
||||
X( mjtNum, viscosity ) \
|
||||
X( mjtNum, o_margin ) \
|
||||
X( mjtNum, mpr_tolerance ) \
|
||||
X( mjtNum, density ) \
|
||||
X( mjtNum, viscosity ) \
|
||||
X( mjtNum, o_margin ) \
|
||||
|
||||
|
||||
#define MJOPTION_INTS \
|
||||
X( int, integrator ) \
|
||||
X( int, collision ) \
|
||||
X( int, cone ) \
|
||||
X( int, jacobian ) \
|
||||
X( int, solver ) \
|
||||
X( int, iterations ) \
|
||||
X( int, integrator ) \
|
||||
X( int, collision ) \
|
||||
X( int, cone ) \
|
||||
X( int, jacobian ) \
|
||||
X( int, solver ) \
|
||||
X( int, iterations ) \
|
||||
X( int, noslip_iterations ) \
|
||||
X( int, mpr_iterations ) \
|
||||
X( int, disableflags ) \
|
||||
X( int, enableflags )
|
||||
X( int, mpr_iterations ) \
|
||||
X( int, disableflags ) \
|
||||
X( int, enableflags )
|
||||
|
||||
|
||||
#define MJOPTION_SCALARS \
|
||||
@@ -351,11 +351,13 @@
|
||||
X( int, actuator_group, nu, 1 ) \
|
||||
X( mjtByte, actuator_ctrllimited, nu, 1 ) \
|
||||
X( mjtByte, actuator_forcelimited, nu, 1 ) \
|
||||
X( mjtByte, actuator_actlimited, nu, 1 ) \
|
||||
X( mjtNum, actuator_dynprm, nu, mjNDYN ) \
|
||||
X( mjtNum, actuator_gainprm, nu, mjNGAIN ) \
|
||||
X( mjtNum, actuator_biasprm, nu, mjNBIAS ) \
|
||||
X( mjtNum, actuator_ctrlrange, nu, 2 ) \
|
||||
X( mjtNum, actuator_forcerange, nu, 2 ) \
|
||||
X( mjtNum, actuator_actrange, nu, 2 ) \
|
||||
X( mjtNum, actuator_gear, nu, 6 ) \
|
||||
X( mjtNum, actuator_cranklength, nu, 1 ) \
|
||||
X( mjtNum, actuator_acc0, nu, 1 ) \
|
||||
@@ -508,8 +510,8 @@
|
||||
X( mjtNum, subtree_angmom, nbody, 3 ) \
|
||||
X( mjtNum, actuator_force, nu, 1 ) \
|
||||
X( mjtNum, qfrc_actuator, nv, 1 ) \
|
||||
X( mjtNum, qfrc_unc, nv, 1 ) \
|
||||
X( mjtNum, qacc_unc, nv, 1 ) \
|
||||
X( mjtNum, qfrc_smooth, nv, 1 ) \
|
||||
X( mjtNum, qacc_smooth, nv, 1 ) \
|
||||
X( mjtNum, efc_b, njmax, 1 ) \
|
||||
X( mjtNum, efc_force, njmax, 1 ) \
|
||||
X( int, efc_state, njmax, 1 ) \
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef MUJOCO_MUJOCO_H_
|
||||
#define MUJOCO_MUJOCO_H_
|
||||
|
||||
#include <mjexport.h>
|
||||
#include <mujoco/mjexport.h>
|
||||
|
||||
|
||||
// this is a C-API
|
||||
@@ -24,7 +24,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// header version; should match the library version as returned by mj_version()
|
||||
#define mjVERSION_HEADER 215
|
||||
#define mjVERSION_HEADER 220
|
||||
|
||||
// needed to define size_t, fabs and log10
|
||||
#include "stdlib.h"
|
||||
@@ -32,12 +32,12 @@ extern "C" {
|
||||
|
||||
|
||||
// type definitions
|
||||
#include <mjdata.h>
|
||||
#include <mjmodel.h>
|
||||
#include <mjrender.h>
|
||||
#include <mjtnum.h>
|
||||
#include <mjui.h>
|
||||
#include <mjvisualize.h>
|
||||
#include <mujoco/mjdata.h>
|
||||
#include <mujoco/mjmodel.h>
|
||||
#include <mujoco/mjrender.h>
|
||||
#include <mujoco/mjtnum.h>
|
||||
#include <mujoco/mjui.h>
|
||||
#include <mujoco/mjvisualize.h>
|
||||
|
||||
|
||||
// macros
|
||||
@@ -139,12 +139,10 @@ MJAPI void mj_forward(const mjModel* m, mjData* d);
|
||||
MJAPI void mj_inverse(const mjModel* m, mjData* d);
|
||||
|
||||
// Forward dynamics with skip; skipstage is mjtStage.
|
||||
MJAPI void mj_forwardSkip(const mjModel* m, mjData* d,
|
||||
int skipstage, int skipsensor);
|
||||
MJAPI void mj_forwardSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor);
|
||||
|
||||
// Inverse dynamics with skip; skipstage is mjtStage.
|
||||
MJAPI void mj_inverseSkip(const mjModel* m, mjData* d,
|
||||
int skipstage, int skipsensor);
|
||||
MJAPI void mj_inverseSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor);
|
||||
|
||||
|
||||
//---------------------------------- Initialization ------------------------------------------------
|
||||
@@ -215,8 +213,7 @@ MJAPI int mj_setLengthRange(mjModel* m, mjData* d, int index,
|
||||
|
||||
// Print mjModel to text file, specifying format.
|
||||
// float_format 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);
|
||||
MJAPI void mj_printFormattedModel(const mjModel* m, const char* filename, const char* float_format);
|
||||
|
||||
// Print model to text file.
|
||||
MJAPI void mj_printModel(const mjModel* m, const char* filename);
|
||||
@@ -234,8 +231,7 @@ MJAPI void mju_printMat(const mjtNum* mat, int nr, int nc);
|
||||
|
||||
// Print sparse matrix to screen.
|
||||
MJAPI void mju_printMatSparse(const mjtNum* mat, int nr,
|
||||
const int* rownnz, const int* rowadr,
|
||||
const int* colind);
|
||||
const int* rownnz, const int* rowadr, const int* colind);
|
||||
|
||||
|
||||
//---------------------------------- Components ----------------------------------------------------
|
||||
@@ -246,7 +242,7 @@ MJAPI void mj_fwdPosition(const mjModel* m, mjData* d);
|
||||
// Run velocity-dependent computations.
|
||||
MJAPI void mj_fwdVelocity(const mjModel* m, mjData* d);
|
||||
|
||||
// Compute actuator force qfrc_actuation.
|
||||
// Compute actuator force qfrc_actuator.
|
||||
MJAPI void mj_fwdActuation(const mjModel* m, mjData* d);
|
||||
|
||||
// Add up all non-constraint forces, compute qacc_unc.
|
||||
@@ -375,35 +371,29 @@ MJAPI int mj_isSparse(const mjModel* m);
|
||||
MJAPI int mj_isDual(const mjModel* m);
|
||||
|
||||
// Multiply dense or sparse constraint Jacobian by vector.
|
||||
MJAPI void mj_mulJacVec(const mjModel* m, mjData* d,
|
||||
mjtNum* res, const mjtNum* vec);
|
||||
MJAPI void mj_mulJacVec(const mjModel* m, mjData* d, mjtNum* res, const mjtNum* vec);
|
||||
|
||||
// Multiply dense or sparse constraint Jacobian transpose by vector.
|
||||
MJAPI void mj_mulJacTVec(const mjModel* m, mjData* d, mjtNum* res, const mjtNum* vec);
|
||||
|
||||
// Compute 3/6-by-nv end-effector Jacobian of global point attached to given body.
|
||||
MJAPI void mj_jac(const mjModel* m, const mjData* d,
|
||||
mjtNum* jacp, mjtNum* jacr, const mjtNum point[3], int body);
|
||||
MJAPI void mj_jac(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr,
|
||||
const mjtNum point[3], int body);
|
||||
|
||||
// Compute body frame end-effector Jacobian.
|
||||
MJAPI void mj_jacBody(const mjModel* m, const mjData* d,
|
||||
mjtNum* jacp, mjtNum* jacr, int body);
|
||||
MJAPI void mj_jacBody(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr, int body);
|
||||
|
||||
// Compute body center-of-mass end-effector Jacobian.
|
||||
MJAPI void mj_jacBodyCom(const mjModel* m, const mjData* d,
|
||||
mjtNum* jacp, mjtNum* jacr, int body);
|
||||
MJAPI void mj_jacBodyCom(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr, int body);
|
||||
|
||||
// Compute geom end-effector Jacobian.
|
||||
MJAPI void mj_jacGeom(const mjModel* m, const mjData* d,
|
||||
mjtNum* jacp, mjtNum* jacr, int geom);
|
||||
MJAPI void mj_jacGeom(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr, int geom);
|
||||
|
||||
// Compute site end-effector Jacobian.
|
||||
MJAPI void mj_jacSite(const mjModel* m, const mjData* d,
|
||||
mjtNum* jacp, mjtNum* jacr, int site);
|
||||
MJAPI void mj_jacSite(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* jacr, int site);
|
||||
|
||||
// Compute translation end-effector Jacobian of point, and rotation Jacobian of axis.
|
||||
MJAPI void mj_jacPointAxis(const mjModel* m, mjData* d,
|
||||
mjtNum* jacPoint, mjtNum* jacAxis,
|
||||
MJAPI void mj_jacPointAxis(const mjModel* m, mjData* d, mjtNum* jacPoint, mjtNum* jacAxis,
|
||||
const mjtNum point[3], const mjtNum axis[3], int body);
|
||||
|
||||
// Get id of object with specified name, return -1 if not found; type is mjtObj.
|
||||
@@ -423,12 +413,10 @@ MJAPI void mj_mulM2(const mjModel* m, const mjData* d, mjtNum* res, const mjtNum
|
||||
|
||||
// Add inertia matrix to destination matrix.
|
||||
// Destination can be sparse uncompressed, or dense when all int* are NULL
|
||||
MJAPI void mj_addM(const mjModel* m, mjData* d, mjtNum* dst,
|
||||
int* rownnz, int* rowadr, int* colind);
|
||||
MJAPI void mj_addM(const mjModel* m, mjData* d, mjtNum* dst, int* rownnz, int* rowadr, int* colind);
|
||||
|
||||
// Apply cartesian force and torque (outside xfrc_applied mechanism).
|
||||
MJAPI void mj_applyFT(const mjModel* m, mjData* d,
|
||||
const mjtNum force[3], const mjtNum torque[3],
|
||||
MJAPI void mj_applyFT(const mjModel* m, mjData* d, const mjtNum force[3], const mjtNum torque[3],
|
||||
const mjtNum point[3], int body, mjtNum* qfrc_target);
|
||||
|
||||
// Compute object 6D velocity in object-centered frame, world/local orientation.
|
||||
@@ -453,9 +441,8 @@ MJAPI void mj_integratePos(const mjModel* m, mjtNum* qpos, const mjtNum* qvel, m
|
||||
MJAPI void mj_normalizeQuat(const mjModel* m, mjtNum* qpos);
|
||||
|
||||
// Map from body local to global Cartesian coordinates.
|
||||
MJAPI void mj_local2Global(mjData* d, mjtNum xpos[3], mjtNum xmat[9],
|
||||
const mjtNum pos[3], const mjtNum quat[4],
|
||||
int body, mjtByte sameframe);
|
||||
MJAPI void mj_local2Global(mjData* d, mjtNum xpos[3], mjtNum xmat[9], const mjtNum pos[3],
|
||||
const mjtNum quat[4], int body, mjtByte sameframe);
|
||||
|
||||
// Sum all body masses.
|
||||
MJAPI mjtNum mj_getTotalmass(const mjModel* m);
|
||||
@@ -657,8 +644,7 @@ MJAPI void mjr_blitBuffer(mjrRect src, mjrRect dst,
|
||||
MJAPI void mjr_setAux(int index, const mjrContext* con);
|
||||
|
||||
// Blit from Aux buffer to con->currentBuffer.
|
||||
MJAPI void mjr_blitAux(int index, mjrRect src, int left, int bottom,
|
||||
const mjrContext* con);
|
||||
MJAPI void mjr_blitAux(int index, mjrRect src, int left, int bottom, const mjrContext* con);
|
||||
|
||||
// Draw text at (x,y) in relative coordinates; font is mjtFont.
|
||||
MJAPI void mjr_text(int font, const char* txt, const mjrContext* con,
|
||||
@@ -914,12 +900,10 @@ MJAPI mjtNum mju_norm(const mjtNum* res, int n);
|
||||
MJAPI mjtNum mju_dot(const mjtNum* vec1, const mjtNum* vec2, const int n);
|
||||
|
||||
// Multiply matrix and vector: res = mat * vec.
|
||||
MJAPI void mju_mulMatVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec,
|
||||
int nr, int nc);
|
||||
MJAPI void mju_mulMatVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int nr, int nc);
|
||||
|
||||
// Multiply transposed matrix and vector: res = mat' * vec.
|
||||
MJAPI void mju_mulMatTVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec,
|
||||
int nr, int nc);
|
||||
MJAPI void mju_mulMatTVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int nr, int nc);
|
||||
|
||||
// Transpose matrix: res = mat'.
|
||||
MJAPI void mju_transpose(mjtNum* res, const mjtNum* mat, int nr, int nc);
|
||||
@@ -954,10 +938,10 @@ MJAPI void mju_rotVecQuat(mjtNum res[3], const mjtNum vec[3], const mjtNum quat[
|
||||
// Conjugate quaternion, corresponding to opposite rotation.
|
||||
MJAPI void mju_negQuat(mjtNum res[4], const mjtNum quat[4]);
|
||||
|
||||
// Muiltiply quaternions.
|
||||
// Multiply quaternions.
|
||||
MJAPI void mju_mulQuat(mjtNum res[4], const mjtNum quat1[4], const mjtNum quat2[4]);
|
||||
|
||||
// Muiltiply quaternion and axis.
|
||||
// Multiply quaternion and axis.
|
||||
MJAPI void mju_mulQuatAxis(mjtNum res[4], const mjtNum quat[4], const mjtNum axis[3]);
|
||||
|
||||
// Convert axisAngle to quaternion.
|
||||
@@ -1030,12 +1014,10 @@ MJAPI mjtNum mju_muscleBias(mjtNum len, const mjtNum lengthrange[2],
|
||||
MJAPI mjtNum mju_muscleDynamics(mjtNum ctrl, mjtNum act, const mjtNum prm[2]);
|
||||
|
||||
// Convert contact force to pyramid representation.
|
||||
MJAPI void mju_encodePyramid(mjtNum* pyramid, const mjtNum* force,
|
||||
const mjtNum* mu, int dim);
|
||||
MJAPI void mju_encodePyramid(mjtNum* pyramid, const mjtNum* force, const mjtNum* mu, int dim);
|
||||
|
||||
// Convert pyramid representation to contact force.
|
||||
MJAPI void mju_decodePyramid(mjtNum* force, const mjtNum* pyramid,
|
||||
const mjtNum* mu, int dim);
|
||||
MJAPI void mju_decodePyramid(mjtNum* force, const mjtNum* pyramid, const mjtNum* mu, int dim);
|
||||
|
||||
// Integrate spring-damper analytically, return pos(dt).
|
||||
MJAPI mjtNum mju_springDamper(mjtNum pos0, mjtNum vel0, mjtNum Kp, mjtNum Kv, mjtNum dt);
|
||||
Reference in New Issue
Block a user