diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1258955..225f13f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -41,14 +41,14 @@ jobs: run: | mkdir -p $HOME/.mujoco cd $HOME/.mujoco - wget https://github.com/google-deepmind/mujoco/releases/download/3.4.0/mujoco-3.4.0-linux-${{ matrix.arch }}.tar.gz - tar -xzf mujoco-3.4.0-linux-${{ matrix.arch }}.tar.gz + wget https://github.com/google-deepmind/mujoco/releases/download/3.10.0/mujoco-3.10.0-linux-${{ matrix.arch }}.tar.gz + tar -xzf mujoco-3.10.0-linux-${{ matrix.arch }}.tar.gz - name: build succeeds with MUJOCO_LIB env: CARGO_BUILD_TARGET: ${{ matrix.arch }}-unknown-linux-gnu run: | - export MUJOCO_LIB="$HOME/.mujoco/mujoco-3.4.0/lib" + export MUJOCO_LIB="$HOME/.mujoco/mujoco-3.10.0/lib" cargo clean ### clean up the build cache to assure the build script is re-run ### cargo build cargo build --features bindgen @@ -58,7 +58,7 @@ jobs: env: CARGO_BUILD_TARGET: ${{ matrix.arch }}-unknown-linux-gnu run: | - sudo cp $HOME/.mujoco/mujoco-3.4.0/lib/libmujoco.so /usr/local/lib/ + sudo cp $HOME/.mujoco/mujoco-3.10.0/lib/libmujoco.so /usr/local/lib/ sudo ldconfig cargo clean ### clean up the build cache to assure the build script is re-run ### cargo build @@ -85,16 +85,16 @@ jobs: - name: setup MuJoCo run: | if [ "${{ matrix.os }}" = 'ubuntu-24.04' ]; then - MUJOCO_FILENAME='mujoco-3.4.0-linux-x86_64.tar.gz' + MUJOCO_FILENAME='mujoco-3.10.0-linux-x86_64.tar.gz' elif [ "${{ matrix.os }}" = 'ubuntu-24.04-arm' ]; then - MUJOCO_FILENAME='mujoco-3.4.0-linux-aarch64.tar.gz' + MUJOCO_FILENAME='mujoco-3.10.0-linux-aarch64.tar.gz' fi mkdir -p $HOME/.mujoco && cd $HOME/.mujoco - wget https://github.com/google-deepmind/mujoco/releases/download/3.4.0/$MUJOCO_FILENAME + wget https://github.com/google-deepmind/mujoco/releases/download/3.10.0/$MUJOCO_FILENAME tar -xzf $MUJOCO_FILENAME ### Set `MUJOCO_LIB` and `LD_LIBRARY_PATH` for the test jobs ### - echo "MUJOCO_LIB=$HOME/.mujoco/mujoco-3.4.0/lib" >> $GITHUB_ENV - echo "LD_LIBRARY_PATH=$HOME/.mujoco/mujoco-3.4.0/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV + echo "MUJOCO_LIB=$HOME/.mujoco/mujoco-3.10.0/lib" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=$HOME/.mujoco/mujoco-3.10.0/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - name: setup additional dependencies for examples run: | diff --git a/Cargo.toml b/Cargo.toml index 5e05708..bb34398 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rusty_mujoco" -version = "0.3.0" +version = "0.4.0" edition = "2024" authors = ["kanarus "] documentation = "https://docs.rs/rusty_mujoco" diff --git a/README.md b/README.md index 4f0f1c4..fe0cf32 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Rusty MuJoCo Binding

Rust bindings for the MuJoCo physics simulator

-

MuJoCo Version: 3.4.0

+

MuJoCo Version: 3.10.0


@@ -32,32 +32,32 @@ ## Requirements -- [MuJoCo 3.4.0](https://github.com/google-deepmind/mujoco/releases/tag/3.4.0) downloaded and installed +- [MuJoCo 3.10.0](https://github.com/google-deepmind/mujoco/releases/tag/3.10.0) downloaded and installed - Additionally, if you place mujoco library in a non-standard directory of the platform, you need `MUJOCO_LIB` environment variable set to the path of the directory containing - `libmujoco.so` or `mujoco.lib` (e.g. `$HOME/.mujoco/mujoco-3.4.0/lib` when you placed the official release above in `~/.mujoco`) + `libmujoco.so` or `mujoco.lib` (e.g. `$HOME/.mujoco/mujoco-3.10.0/lib` when you placed the official release above in `~/.mujoco`) ### Note / Tips - For example on x86_64 Linux, run: ```sh - wget https://github.com/google-deepmind/mujoco/releases/download/3.4.0/mujoco-3.4.0-linux-x86_64.tar.gz - tar -xzf mujoco-3.4.0-linux-x86_64.tar.gz + wget https://github.com/google-deepmind/mujoco/releases/download/3.10.0/mujoco-3.10.0-linux-x86_64.tar.gz + tar -xzf mujoco-3.10.0-linux-x86_64.tar.gz ``` - to download & expand MuJoCo 3.4.0.\ + to download & expand MuJoCo 3.10.0.\ On other platforms, do the same with the appropriate archive file for your system. - One way to setup is to install MuJoCo to _a default standard path_ like `/usr/local/lib/` - (or a folder in _PATH_ on Windows), then if needed create symlink to `mujoco-3.4.0/lib/libmujoco.so` there, + (or a folder in _PATH_ on Windows), then if needed create symlink to `mujoco-3.10.0/lib/libmujoco.so` there, and insert to your shell config file: ```sh # example on Linux with /usr/local/lib/ - export MUJOCO_LIB="/usr/local/lib/mujoco-3.4.0/lib" + export MUJOCO_LIB="/usr/local/lib/mujoco-3.10.0/lib" ``` Or if you'd like to avoid to install MuJoCo to such a system directory: ```sh # example on Linux with $HOME/.mujoco/ - export MUJOCO_LIB="$HOME/.mujoco/mujoco-3.4.0/lib" + export MUJOCO_LIB="$HOME/.mujoco/mujoco-3.10.0/lib" export LD_LIBRARY_PATH="$MUJOCO_LIB:$LD_LIBRARY_PATH" ``` @@ -70,7 +70,7 @@ ```toml [dependencies] -rusty_mujoco = "0.3" +rusty_mujoco = "0.4" glfw = "0.60" ``` diff --git a/src/bindgen.rs b/src/bindgen.rs index 69e514a..2472fa6 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -2,7 +2,7 @@ #![allow(unused, non_camel_case_types, non_snake_case, non_upper_case_globals, clippy::all)] -pub const mjVERSION_HEADER: u32 = 340; +pub const mjVERSION_HEADER: u32 = 3010000; pub const mjMINVAL: f64 = 0.000000000000001; pub const mjPI: f64 = 3.141592653589793; pub const mjMAXVAL: f64 = 10000000000.0; @@ -20,10 +20,10 @@ pub const mjNBIAS: usize = 10; pub const mjNFLUID: usize = 12; pub const mjNREF: usize = 2; pub const mjNIMP: usize = 5; +pub const mjNPOLY: usize = 2; pub const mjNSENS: usize = 3; pub const mjNSOLVER: usize = 200; pub const mjNISLAND: usize = 20; -pub const mjMAXTHREAD: usize = 128; pub const mjNGROUP: usize = 6; pub const mjMAXLIGHT: usize = 100; pub const mjMAXOVERLAY: usize = 500; @@ -72,6 +72,7 @@ pub const mjKEY_NUMPAD_0: u32 = 320; pub const mjKEY_NUMPAD_9: u32 = 329; pub type mjtNum = f64; pub type mjtByte = ::core::ffi::c_uchar; +pub type mjtBool = bool; pub type mjtSize = i64; pub const mjNDISABLE: usize = mjtDisableBit::mjNDISABLE.0 as usize; impl mjtDisableBit { @@ -94,7 +95,8 @@ impl mjtDisableBit { pub const AUTORESET: mjtDisableBit = mjtDisableBit(65536); pub const NATIVECCD: mjtDisableBit = mjtDisableBit(131072); pub const ISLAND: mjtDisableBit = mjtDisableBit(262144); - const mjNDISABLE: mjtDisableBit = mjtDisableBit(19); + pub const MULTICCD: mjtDisableBit = mjtDisableBit(524288); + const mjNDISABLE: mjtDisableBit = mjtDisableBit(20); } impl ::core::ops::BitOr for mjtDisableBit { type Output = Self; @@ -131,8 +133,8 @@ impl mjtEnableBit { pub const ENERGY: mjtEnableBit = mjtEnableBit(2); pub const FWDINV: mjtEnableBit = mjtEnableBit(4); pub const INVDISCRETE: mjtEnableBit = mjtEnableBit(8); - pub const MULTICCD: mjtEnableBit = mjtEnableBit(16); - pub const SLEEP: mjtEnableBit = mjtEnableBit(32); + pub const SLEEP: mjtEnableBit = mjtEnableBit(16); + pub const DIAGEXACT: mjtEnableBit = mjtEnableBit(32); const mjNENABLE: mjtEnableBit = mjtEnableBit(6); } impl ::core::ops::BitOr for mjtEnableBit { @@ -199,6 +201,13 @@ impl mjtGeom { #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct mjtGeom(pub(crate) ::core::ffi::c_uint); +impl mjtProjection { + pub const PERSPECTIVE: mjtProjection = mjtProjection(0); + pub const ORTHOGRAPHIC: mjtProjection = mjtProjection(1); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtProjection(pub(crate) ::core::ffi::c_uint); impl mjtCamLight { pub const FIXED: mjtCamLight = mjtCamLight(0); pub const TRACK: mjtCamLight = mjtCamLight(1); @@ -289,7 +298,9 @@ impl mjtEq { pub const JOINT: mjtEq = mjtEq(2); pub const TENDON: mjtEq = mjtEq(3); pub const FLEX: mjtEq = mjtEq(4); - pub const DISTANCE: mjtEq = mjtEq(5); + pub const FLEXVERT: mjtEq = mjtEq(5); + pub const FLEXSTRAIN: mjtEq = mjtEq(6); + pub const DISTANCE: mjtEq = mjtEq(7); } #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -323,7 +334,8 @@ impl mjtDyn { pub const FILTER: mjtDyn = mjtDyn(2); pub const FILTEREXACT: mjtDyn = mjtDyn(3); pub const MUSCLE: mjtDyn = mjtDyn(4); - pub const USER: mjtDyn = mjtDyn(5); + pub const DCMOTOR: mjtDyn = mjtDyn(5); + pub const USER: mjtDyn = mjtDyn(6); } #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -332,7 +344,8 @@ impl mjtGain { pub const FIXED: mjtGain = mjtGain(0); pub const AFFINE: mjtGain = mjtGain(1); pub const MUSCLE: mjtGain = mjtGain(2); - pub const USER: mjtGain = mjtGain(3); + pub const DCMOTOR: mjtGain = mjtGain(3); + pub const USER: mjtGain = mjtGain(4); } #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -341,7 +354,8 @@ impl mjtBias { pub const NONE: mjtBias = mjtBias(0); pub const AFFINE: mjtBias = mjtBias(1); pub const MUSCLE: mjtBias = mjtBias(2); - pub const USER: mjtBias = mjtBias(3); + pub const DCMOTOR: mjtBias = mjtBias(3); + pub const USER: mjtBias = mjtBias(4); } #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -468,6 +482,57 @@ impl mjtConDataField { #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct mjtConDataField(pub(crate) ::core::ffi::c_uint); +pub const mjNRAYDATA: usize = mjtRayDataField::mjNRAYDATA.0 as usize; +impl mjtRayDataField { + pub const DIST: mjtRayDataField = mjtRayDataField(0); + pub const DIR: mjtRayDataField = mjtRayDataField(1); + pub const ORIGIN: mjtRayDataField = mjtRayDataField(2); + pub const POINT: mjtRayDataField = mjtRayDataField(3); + pub const NORMAL: mjtRayDataField = mjtRayDataField(4); + pub const DEPTH: mjtRayDataField = mjtRayDataField(5); + const mjNRAYDATA: mjtRayDataField = mjtRayDataField(6); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtRayDataField(pub(crate) ::core::ffi::c_uint); +pub const mjNCAMOUT: usize = mjtCamOutBit::mjNCAMOUT.0 as usize; +impl mjtCamOutBit { + pub const RGB: mjtCamOutBit = mjtCamOutBit(1); + pub const DEPTH: mjtCamOutBit = mjtCamOutBit(2); + pub const DIST: mjtCamOutBit = mjtCamOutBit(4); + pub const NORMAL: mjtCamOutBit = mjtCamOutBit(8); + pub const SEG: mjtCamOutBit = mjtCamOutBit(16); + const mjNCAMOUT: mjtCamOutBit = mjtCamOutBit(5); +} +impl ::core::ops::BitOr for mjtCamOutBit { + type Output = Self; + #[inline] + fn bitor(self, other: Self) -> Self { + mjtCamOutBit(self.0 | other.0) + } +} +impl ::core::ops::BitOrAssign for mjtCamOutBit { + #[inline] + fn bitor_assign(&mut self, rhs: mjtCamOutBit) { + self.0 |= rhs.0; + } +} +impl ::core::ops::BitAnd for mjtCamOutBit { + type Output = Self; + #[inline] + fn bitand(self, other: Self) -> Self { + mjtCamOutBit(self.0 & other.0) + } +} +impl ::core::ops::BitAndAssign for mjtCamOutBit { + #[inline] + fn bitand_assign(&mut self, rhs: mjtCamOutBit) { + self.0 &= rhs.0; + } +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtCamOutBit(pub(crate) ::core::ffi::c_uint); impl mjtSameFrame { pub const NONE: mjtSameFrame = mjtSameFrame(0); pub const BODY: mjtSameFrame = mjtSameFrame(1); @@ -517,6 +582,138 @@ impl mjtSDFType { #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct mjtSDFType(pub(crate) ::core::ffi::c_uint); +pub const mjNSTATE: usize = mjtState::mjNSTATE.0 as usize; +impl mjtState { + pub const TIME: mjtState = mjtState(1); + pub const QPOS: mjtState = mjtState(2); + pub const QVEL: mjtState = mjtState(4); + pub const ACT: mjtState = mjtState(8); + pub const HISTORY: mjtState = mjtState(16); + pub const WARMSTART: mjtState = mjtState(32); + pub const CTRL: mjtState = mjtState(64); + pub const QFRC_APPLIED: mjtState = mjtState(128); + pub const XFRC_APPLIED: mjtState = mjtState(256); + pub const EQ_ACTIVE: mjtState = mjtState(512); + pub const MOCAP_POS: mjtState = mjtState(1024); + pub const MOCAP_QUAT: mjtState = mjtState(2048); + pub const USERDATA: mjtState = mjtState(4096); + pub const PLUGIN: mjtState = mjtState(8192); + pub const PHYSICS: mjtState = mjtState(30); + pub const FULLPHYSICS: mjtState = mjtState(8223); + pub const USER: mjtState = mjtState(8128); + pub const INTEGRATION: mjtState = mjtState(16383); + const mjNSTATE: mjtState = mjtState(14); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtState(pub(crate) ::core::ffi::c_uint); +impl mjtConstraint { + pub const EQUALITY: mjtConstraint = mjtConstraint(0); + pub const FRICTION_DOF: mjtConstraint = mjtConstraint(1); + pub const FRICTION_TENDON: mjtConstraint = mjtConstraint(2); + pub const LIMIT_JOINT: mjtConstraint = mjtConstraint(3); + pub const LIMIT_TENDON: mjtConstraint = mjtConstraint(4); + pub const CONTACT_FRICTIONLESS: mjtConstraint = mjtConstraint(5); + pub const CONTACT_PYRAMIDAL: mjtConstraint = mjtConstraint(6); + pub const CONTACT_ELLIPTIC: mjtConstraint = mjtConstraint(7); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtConstraint(pub(crate) ::core::ffi::c_uint); +impl mjtConstraintState { + pub const SATISFIED: mjtConstraintState = mjtConstraintState(0); + pub const QUADRATIC: mjtConstraintState = mjtConstraintState(1); + pub const LINEARNEG: mjtConstraintState = mjtConstraintState(2); + pub const LINEARPOS: mjtConstraintState = mjtConstraintState(3); + pub const CONE: mjtConstraintState = mjtConstraintState(4); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtConstraintState(pub(crate) ::core::ffi::c_uint); +pub const mjNWARNING: usize = mjtWarning::mjNWARNING.0 as usize; +impl mjtWarning { + pub const INERTIA: mjtWarning = mjtWarning(0); + pub const CONTACTFULL: mjtWarning = mjtWarning(1); + pub const CNSTRFULL: mjtWarning = mjtWarning(2); + pub const BADQPOS: mjtWarning = mjtWarning(3); + pub const BADQVEL: mjtWarning = mjtWarning(4); + pub const BADQACC: mjtWarning = mjtWarning(5); + pub const BADCTRL: mjtWarning = mjtWarning(6); + const mjNWARNING: mjtWarning = mjtWarning(7); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtWarning(pub(crate) ::core::ffi::c_uint); +pub const mjNTIMER: usize = mjtTimer::mjNTIMER.0 as usize; +impl mjtTimer { + pub const STEP: mjtTimer = mjtTimer(0); + pub const FORWARD: mjtTimer = mjtTimer(1); + pub const INVERSE: mjtTimer = mjtTimer(2); + pub const POSITION: mjtTimer = mjtTimer(3); + pub const VELOCITY: mjtTimer = mjtTimer(4); + pub const ACTUATION: mjtTimer = mjtTimer(5); + pub const CONSTRAINT: mjtTimer = mjtTimer(6); + pub const ADVANCE: mjtTimer = mjtTimer(7); + pub const POS_KINEMATICS: mjtTimer = mjtTimer(8); + pub const POS_INERTIA: mjtTimer = mjtTimer(9); + pub const POS_COLLISION: mjtTimer = mjtTimer(10); + pub const POS_MAKE: mjtTimer = mjtTimer(11); + pub const POS_PROJECT: mjtTimer = mjtTimer(12); + pub const COL_BROAD: mjtTimer = mjtTimer(13); + pub const COL_NARROW: mjtTimer = mjtTimer(14); + const mjNTIMER: mjtTimer = mjtTimer(15); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtTimer(pub(crate) ::core::ffi::c_uint); +impl mjtSleepState { + pub const STATIC: mjtSleepState = mjtSleepState(-1); + pub const ASLEEP: mjtSleepState = mjtSleepState(0); + pub const AWAKE: mjtSleepState = mjtSleepState(1); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtSleepState(pub(crate) ::core::ffi::c_int); +impl mjtLogLevel { + pub const DEBUG: mjtLogLevel = mjtLogLevel(0); + pub const INFO: mjtLogLevel = mjtLogLevel(1); + pub const WARNING: mjtLogLevel = mjtLogLevel(2); + pub const ERROR: mjtLogLevel = mjtLogLevel(3); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtLogLevel(pub(crate) ::core::ffi::c_uint); +impl mjtLogTopic { + pub const NONE: mjtLogTopic = mjtLogTopic(0); + pub const TIME_STP: mjtLogTopic = mjtLogTopic(1); + pub const TIME_CMP: mjtLogTopic = mjtLogTopic(2); + pub const SLEEP: mjtLogTopic = mjtLogTopic(3); + const mjNTOPIC: mjtLogTopic = mjtLogTopic(3); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtLogTopic(pub(crate) ::core::ffi::c_uint); +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct mjLogMessage { + pub(crate) level: ::core::ffi::c_int, + pub(crate) topic: ::core::ffi::c_int, + pub(crate) subject: [::core::ffi::c_char; 1024usize], + pub(crate) body: *const ::core::ffi::c_char, + pub(crate) func: *const ::core::ffi::c_char, + pub(crate) file: *const ::core::ffi::c_char, + pub(crate) line: ::core::ffi::c_int, + pub(crate) timestamp: mjtBool, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct mjLogConfig { + pub(crate) logto_console: mjtBool, + pub(crate) logto_file: mjtBool, + pub(crate) logfile: [::core::ffi::c_char; 1024usize], + pub(crate) topics: ::core::ffi::c_int, +} +pub type mjfLogHandler = ::core::option::Option; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct mjLROpt { @@ -697,90 +894,96 @@ pub struct mjStatistic { #[repr(C)] #[derive(Debug)] pub struct mjModel { - pub(crate) nq: ::core::ffi::c_int, - pub(crate) nv: ::core::ffi::c_int, - pub(crate) nu: ::core::ffi::c_int, - pub(crate) na: ::core::ffi::c_int, - pub(crate) nbody: ::core::ffi::c_int, - pub(crate) nbvh: ::core::ffi::c_int, - pub(crate) nbvhstatic: ::core::ffi::c_int, - pub(crate) nbvhdynamic: ::core::ffi::c_int, - pub(crate) noct: ::core::ffi::c_int, - pub(crate) njnt: ::core::ffi::c_int, - pub(crate) ntree: ::core::ffi::c_int, - pub(crate) nM: ::core::ffi::c_int, - pub(crate) nB: ::core::ffi::c_int, - pub(crate) nC: ::core::ffi::c_int, - pub(crate) nD: ::core::ffi::c_int, - pub(crate) ngeom: ::core::ffi::c_int, - pub(crate) nsite: ::core::ffi::c_int, - pub(crate) ncam: ::core::ffi::c_int, - pub(crate) nlight: ::core::ffi::c_int, - pub(crate) nflex: ::core::ffi::c_int, - pub(crate) nflexnode: ::core::ffi::c_int, - pub(crate) nflexvert: ::core::ffi::c_int, - pub(crate) nflexedge: ::core::ffi::c_int, - pub(crate) nflexelem: ::core::ffi::c_int, - pub(crate) nflexelemdata: ::core::ffi::c_int, - pub(crate) nflexelemedge: ::core::ffi::c_int, - pub(crate) nflexshelldata: ::core::ffi::c_int, - pub(crate) nflexevpair: ::core::ffi::c_int, - pub(crate) nflextexcoord: ::core::ffi::c_int, - pub(crate) nmesh: ::core::ffi::c_int, - pub(crate) nmeshvert: ::core::ffi::c_int, - pub(crate) nmeshnormal: ::core::ffi::c_int, - pub(crate) nmeshtexcoord: ::core::ffi::c_int, - pub(crate) nmeshface: ::core::ffi::c_int, - pub(crate) nmeshgraph: ::core::ffi::c_int, - pub(crate) nmeshpoly: ::core::ffi::c_int, - pub(crate) nmeshpolyvert: ::core::ffi::c_int, - pub(crate) nmeshpolymap: ::core::ffi::c_int, - pub(crate) nskin: ::core::ffi::c_int, - pub(crate) nskinvert: ::core::ffi::c_int, - pub(crate) nskintexvert: ::core::ffi::c_int, - pub(crate) nskinface: ::core::ffi::c_int, - pub(crate) nskinbone: ::core::ffi::c_int, - pub(crate) nskinbonevert: ::core::ffi::c_int, - pub(crate) nhfield: ::core::ffi::c_int, - pub(crate) nhfielddata: ::core::ffi::c_int, - pub(crate) ntex: ::core::ffi::c_int, - pub(crate) ntexdata: ::core::ffi::c_int, - pub(crate) nmat: ::core::ffi::c_int, - pub(crate) npair: ::core::ffi::c_int, - pub(crate) nexclude: ::core::ffi::c_int, - pub(crate) neq: ::core::ffi::c_int, - pub(crate) ntendon: ::core::ffi::c_int, - pub(crate) nwrap: ::core::ffi::c_int, - pub(crate) nsensor: ::core::ffi::c_int, - pub(crate) nnumeric: ::core::ffi::c_int, - pub(crate) nnumericdata: ::core::ffi::c_int, - pub(crate) ntext: ::core::ffi::c_int, - pub(crate) ntextdata: ::core::ffi::c_int, - pub(crate) ntuple: ::core::ffi::c_int, - pub(crate) ntupledata: ::core::ffi::c_int, - pub(crate) nkey: ::core::ffi::c_int, - pub(crate) nmocap: ::core::ffi::c_int, - pub(crate) nplugin: ::core::ffi::c_int, - pub(crate) npluginattr: ::core::ffi::c_int, - pub(crate) nuser_body: ::core::ffi::c_int, - pub(crate) nuser_jnt: ::core::ffi::c_int, - pub(crate) nuser_geom: ::core::ffi::c_int, - pub(crate) nuser_site: ::core::ffi::c_int, - pub(crate) nuser_cam: ::core::ffi::c_int, - pub(crate) nuser_tendon: ::core::ffi::c_int, - pub(crate) nuser_actuator: ::core::ffi::c_int, - pub(crate) nuser_sensor: ::core::ffi::c_int, - pub(crate) nnames: ::core::ffi::c_int, - pub(crate) npaths: ::core::ffi::c_int, - pub(crate) nnames_map: ::core::ffi::c_int, - pub(crate) nJmom: ::core::ffi::c_int, - pub(crate) ngravcomp: ::core::ffi::c_int, - pub(crate) nemax: ::core::ffi::c_int, - pub(crate) njmax: ::core::ffi::c_int, - pub(crate) nconmax: ::core::ffi::c_int, - pub(crate) nuserdata: ::core::ffi::c_int, - pub(crate) nsensordata: ::core::ffi::c_int, - pub(crate) npluginstate: ::core::ffi::c_int, + pub(crate) nq: mjtSize, + pub(crate) nv: mjtSize, + pub(crate) nu: mjtSize, + pub(crate) na: mjtSize, + pub(crate) nbody: mjtSize, + pub(crate) nbvh: mjtSize, + pub(crate) nbvhstatic: mjtSize, + pub(crate) nbvhdynamic: mjtSize, + pub(crate) noct: mjtSize, + pub(crate) njnt: mjtSize, + pub(crate) ntree: mjtSize, + pub(crate) nM: mjtSize, + pub(crate) nB: mjtSize, + pub(crate) nC: mjtSize, + pub(crate) nD: mjtSize, + pub(crate) ngeom: mjtSize, + pub(crate) nsite: mjtSize, + pub(crate) ncam: mjtSize, + pub(crate) nlight: mjtSize, + pub(crate) nflex: mjtSize, + pub(crate) nflexnode: mjtSize, + pub(crate) nflexvert: mjtSize, + pub(crate) nflexedge: mjtSize, + pub(crate) nflexelem: mjtSize, + pub(crate) nflexelemdata: mjtSize, + pub(crate) nflexstiffness: mjtSize, + pub(crate) nflexbending: mjtSize, + pub(crate) nflexelemedge: mjtSize, + pub(crate) nflexshelldata: mjtSize, + pub(crate) nflexevpair: mjtSize, + pub(crate) nflextexcoord: mjtSize, + pub(crate) nJfe: mjtSize, + pub(crate) nJfv: mjtSize, + pub(crate) nmesh: mjtSize, + pub(crate) nmeshvert: mjtSize, + pub(crate) nmeshnormal: mjtSize, + pub(crate) nmeshtexcoord: mjtSize, + pub(crate) nmeshface: mjtSize, + pub(crate) nmeshgraph: mjtSize, + pub(crate) nmeshpoly: mjtSize, + pub(crate) nmeshpolyvert: mjtSize, + pub(crate) nmeshpolymap: mjtSize, + pub(crate) nskin: mjtSize, + pub(crate) nskinvert: mjtSize, + pub(crate) nskintexvert: mjtSize, + pub(crate) nskinface: mjtSize, + pub(crate) nskinbone: mjtSize, + pub(crate) nskinbonevert: mjtSize, + pub(crate) nhfield: mjtSize, + pub(crate) nhfielddata: mjtSize, + pub(crate) ntex: mjtSize, + pub(crate) ntexdata: mjtSize, + pub(crate) nmat: mjtSize, + pub(crate) npair: mjtSize, + pub(crate) nexclude: mjtSize, + pub(crate) neq: mjtSize, + pub(crate) ntendon: mjtSize, + pub(crate) nJten: mjtSize, + pub(crate) nwrap: mjtSize, + pub(crate) nsensor: mjtSize, + pub(crate) nnumeric: mjtSize, + pub(crate) nnumericdata: mjtSize, + pub(crate) ntext: mjtSize, + pub(crate) ntextdata: mjtSize, + pub(crate) ntuple: mjtSize, + pub(crate) ntupledata: mjtSize, + pub(crate) nkey: mjtSize, + pub(crate) nmocap: mjtSize, + pub(crate) nplugin: mjtSize, + pub(crate) npluginattr: mjtSize, + pub(crate) nuser_body: mjtSize, + pub(crate) nuser_jnt: mjtSize, + pub(crate) nuser_geom: mjtSize, + pub(crate) nuser_site: mjtSize, + pub(crate) nuser_cam: mjtSize, + pub(crate) nuser_tendon: mjtSize, + pub(crate) nuser_actuator: mjtSize, + pub(crate) nuser_sensor: mjtSize, + pub(crate) nnames: mjtSize, + pub(crate) npaths: mjtSize, + pub(crate) nnames_map: mjtSize, + pub(crate) nJmom: mjtSize, + pub(crate) ngravcomp: mjtSize, + pub(crate) nemax: mjtSize, + pub(crate) njmax: mjtSize, + pub(crate) nconmax: mjtSize, + pub(crate) nuserdata: mjtSize, + pub(crate) nsensordata: mjtSize, + pub(crate) npluginstate: mjtSize, + pub(crate) nhistory: mjtSize, pub(crate) narena: mjtSize, pub(crate) nbuffer: mjtSize, pub(crate) opt: mjOption, @@ -830,15 +1033,17 @@ pub struct mjModel { pub(crate) jnt_qposadr: *mut ::core::ffi::c_int, pub(crate) jnt_dofadr: *mut ::core::ffi::c_int, pub(crate) jnt_bodyid: *mut ::core::ffi::c_int, + pub(crate) jnt_actuatorid: *mut ::core::ffi::c_int, pub(crate) jnt_group: *mut ::core::ffi::c_int, - pub(crate) jnt_limited: *mut mjtByte, - pub(crate) jnt_actfrclimited: *mut mjtByte, - pub(crate) jnt_actgravcomp: *mut mjtByte, + pub(crate) jnt_limited: *mut mjtBool, + pub(crate) jnt_actfrclimited: *mut mjtBool, + pub(crate) jnt_actgravcomp: *mut mjtBool, pub(crate) jnt_solref: *mut mjtNum, pub(crate) jnt_solimp: *mut mjtNum, pub(crate) jnt_pos: *mut mjtNum, pub(crate) jnt_axis: *mut mjtNum, pub(crate) jnt_stiffness: *mut mjtNum, + pub(crate) jnt_stiffnesspoly: *mut mjtNum, pub(crate) jnt_range: *mut mjtNum, pub(crate) jnt_actfrcrange: *mut mjtNum, pub(crate) jnt_margin: *mut mjtNum, @@ -854,6 +1059,7 @@ pub struct mjModel { pub(crate) dof_frictionloss: *mut mjtNum, pub(crate) dof_armature: *mut mjtNum, pub(crate) dof_damping: *mut mjtNum, + pub(crate) dof_dampingpoly: *mut mjtNum, pub(crate) dof_invweight0: *mut mjtNum, pub(crate) dof_M0: *mut mjtNum, pub(crate) dof_length: *mut mjtNum, @@ -905,10 +1111,11 @@ pub struct mjModel { pub(crate) cam_poscom0: *mut mjtNum, pub(crate) cam_pos0: *mut mjtNum, pub(crate) cam_mat0: *mut mjtNum, - pub(crate) cam_orthographic: *mut ::core::ffi::c_int, + pub(crate) cam_projection: *mut ::core::ffi::c_int, pub(crate) cam_fovy: *mut mjtNum, pub(crate) cam_ipd: *mut mjtNum, pub(crate) cam_resolution: *mut ::core::ffi::c_int, + pub(crate) cam_output: *mut ::core::ffi::c_int, pub(crate) cam_sensorsize: *mut f32, pub(crate) cam_intrinsic: *mut f32, pub(crate) cam_user: *mut mjtNum, @@ -917,11 +1124,11 @@ pub struct mjModel { pub(crate) light_targetbodyid: *mut ::core::ffi::c_int, pub(crate) light_type: *mut ::core::ffi::c_int, pub(crate) light_texid: *mut ::core::ffi::c_int, - pub(crate) light_castshadow: *mut mjtByte, + pub(crate) light_castshadow: *mut mjtBool, pub(crate) light_bulbradius: *mut f32, pub(crate) light_intensity: *mut f32, pub(crate) light_range: *mut f32, - pub(crate) light_active: *mut mjtByte, + pub(crate) light_active: *mut mjtBool, pub(crate) light_pos: *mut mjtNum, pub(crate) light_dir: *mut mjtNum, pub(crate) light_poscom0: *mut mjtNum, @@ -943,7 +1150,7 @@ pub struct mjModel { pub(crate) flex_friction: *mut mjtNum, pub(crate) flex_margin: *mut mjtNum, pub(crate) flex_gap: *mut mjtNum, - pub(crate) flex_internal: *mut mjtByte, + pub(crate) flex_internal: *mut mjtBool, pub(crate) flex_selfcollide: *mut ::core::ffi::c_int, pub(crate) flex_activelayers: *mut ::core::ffi::c_int, pub(crate) flex_passive: *mut ::core::ffi::c_int, @@ -951,6 +1158,7 @@ pub struct mjModel { pub(crate) flex_matid: *mut ::core::ffi::c_int, pub(crate) flex_group: *mut ::core::ffi::c_int, pub(crate) flex_interp: *mut ::core::ffi::c_int, + pub(crate) flex_cellnum: *mut ::core::ffi::c_int, pub(crate) flex_nodeadr: *mut ::core::ffi::c_int, pub(crate) flex_nodenum: *mut ::core::ffi::c_int, pub(crate) flex_vertadr: *mut ::core::ffi::c_int, @@ -960,7 +1168,9 @@ pub struct mjModel { pub(crate) flex_elemadr: *mut ::core::ffi::c_int, pub(crate) flex_elemnum: *mut ::core::ffi::c_int, pub(crate) flex_elemdataadr: *mut ::core::ffi::c_int, + pub(crate) flex_stiffnessadr: *mut ::core::ffi::c_int, pub(crate) flex_elemedgeadr: *mut ::core::ffi::c_int, + pub(crate) flex_bendingadr: *mut ::core::ffi::c_int, pub(crate) flex_shellnum: *mut ::core::ffi::c_int, pub(crate) flex_shelldataadr: *mut ::core::ffi::c_int, pub(crate) flex_evpairadr: *mut ::core::ffi::c_int, @@ -968,6 +1178,9 @@ pub struct mjModel { pub(crate) flex_texcoordadr: *mut ::core::ffi::c_int, pub(crate) flex_nodebodyid: *mut ::core::ffi::c_int, pub(crate) flex_vertbodyid: *mut ::core::ffi::c_int, + pub(crate) flex_vertedgeadr: *mut ::core::ffi::c_int, + pub(crate) flex_vertedgenum: *mut ::core::ffi::c_int, + pub(crate) flex_vertedge: *mut ::core::ffi::c_int, pub(crate) flex_edge: *mut ::core::ffi::c_int, pub(crate) flex_edgeflap: *mut ::core::ffi::c_int, pub(crate) flex_elem: *mut ::core::ffi::c_int, @@ -978,23 +1191,31 @@ pub struct mjModel { pub(crate) flex_evpair: *mut ::core::ffi::c_int, pub(crate) flex_vert: *mut mjtNum, pub(crate) flex_vert0: *mut mjtNum, + pub(crate) flex_vertmetric: *mut mjtNum, pub(crate) flex_node: *mut mjtNum, pub(crate) flex_node0: *mut mjtNum, pub(crate) flexedge_length0: *mut mjtNum, pub(crate) flexedge_invweight0: *mut mjtNum, pub(crate) flex_radius: *mut mjtNum, + pub(crate) flex_size: *mut mjtNum, pub(crate) flex_stiffness: *mut mjtNum, pub(crate) flex_bending: *mut mjtNum, pub(crate) flex_damping: *mut mjtNum, pub(crate) flex_edgestiffness: *mut mjtNum, pub(crate) flex_edgedamping: *mut mjtNum, - pub(crate) flex_edgeequality: *mut mjtByte, - pub(crate) flex_rigid: *mut mjtByte, - pub(crate) flexedge_rigid: *mut mjtByte, - pub(crate) flex_centered: *mut mjtByte, - pub(crate) flex_flatskin: *mut mjtByte, + pub(crate) flex_edgeequality: *mut ::core::ffi::c_int, + pub(crate) flex_rigid: *mut mjtBool, + pub(crate) flexedge_rigid: *mut mjtBool, + pub(crate) flex_centered: *mut mjtBool, + pub(crate) flex_flatskin: *mut mjtBool, pub(crate) flex_bvhadr: *mut ::core::ffi::c_int, pub(crate) flex_bvhnum: *mut ::core::ffi::c_int, + pub(crate) flexedge_J_rownnz: *mut ::core::ffi::c_int, + pub(crate) flexedge_J_rowadr: *mut ::core::ffi::c_int, + pub(crate) flexedge_J_colind: *mut ::core::ffi::c_int, + pub(crate) flexvert_J_rownnz: *mut ::core::ffi::c_int, + pub(crate) flexvert_J_rowadr: *mut ::core::ffi::c_int, + pub(crate) flexvert_J_colind: *mut ::core::ffi::c_int, pub(crate) flex_rgba: *mut f32, pub(crate) flex_texcoord: *mut f32, pub(crate) mesh_vertadr: *mut ::core::ffi::c_int, @@ -1063,11 +1284,11 @@ pub struct mjModel { pub(crate) tex_height: *mut ::core::ffi::c_int, pub(crate) tex_width: *mut ::core::ffi::c_int, pub(crate) tex_nchannel: *mut ::core::ffi::c_int, - pub(crate) tex_adr: *mut ::core::ffi::c_int, + pub(crate) tex_adr: *mut mjtSize, pub(crate) tex_data: *mut mjtByte, pub(crate) tex_pathadr: *mut ::core::ffi::c_int, pub(crate) mat_texid: *mut ::core::ffi::c_int, - pub(crate) mat_texuniform: *mut mjtByte, + pub(crate) mat_texuniform: *mut mjtBool, pub(crate) mat_texrepeat: *mut f32, pub(crate) mat_emission: *mut f32, pub(crate) mat_specular: *mut f32, @@ -1091,18 +1312,22 @@ pub struct mjModel { pub(crate) eq_obj1id: *mut ::core::ffi::c_int, pub(crate) eq_obj2id: *mut ::core::ffi::c_int, pub(crate) eq_objtype: *mut ::core::ffi::c_int, - pub(crate) eq_active0: *mut mjtByte, + pub(crate) eq_active0: *mut mjtBool, pub(crate) eq_solref: *mut mjtNum, pub(crate) eq_solimp: *mut mjtNum, pub(crate) eq_data: *mut mjtNum, pub(crate) tendon_adr: *mut ::core::ffi::c_int, pub(crate) tendon_num: *mut ::core::ffi::c_int, pub(crate) tendon_matid: *mut ::core::ffi::c_int, + pub(crate) tendon_actuatorid: *mut ::core::ffi::c_int, pub(crate) tendon_group: *mut ::core::ffi::c_int, pub(crate) tendon_treenum: *mut ::core::ffi::c_int, pub(crate) tendon_treeid: *mut ::core::ffi::c_int, - pub(crate) tendon_limited: *mut mjtByte, - pub(crate) tendon_actfrclimited: *mut mjtByte, + pub(crate) ten_J_rownnz: *mut ::core::ffi::c_int, + pub(crate) ten_J_rowadr: *mut ::core::ffi::c_int, + pub(crate) ten_J_colind: *mut ::core::ffi::c_int, + pub(crate) tendon_limited: *mut mjtBool, + pub(crate) tendon_actfrclimited: *mut mjtBool, pub(crate) tendon_width: *mut mjtNum, pub(crate) tendon_solref_lim: *mut mjtNum, pub(crate) tendon_solimp_lim: *mut mjtNum, @@ -1112,7 +1337,9 @@ pub struct mjModel { pub(crate) tendon_actfrcrange: *mut mjtNum, pub(crate) tendon_margin: *mut mjtNum, pub(crate) tendon_stiffness: *mut mjtNum, + pub(crate) tendon_stiffnesspoly: *mut mjtNum, pub(crate) tendon_damping: *mut mjtNum, + pub(crate) tendon_dampingpoly: *mut mjtNum, pub(crate) tendon_armature: *mut mjtNum, pub(crate) tendon_frictionloss: *mut mjtNum, pub(crate) tendon_lengthspring: *mut mjtNum, @@ -1128,16 +1355,22 @@ pub struct mjModel { pub(crate) actuator_gaintype: *mut ::core::ffi::c_int, pub(crate) actuator_biastype: *mut ::core::ffi::c_int, pub(crate) actuator_trnid: *mut ::core::ffi::c_int, + pub(crate) actuator_damping: *mut mjtNum, + pub(crate) actuator_dampingpoly: *mut mjtNum, + pub(crate) actuator_armature: *mut mjtNum, pub(crate) actuator_actadr: *mut ::core::ffi::c_int, pub(crate) actuator_actnum: *mut ::core::ffi::c_int, pub(crate) actuator_group: *mut ::core::ffi::c_int, - pub(crate) actuator_ctrllimited: *mut mjtByte, - pub(crate) actuator_forcelimited: *mut mjtByte, - pub(crate) actuator_actlimited: *mut mjtByte, + pub(crate) actuator_history: *mut ::core::ffi::c_int, + pub(crate) actuator_historyadr: *mut ::core::ffi::c_int, + pub(crate) actuator_delay: *mut mjtNum, + pub(crate) actuator_ctrllimited: *mut mjtBool, + pub(crate) actuator_forcelimited: *mut mjtBool, + pub(crate) actuator_actlimited: *mut mjtBool, pub(crate) actuator_dynprm: *mut mjtNum, pub(crate) actuator_gainprm: *mut mjtNum, pub(crate) actuator_biasprm: *mut mjtNum, - pub(crate) actuator_actearly: *mut mjtByte, + pub(crate) actuator_actearly: *mut mjtBool, pub(crate) actuator_ctrlrange: *mut mjtNum, pub(crate) actuator_forcerange: *mut mjtNum, pub(crate) actuator_actrange: *mut mjtNum, @@ -1160,6 +1393,10 @@ pub struct mjModel { pub(crate) sensor_adr: *mut ::core::ffi::c_int, pub(crate) sensor_cutoff: *mut mjtNum, pub(crate) sensor_noise: *mut mjtNum, + pub(crate) sensor_history: *mut ::core::ffi::c_int, + pub(crate) sensor_historyadr: *mut ::core::ffi::c_int, + pub(crate) sensor_delay: *mut mjtNum, + pub(crate) sensor_interval: *mut mjtNum, pub(crate) sensor_user: *mut mjtNum, pub(crate) sensor_plugin: *mut ::core::ffi::c_int, pub(crate) plugin: *mut ::core::ffi::c_int, @@ -1226,121 +1463,14 @@ pub struct mjModel { pub(crate) mapD2M: *mut ::core::ffi::c_int, pub(crate) signature: u64, } -impl mjtTaskStatus { - pub const NEW: mjtTaskStatus = mjtTaskStatus(0); - pub const QUEUED: mjtTaskStatus = mjtTaskStatus(1); - pub const COMPLETED: mjtTaskStatus = mjtTaskStatus(2); -} -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mjtTaskStatus(pub(crate) ::core::ffi::c_uint); -pub type mjfTask = ::core::option::Option< - unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void) -> *mut ::core::ffi::c_void, ->; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct mjThreadPool { - pub(crate) nworker: ::core::ffi::c_int, -} #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct mjTask { - pub(crate) func: mjfTask, - pub(crate) args: *mut ::core::ffi::c_void, - pub(crate) status: ::core::ffi::c_int, -} -pub const mjNSTATE: usize = mjtState::mjNSTATE.0 as usize; -impl mjtState { - pub const TIME: mjtState = mjtState(1); - pub const QPOS: mjtState = mjtState(2); - pub const QVEL: mjtState = mjtState(4); - pub const ACT: mjtState = mjtState(8); - pub const WARMSTART: mjtState = mjtState(16); - pub const CTRL: mjtState = mjtState(32); - pub const QFRC_APPLIED: mjtState = mjtState(64); - pub const XFRC_APPLIED: mjtState = mjtState(128); - pub const EQ_ACTIVE: mjtState = mjtState(256); - pub const MOCAP_POS: mjtState = mjtState(512); - pub const MOCAP_QUAT: mjtState = mjtState(1024); - pub const USERDATA: mjtState = mjtState(2048); - pub const PLUGIN: mjtState = mjtState(4096); - pub const PHYSICS: mjtState = mjtState(14); - pub const FULLPHYSICS: mjtState = mjtState(4111); - pub const USER: mjtState = mjtState(4064); - pub const INTEGRATION: mjtState = mjtState(8191); - const mjNSTATE: mjtState = mjtState(13); -} -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mjtState(pub(crate) ::core::ffi::c_uint); -impl mjtConstraint { - pub const EQUALITY: mjtConstraint = mjtConstraint(0); - pub const FRICTION_DOF: mjtConstraint = mjtConstraint(1); - pub const FRICTION_TENDON: mjtConstraint = mjtConstraint(2); - pub const LIMIT_JOINT: mjtConstraint = mjtConstraint(3); - pub const LIMIT_TENDON: mjtConstraint = mjtConstraint(4); - pub const CONTACT_FRICTIONLESS: mjtConstraint = mjtConstraint(5); - pub const CONTACT_PYRAMIDAL: mjtConstraint = mjtConstraint(6); - pub const CONTACT_ELLIPTIC: mjtConstraint = mjtConstraint(7); -} -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mjtConstraint(pub(crate) ::core::ffi::c_uint); -impl mjtConstraintState { - pub const SATISFIED: mjtConstraintState = mjtConstraintState(0); - pub const QUADRATIC: mjtConstraintState = mjtConstraintState(1); - pub const LINEARNEG: mjtConstraintState = mjtConstraintState(2); - pub const LINEARPOS: mjtConstraintState = mjtConstraintState(3); - pub const CONE: mjtConstraintState = mjtConstraintState(4); -} -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mjtConstraintState(pub(crate) ::core::ffi::c_uint); -pub const mjNWARNING: usize = mjtWarning::mjNWARNING.0 as usize; -impl mjtWarning { - pub const INERTIA: mjtWarning = mjtWarning(0); - pub const CONTACTFULL: mjtWarning = mjtWarning(1); - pub const CNSTRFULL: mjtWarning = mjtWarning(2); - pub const VGEOMFULL: mjtWarning = mjtWarning(3); - pub const BADQPOS: mjtWarning = mjtWarning(4); - pub const BADQVEL: mjtWarning = mjtWarning(5); - pub const BADQACC: mjtWarning = mjtWarning(6); - pub const BADCTRL: mjtWarning = mjtWarning(7); - const mjNWARNING: mjtWarning = mjtWarning(8); -} -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mjtWarning(pub(crate) ::core::ffi::c_uint); -pub const mjNTIMER: usize = mjtTimer::mjNTIMER.0 as usize; -impl mjtTimer { - pub const STEP: mjtTimer = mjtTimer(0); - pub const FORWARD: mjtTimer = mjtTimer(1); - pub const INVERSE: mjtTimer = mjtTimer(2); - pub const POSITION: mjtTimer = mjtTimer(3); - pub const VELOCITY: mjtTimer = mjtTimer(4); - pub const ACTUATION: mjtTimer = mjtTimer(5); - pub const CONSTRAINT: mjtTimer = mjtTimer(6); - pub const ADVANCE: mjtTimer = mjtTimer(7); - pub const POS_KINEMATICS: mjtTimer = mjtTimer(8); - pub const POS_INERTIA: mjtTimer = mjtTimer(9); - pub const POS_COLLISION: mjtTimer = mjtTimer(10); - pub const POS_MAKE: mjtTimer = mjtTimer(11); - pub const POS_PROJECT: mjtTimer = mjtTimer(12); - pub const COL_BROAD: mjtTimer = mjtTimer(13); - pub const COL_NARROW: mjtTimer = mjtTimer(14); - const mjNTIMER: mjtTimer = mjtTimer(15); -} -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mjtTimer(pub(crate) ::core::ffi::c_uint); -impl mjtSleepState { - pub const STATIC: mjtSleepState = mjtSleepState(-1); - pub const ASLEEP: mjtSleepState = mjtSleepState(0); - pub const AWAKE: mjtSleepState = mjtSleepState(1); +pub struct mjPreContact { + pub(crate) dist: mjtNum, + pub(crate) pos: [mjtNum; 3usize], + pub(crate) normal: [mjtNum; 3usize], + pub(crate) tangent: [mjtNum; 3usize], } -#[repr(transparent)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct mjtSleepState(pub(crate) ::core::ffi::c_int); #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct mjContact { @@ -1396,8 +1526,9 @@ pub struct mjData { pub(crate) pstack: usize, pub(crate) pbase: usize, pub(crate) parena: usize, + pub(crate) threadpool: usize, + pub(crate) threadlock: mjtBool, pub(crate) maxuse_stack: mjtSize, - pub(crate) maxuse_threadstack: [mjtSize; 128usize], pub(crate) maxuse_arena: mjtSize, pub(crate) maxuse_con: ::core::ffi::c_int, pub(crate) maxuse_efc: ::core::ffi::c_int, @@ -1405,7 +1536,7 @@ pub struct mjData { pub(crate) solver_niter: [::core::ffi::c_int; 20usize], pub(crate) solver_nnz: [::core::ffi::c_int; 20usize], pub(crate) solver_fwdinv: [mjtNum; 2usize], - pub(crate) warning: [mjWarningStat; 8usize], + pub(crate) warning: [mjWarningStat; 7usize], pub(crate) timer: [mjTimerStat; 15usize], pub(crate) ncon: ::core::ffi::c_int, pub(crate) ne: ::core::ffi::c_int, @@ -1413,6 +1544,7 @@ pub struct mjData { pub(crate) nl: ::core::ffi::c_int, pub(crate) nefc: ::core::ffi::c_int, pub(crate) nJ: ::core::ffi::c_int, + pub(crate) nY: ::core::ffi::c_int, pub(crate) nA: ::core::ffi::c_int, pub(crate) nisland: ::core::ffi::c_int, pub(crate) nidof: ::core::ffi::c_int, @@ -1420,6 +1552,10 @@ pub struct mjData { pub(crate) nbody_awake: ::core::ffi::c_int, pub(crate) nparent_awake: ::core::ffi::c_int, pub(crate) nv_awake: ::core::ffi::c_int, + pub(crate) flg_energypos: mjtBool, + pub(crate) flg_energyvel: mjtBool, + pub(crate) flg_subtreevel: mjtBool, + pub(crate) flg_rnepost: mjtBool, pub(crate) time: mjtNum, pub(crate) energy: [mjtNum; 2usize], pub(crate) buffer: *mut ::core::ffi::c_void, @@ -1427,12 +1563,13 @@ pub struct mjData { pub(crate) qpos: *mut mjtNum, pub(crate) qvel: *mut mjtNum, pub(crate) act: *mut mjtNum, + pub(crate) history: *mut mjtNum, pub(crate) qacc_warmstart: *mut mjtNum, pub(crate) plugin_state: *mut mjtNum, pub(crate) ctrl: *mut mjtNum, pub(crate) qfrc_applied: *mut mjtNum, pub(crate) xfrc_applied: *mut mjtNum, - pub(crate) eq_active: *mut mjtByte, + pub(crate) eq_active: *mut mjtBool, pub(crate) mocap_pos: *mut mjtNum, pub(crate) mocap_quat: *mut mjtNum, pub(crate) qacc: *mut mjtNum, @@ -1462,17 +1599,13 @@ pub struct mjData { pub(crate) cinert: *mut mjtNum, pub(crate) flexvert_xpos: *mut mjtNum, pub(crate) flexelem_aabb: *mut mjtNum, - pub(crate) flexedge_J_rownnz: *mut ::core::ffi::c_int, - pub(crate) flexedge_J_rowadr: *mut ::core::ffi::c_int, - pub(crate) flexedge_J_colind: *mut ::core::ffi::c_int, pub(crate) flexedge_J: *mut mjtNum, pub(crate) flexedge_length: *mut mjtNum, + pub(crate) flexvert_J: *mut mjtNum, + pub(crate) flexvert_length: *mut mjtNum, pub(crate) bvh_aabb_dyn: *mut mjtNum, pub(crate) ten_wrapadr: *mut ::core::ffi::c_int, pub(crate) ten_wrapnum: *mut ::core::ffi::c_int, - pub(crate) ten_J_rownnz: *mut ::core::ffi::c_int, - pub(crate) ten_J_rowadr: *mut ::core::ffi::c_int, - pub(crate) ten_J_colind: *mut ::core::ffi::c_int, pub(crate) ten_J: *mut mjtNum, pub(crate) ten_length: *mut mjtNum, pub(crate) wrap_obj: *mut ::core::ffi::c_int, @@ -1487,7 +1620,7 @@ pub struct mjData { pub(crate) M: *mut mjtNum, pub(crate) qLD: *mut mjtNum, pub(crate) qLDiagInv: *mut mjtNum, - pub(crate) bvh_active: *mut mjtByte, + pub(crate) bvh_active: *mut mjtBool, pub(crate) tree_awake: *mut ::core::ffi::c_int, pub(crate) body_awake: *mut ::core::ffi::c_int, pub(crate) body_awake_ind: *mut ::core::ffi::c_int, @@ -1530,7 +1663,7 @@ pub struct mjData { pub(crate) efc_pos: *mut mjtNum, pub(crate) efc_margin: *mut mjtNum, pub(crate) efc_frictionloss: *mut mjtNum, - pub(crate) efc_diagApprox: *mut mjtNum, + pub(crate) efc_diagA: *mut mjtNum, pub(crate) efc_KBIP: *mut mjtNum, pub(crate) efc_D: *mut mjtNum, pub(crate) efc_R: *mut mjtNum, @@ -1547,12 +1680,6 @@ pub struct mjData { pub(crate) map_idof2dof: *mut ::core::ffi::c_int, pub(crate) ifrc_smooth: *mut mjtNum, pub(crate) iacc_smooth: *mut mjtNum, - pub(crate) iM_rownnz: *mut ::core::ffi::c_int, - pub(crate) iM_rowadr: *mut ::core::ffi::c_int, - pub(crate) iM_colind: *mut ::core::ffi::c_int, - pub(crate) iM: *mut mjtNum, - pub(crate) iLD: *mut mjtNum, - pub(crate) iLDiagInv: *mut mjtNum, pub(crate) iacc: *mut mjtNum, pub(crate) efc_island: *mut ::core::ffi::c_int, pub(crate) island_ne: *mut ::core::ffi::c_int, @@ -1563,14 +1690,13 @@ pub struct mjData { pub(crate) map_iefc2efc: *mut ::core::ffi::c_int, pub(crate) iefc_type: *mut ::core::ffi::c_int, pub(crate) iefc_id: *mut ::core::ffi::c_int, - pub(crate) iefc_J_rownnz: *mut ::core::ffi::c_int, - pub(crate) iefc_J_rowadr: *mut ::core::ffi::c_int, - pub(crate) iefc_J_rowsuper: *mut ::core::ffi::c_int, - pub(crate) iefc_J_colind: *mut ::core::ffi::c_int, - pub(crate) iefc_J: *mut mjtNum, pub(crate) iefc_frictionloss: *mut mjtNum, pub(crate) iefc_D: *mut mjtNum, pub(crate) iefc_R: *mut mjtNum, + pub(crate) efc_Y_rownnz: *mut ::core::ffi::c_int, + pub(crate) efc_Y_rowadr: *mut ::core::ffi::c_int, + pub(crate) efc_Y_colind: *mut ::core::ffi::c_int, + pub(crate) efc_Y: *mut mjtNum, pub(crate) efc_AR_rownnz: *mut ::core::ffi::c_int, pub(crate) efc_AR_rowadr: *mut ::core::ffi::c_int, pub(crate) efc_AR_colind: *mut ::core::ffi::c_int, @@ -1584,7 +1710,6 @@ pub struct mjData { pub(crate) efc_state: *mut ::core::ffi::c_int, pub(crate) efc_force: *mut mjtNum, pub(crate) ifrc_constraint: *mut mjtNum, - pub(crate) threadpool: usize, pub(crate) signature: u64, } pub type mjfGeneric = @@ -1607,8 +1732,8 @@ pub type mjfAct = ::core::option::Option< pub type mjfCollision = ::core::option::Option< unsafe extern "C" fn( m: *const mjModel, - d: *const mjData, - con: *mut mjContact, + d: *mut mjData, + con: *mut mjPreContact, g1: ::core::ffi::c_int, g2: ::core::ffi::c_int, margin: mjtNum, @@ -1703,6 +1828,30 @@ impl mjtOrientation { #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct mjtOrientation(pub(crate) ::core::ffi::c_uint); +impl mjtConflict { + pub const WARNING: mjtConflict = mjtConflict(0); + pub const MERGE: mjtConflict = mjtConflict(1); + pub const ERROR: mjtConflict = mjtConflict(2); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtConflict(pub(crate) ::core::ffi::c_uint); +pub const mjNCTIMER: usize = mjtCTimer::mjNCTIMER.0 as usize; +impl mjtCTimer { + pub const TOTAL: mjtCTimer = mjtCTimer(0); + pub const ASSETS: mjtCTimer = mjtCTimer(1); + pub const TEXTURE: mjtCTimer = mjtCTimer(2); + pub const MESH_LOAD: mjtCTimer = mjtCTimer(3); + pub const MESH_HULL: mjtCTimer = mjtCTimer(4); + pub const MESH_POLYGON: mjtCTimer = mjtCTimer(5); + pub const MESH_INERTIA: mjtCTimer = mjtCTimer(6); + pub const MESH_BVH: mjtCTimer = mjtCTimer(7); + pub const MESH_OCTREE: mjtCTimer = mjtCTimer(8); + const mjNCTIMER: mjtCTimer = mjtCTimer(9); +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct mjtCTimer(pub(crate) ::core::ffi::c_uint); #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct mjsElement { @@ -1727,9 +1876,25 @@ pub struct mjsCompiler { pub(crate) inertiagrouprange: [::core::ffi::c_int; 2usize], pub(crate) saveinertial: mjtByte, pub(crate) alignfree: ::core::ffi::c_int, + pub(crate) conflict: ::core::ffi::c_int, pub(crate) LRopt: mjLROpt, pub(crate) meshdir: *mut mjString, pub(crate) texturedir: *mut mjString, + pub(crate) authored: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct mjsAuthored { + pub(crate) option: u64, + pub(crate) disableflags: ::core::ffi::c_int, + pub(crate) enableflags: ::core::ffi::c_int, + pub(crate) disableactuator: ::core::ffi::c_int, + pub(crate) visual_global: u64, + pub(crate) visual_quality: u64, + pub(crate) visual_headlight: u64, + pub(crate) visual_map: u64, + pub(crate) visual_scale: u64, + pub(crate) visual_rgba: u64, } #[repr(C)] #[derive(Debug)] @@ -1759,6 +1924,7 @@ pub struct mjSpec { pub(crate) comment: *mut mjString, pub(crate) modelfiledir: *mut mjString, pub(crate) hasImplicitPluginElem: mjtByte, + pub(crate) authored: mjsAuthored, } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -1819,7 +1985,7 @@ pub struct mjsJoint { pub(crate) axis: [f64; 3usize], pub(crate) ref_: f64, pub(crate) align: ::core::ffi::c_int, - pub(crate) stiffness: f64, + pub(crate) stiffness: [f64; 3usize], pub(crate) springref: f64, pub(crate) springdamper: [f64; 2usize], pub(crate) limited: ::core::ffi::c_int, @@ -1830,7 +1996,7 @@ pub struct mjsJoint { pub(crate) actfrclimited: ::core::ffi::c_int, pub(crate) actfrcrange: [f64; 2usize], pub(crate) armature: f64, - pub(crate) damping: f64, + pub(crate) damping: [f64; 3usize], pub(crate) frictionloss: f64, pub(crate) solref_friction: [mjtNum; 2usize], pub(crate) solimp_friction: [mjtNum; 5usize], @@ -1899,12 +2065,13 @@ pub struct mjsCamera { pub(crate) alt: mjsOrientation, pub(crate) mode: mjtCamLight, pub(crate) targetbody: *mut mjString, - pub(crate) orthographic: ::core::ffi::c_int, + pub(crate) proj: mjtProjection, + pub(crate) resolution: [::core::ffi::c_int; 2usize], + pub(crate) output: ::core::ffi::c_int, pub(crate) fovy: f64, pub(crate) ipd: f64, pub(crate) intrinsic: [f32; 4usize], pub(crate) sensor_size: [f32; 2usize], - pub(crate) resolution: [f32; 2usize], pub(crate) focal_length: [f32; 2usize], pub(crate) focal_pixel: [f32; 2usize], pub(crate) principal_length: [f32; 2usize], @@ -1951,10 +2118,10 @@ pub struct mjsFlex { pub(crate) gap: f64, pub(crate) dim: ::core::ffi::c_int, pub(crate) radius: f64, + pub(crate) size: [f64; 3usize], pub(crate) internal: mjtByte, pub(crate) flatskin: mjtByte, pub(crate) selfcollide: ::core::ffi::c_int, - pub(crate) vertcollide: ::core::ffi::c_int, pub(crate) passive: ::core::ffi::c_int, pub(crate) activelayers: ::core::ffi::c_int, pub(crate) group: ::core::ffi::c_int, @@ -1967,6 +2134,8 @@ pub struct mjsFlex { pub(crate) damping: f64, pub(crate) thickness: f64, pub(crate) elastic2d: ::core::ffi::c_int, + pub(crate) cellcount: [::core::ffi::c_int; 3usize], + pub(crate) order: ::core::ffi::c_int, pub(crate) nodebody: *mut mjStringVec, pub(crate) vertbody: *mut mjStringVec, pub(crate) node: *mut mjDoubleVec, @@ -1997,6 +2166,7 @@ pub struct mjsMesh { pub(crate) userfacetexcoord: *mut mjIntVec, pub(crate) plugin: mjsPlugin, pub(crate) material: *mut mjString, + pub(crate) octree_maxdepth: ::core::ffi::c_int, pub(crate) info: *mut mjString, } #[repr(C)] @@ -2112,9 +2282,9 @@ pub struct mjsEquality { #[derive(Debug, Copy, Clone)] pub struct mjsTendon { pub(crate) element: *mut mjsElement, - pub(crate) stiffness: f64, + pub(crate) stiffness: [f64; 3usize], pub(crate) springlength: [f64; 2usize], - pub(crate) damping: f64, + pub(crate) damping: [f64; 3usize], pub(crate) frictionloss: f64, pub(crate) solref_friction: [mjtNum; 2usize], pub(crate) solimp_friction: [mjtNum; 5usize], @@ -2160,6 +2330,8 @@ pub struct mjsActuator { pub(crate) cranklength: f64, pub(crate) lengthrange: [f64; 2usize], pub(crate) inheritrange: f64, + pub(crate) damping: [f64; 3usize], + pub(crate) armature: f64, pub(crate) ctrllimited: ::core::ffi::c_int, pub(crate) ctrlrange: [f64; 2usize], pub(crate) forcelimited: ::core::ffi::c_int, @@ -2167,6 +2339,9 @@ pub struct mjsActuator { pub(crate) actlimited: ::core::ffi::c_int, pub(crate) actrange: [f64; 2usize], pub(crate) group: ::core::ffi::c_int, + pub(crate) nsample: ::core::ffi::c_int, + pub(crate) interp: ::core::ffi::c_int, + pub(crate) delay: f64, pub(crate) userdata: *mut mjDoubleVec, pub(crate) plugin: mjsPlugin, pub(crate) info: *mut mjString, @@ -2186,6 +2361,10 @@ pub struct mjsSensor { pub(crate) dim: ::core::ffi::c_int, pub(crate) cutoff: f64, pub(crate) noise: f64, + pub(crate) nsample: ::core::ffi::c_int, + pub(crate) interp: ::core::ffi::c_int, + pub(crate) delay: f64, + pub(crate) interval: [f64; 2usize], pub(crate) userdata: *mut mjDoubleVec, pub(crate) plugin: mjsPlugin, pub(crate) info: *mut mjString, @@ -2420,10 +2599,11 @@ impl mjtRndFlag { pub const SKYBOX: mjtRndFlag = mjtRndFlag(4); pub const FOG: mjtRndFlag = mjtRndFlag(5); pub const HAZE: mjtRndFlag = mjtRndFlag(6); - pub const SEGMENT: mjtRndFlag = mjtRndFlag(7); - pub const IDCOLOR: mjtRndFlag = mjtRndFlag(8); - pub const CULL_FACE: mjtRndFlag = mjtRndFlag(9); - const mjNRNDFLAG: mjtRndFlag = mjtRndFlag(10); + pub const DEPTH: mjtRndFlag = mjtRndFlag(7); + pub const SEGMENT: mjtRndFlag = mjtRndFlag(8); + pub const IDCOLOR: mjtRndFlag = mjtRndFlag(9); + pub const CULL_FACE: mjtRndFlag = mjtRndFlag(10); + const mjNRNDFLAG: mjtRndFlag = mjtRndFlag(11); } #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -2575,7 +2755,7 @@ pub struct mjvScene { pub(crate) rotate: [f32; 4usize], pub(crate) scale: f32, pub(crate) stereo: ::core::ffi::c_int, - pub(crate) flags: [mjtByte; 10usize], + pub(crate) flags: [mjtByte; 11usize], pub(crate) framewidth: ::core::ffi::c_int, pub(crate) framergb: [f32; 3usize], pub(crate) status: ::core::ffi::c_int, @@ -2622,6 +2802,7 @@ pub struct mjvFigure { pub struct mjResource { pub(crate) name: *mut ::core::ffi::c_char, pub(crate) data: *mut ::core::ffi::c_void, + pub(crate) vfs: *mut mjVFS, pub(crate) timestamp: [::core::ffi::c_char; 512usize], pub(crate) provider: *const mjpResourceProvider, } @@ -2634,13 +2815,10 @@ pub type mjfReadResource = ::core::option::Option< ) -> ::core::ffi::c_int, >; pub type mjfCloseResource = ::core::option::Option; -pub type mjfGetResourceDir = ::core::option::Option< - unsafe extern "C" fn( - resource: *mut mjResource, - dir: *mut *const ::core::ffi::c_char, - ndir: *mut ::core::ffi::c_int, - ), ->; +pub type mjfMountResource = + ::core::option::Option ::core::ffi::c_int>; +pub type mjfUnmountResource = + ::core::option::Option ::core::ffi::c_int>; pub type mjfResourceModified = ::core::option::Option< unsafe extern "C" fn( resource: *const mjResource, @@ -2654,12 +2832,14 @@ pub struct mjpResourceProvider { pub(crate) open: mjfOpenResource, pub(crate) read: mjfReadResource, pub(crate) close: mjfCloseResource, - pub(crate) getdir: mjfGetResourceDir, + pub(crate) mount: mjfMountResource, + pub(crate) unmount: mjfUnmountResource, pub(crate) modified: mjfResourceModified, pub(crate) data: *mut ::core::ffi::c_void, } -pub type mjfDecode = - ::core::option::Option *mut mjSpec>; +pub type mjfDecode = ::core::option::Option< + unsafe extern "C" fn(resource: *mut mjResource, vfs: *const mjVFS) -> *mut mjSpec, +>; pub type mjfCanDecode = ::core::option::Option ::core::ffi::c_int>; #[repr(C)] @@ -2670,6 +2850,22 @@ pub struct mjpDecoder { pub(crate) can_decode: mjfCanDecode, pub(crate) decode: mjfDecode, } +pub type mjfEncode = ::core::option::Option< + unsafe extern "C" fn( + s: *const mjSpec, + m: *const mjModel, + vfs: *const mjVFS, + resource: *mut mjResource, + ) -> ::core::ffi::c_int, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct mjpEncoder { + pub(crate) content_type: *const ::core::ffi::c_char, + pub(crate) extension: *const ::core::ffi::c_char, + pub(crate) encode: mjfEncode, + pub(crate) close_resource: mjfCloseResource, +} impl mjtPluginCapabilityBit { pub const ACTUATOR: mjtPluginCapabilityBit = mjtPluginCapabilityBit(1); pub const SENSOR: mjtPluginCapabilityBit = mjtPluginCapabilityBit(2); @@ -2863,6 +3059,31 @@ impl mjtFont { #[repr(transparent)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct mjtFont(pub(crate) ::core::ffi::c_uint); +pub const mjPIXEL_FORMAT_UNKNOWN: mjrPixelFormat = 0; +pub const mjPIXEL_FORMAT_R8: mjrPixelFormat = 1; +pub const mjPIXEL_FORMAT_RGB8: mjrPixelFormat = 2; +pub const mjPIXEL_FORMAT_RGBA8: mjrPixelFormat = 3; +pub const mjPIXEL_FORMAT_R32F: mjrPixelFormat = 4; +pub const mjPIXEL_FORMAT_DEPTH32F: mjrPixelFormat = 5; +pub const mjPIXEL_FORMAT_KTX: mjrPixelFormat = 6; +pub type mjrPixelFormat = ::core::ffi::c_uint; +pub const mjVERTEX_ATTRIBUTE_USAGE_POSITION: mjrVertexAttributeUsage = 0; +pub const mjVERTEX_ATTRIBUTE_USAGE_NORMAL: mjrVertexAttributeUsage = 1; +pub const mjVERTEX_ATTRIBUTE_USAGE_TANGENTS: mjrVertexAttributeUsage = 2; +pub const mjVERTEX_ATTRIBUTE_USAGE_UV: mjrVertexAttributeUsage = 3; +pub const mjVERTEX_ATTRIBUTE_USAGE_COLOR: mjrVertexAttributeUsage = 4; +pub type mjrVertexAttributeUsage = ::core::ffi::c_uint; +pub const mjVERTEX_ATTRIBUTE_TYPE_FLOAT2: mjrVertexAttributeType = 0; +pub const mjVERTEX_ATTRIBUTE_TYPE_FLOAT3: mjrVertexAttributeType = 1; +pub const mjVERTEX_ATTRIBUTE_TYPE_FLOAT4: mjrVertexAttributeType = 2; +pub const mjVERTEX_ATTRIBUTE_TYPE_UBYTE4: mjrVertexAttributeType = 3; +pub type mjrVertexAttributeType = ::core::ffi::c_uint; +pub const mjINDEX_TYPE_U16: mjrIndexType = 0; +pub const mjINDEX_TYPE_U32: mjrIndexType = 1; +pub type mjrIndexType = ::core::ffi::c_uint; +pub const mjMESH_PRIMITIVE_TYPE_TRIANGLES: mjrMeshPrimitiveType = 0; +pub const mjMESH_PRIMITIVE_TYPE_LINES: mjrMeshPrimitiveType = 1; +pub type mjrMeshPrimitiveType = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct mjrRect { @@ -2872,6 +3093,17 @@ pub struct mjrRect { pub(crate) height: ::core::ffi::c_int, } #[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct mjrVertexAttribute { + pub(crate) bytes: *const ::core::ffi::c_void, + pub(crate) usage: ::core::ffi::c_int, + pub(crate) type_: ::core::ffi::c_int, +} +pub use self::mjtColorSpace as mjrColorSpace; +pub use self::mjtLightType as mjrLightType; +pub use self::mjtTexture as mjrSamplerType; +pub type mjrCamera = mjvGLCamera; +#[repr(C)] #[derive(Debug)] pub struct mjrContext { pub(crate) lineWidth: f32, @@ -3174,14 +3406,14 @@ pub struct mjuiDef { pub(crate) otherint: ::core::ffi::c_int, } unsafe extern "C" { - pub static mut mju_user_error: - ::core::option::Option; - pub static mut mju_user_warning: - ::core::option::Option; pub static mut mju_user_malloc: ::core::option::Option *mut ::core::ffi::c_void>; pub static mut mju_user_free: ::core::option::Option; + pub static mut mju_user_error: + ::core::option::Option; + pub static mut mju_user_warning: + ::core::option::Option; pub static mut mjcb_passive: mjfGeneric; pub static mut mjcb_control: mjfGeneric; pub static mut mjcb_contactfilter: mjfConFilt; @@ -3191,14 +3423,24 @@ unsafe extern "C" { pub static mut mjcb_act_gain: mjfAct; pub static mut mjcb_act_bias: mjfAct; pub static mut mjCOLLISIONFUNC: [[mjfCollision; 9usize]; 9usize]; - pub static mut mjDISABLESTRING: [*const ::core::ffi::c_char; 19usize]; + pub static mut mjDISABLESTRING: [*const ::core::ffi::c_char; 20usize]; pub static mut mjENABLESTRING: [*const ::core::ffi::c_char; 6usize]; pub static mut mjTIMERSTRING: [*const ::core::ffi::c_char; 15usize]; pub static mut mjLABELSTRING: [*const ::core::ffi::c_char; 17usize]; pub static mut mjFRAMESTRING: [*const ::core::ffi::c_char; 8usize]; pub static mut mjVISSTRING: [[*const ::core::ffi::c_char; 3usize]; 31usize]; - pub static mut mjRNDSTRING: [[*const ::core::ffi::c_char; 3usize]; 10usize]; + pub static mut mjRNDSTRING: [[*const ::core::ffi::c_char; 3usize]; 11usize]; + pub static mut mjTOPICSTRING: [*const ::core::ffi::c_char; 3usize]; pub fn mj_defaultVFS(vfs: *mut mjVFS); + pub fn mj_mountVFS( + vfs: *mut mjVFS, + filepath: *const ::core::ffi::c_char, + provider: *const mjpResourceProvider, + ) -> ::core::ffi::c_int; + pub fn mj_unmountVFS( + vfs: *mut mjVFS, + filename: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; pub fn mj_addFileVFS( vfs: *mut mjVFS, directory: *const ::core::ffi::c_char, @@ -3214,6 +3456,15 @@ unsafe extern "C" { vfs: *mut mjVFS, filename: *const ::core::ffi::c_char, ) -> ::core::ffi::c_int; + pub fn mj_containsBufferVFS( + vfs: *mut mjVFS, + name: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; + pub fn mj_containsFileVFS( + vfs: *mut mjVFS, + directory: *const ::core::ffi::c_char, + filename: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; pub fn mj_deleteVFS(vfs: *mut mjVFS); pub fn mj_getCacheSize(cache: *const mjCache) -> usize; pub fn mj_getCacheCapacity(cache: *const mjCache) -> usize; @@ -3245,6 +3496,15 @@ unsafe extern "C" { error: *mut ::core::ffi::c_char, error_sz: ::core::ffi::c_int, ) -> *mut mjSpec; + pub fn mj_encode( + s: *const mjSpec, + m: *const mjModel, + filename: *const ::core::ffi::c_char, + content_type: *const ::core::ffi::c_char, + vfs: *const mjVFS, + error: *mut ::core::ffi::c_char, + error_sz: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; pub fn mj_compile(s: *mut mjSpec, vfs: *const mjVFS) -> *mut mjModel; pub fn mj_copyBack(s: *mut mjSpec, m: *const mjModel) -> ::core::ffi::c_int; pub fn mj_recompile( @@ -3306,6 +3566,10 @@ unsafe extern "C" { buffer_sz: ::core::ffi::c_int, ); pub fn mj_loadModel(filename: *const ::core::ffi::c_char, vfs: *const mjVFS) -> *mut mjModel; + pub fn mj_loadModelBuffer( + buffer: *const ::core::ffi::c_void, + buffer_sz: ::core::ffi::c_int, + ) -> *mut mjModel; pub fn mj_deleteModel(m: *mut mjModel); pub fn mj_sizeModel(m: *const mjModel) -> mjtSize; pub fn mj_makeData(m: *const mjModel) -> *mut mjData; @@ -3431,6 +3695,12 @@ unsafe extern "C" { result: *mut mjtNum, ); pub fn mj_rnePostConstraint(m: *const mjModel, d: *mut mjData); + pub fn mj_maxContact( + m: *const mjModel, + g1: ::core::ffi::c_int, + g2: ::core::ffi::c_int, + has_margin: ::core::ffi::c_int, + ) -> ::core::ffi::c_int; pub fn mj_collision(m: *const mjModel, d: *mut mjData); pub fn mj_makeConstraint(m: *const mjModel, d: *mut mjData); pub fn mj_island(m: *const mjModel, d: *mut mjData); @@ -3443,31 +3713,61 @@ unsafe extern "C" { cost: *mut [mjtNum; 1usize], flg_coneHessian: ::core::ffi::c_int, ); - pub fn mj_stateSize(m: *const mjModel, sig: ::core::ffi::c_uint) -> ::core::ffi::c_int; + pub fn mj_stateSize(m: *const mjModel, sig: ::core::ffi::c_int) -> ::core::ffi::c_int; pub fn mj_getState( m: *const mjModel, d: *const mjData, state: *mut mjtNum, - sig: ::core::ffi::c_uint, + sig: ::core::ffi::c_int, ); pub fn mj_extractState( m: *const mjModel, src: *const mjtNum, - srcsig: ::core::ffi::c_uint, + srcsig: ::core::ffi::c_int, dst: *mut mjtNum, - dstsig: ::core::ffi::c_uint, + dstsig: ::core::ffi::c_int, ); pub fn mj_setState( m: *const mjModel, d: *mut mjData, state: *const mjtNum, - sig: ::core::ffi::c_uint, + sig: ::core::ffi::c_int, ); pub fn mj_copyState( m: *const mjModel, src: *const mjData, dst: *mut mjData, - sig: ::core::ffi::c_uint, + sig: ::core::ffi::c_int, + ); + pub fn mj_readCtrl( + m: *const mjModel, + d: *const mjData, + id: ::core::ffi::c_int, + time: mjtNum, + interp: ::core::ffi::c_int, + ) -> mjtNum; + pub fn mj_readSensor( + m: *const mjModel, + d: *const mjData, + id: ::core::ffi::c_int, + time: mjtNum, + result: *mut mjtNum, + interp: ::core::ffi::c_int, + ) -> *const mjtNum; + pub fn mj_initCtrlHistory( + m: *const mjModel, + d: *mut mjData, + id: ::core::ffi::c_int, + times: *const mjtNum, + values: *const mjtNum, + ); + pub fn mj_initSensorHistory( + m: *const mjModel, + d: *mut mjData, + id: ::core::ffi::c_int, + times: *const mjtNum, + values: *const mjtNum, + phase: mjtNum, ); pub fn mj_setKeyframe(m: *mut mjModel, d: *const mjData, k: ::core::ffi::c_int); pub fn mj_addContact( @@ -3555,7 +3855,7 @@ unsafe extern "C" { type_: ::core::ffi::c_int, id: ::core::ffi::c_int, ) -> *const ::core::ffi::c_char; - pub fn mj_fullM(m: *const mjModel, dst: *mut mjtNum, M: *const mjtNum); + pub fn mj_fullM(m: *const mjModel, d: *const mjData, dst: *mut mjtNum); pub fn mj_mulM(m: *const mjModel, d: *const mjData, res: *mut mjtNum, vec: *const mjtNum); pub fn mj_mulM2(m: *const mjModel, d: *const mjData, res: *mut mjtNum, vec: *const mjtNum); pub fn mj_addM( @@ -3593,7 +3893,7 @@ unsafe extern "C" { ); pub fn mj_geomDistance( m: *const mjModel, - d: *const mjData, + d: *mut mjData, geom1: ::core::ffi::c_int, geom2: ::core::ffi::c_int, distmax: mjtNum, @@ -3637,35 +3937,38 @@ unsafe extern "C" { ); pub fn mj_version() -> ::core::ffi::c_int; pub fn mj_versionString() -> *const ::core::ffi::c_char; + pub fn mj_ray( + m: *const mjModel, + d: *const mjData, + pnt: *const [mjtNum; 3usize], + vec: *const [mjtNum; 3usize], + geomgroup: *const mjtByte, + flg_static: mjtBool, + bodyexclude: ::core::ffi::c_int, + geomid: *mut [::core::ffi::c_int; 1usize], + normal: *mut [mjtNum; 3usize], + ) -> mjtNum; pub fn mj_multiRay( m: *const mjModel, d: *mut mjData, pnt: *const [mjtNum; 3usize], - vec: *const [mjtNum; 3usize], + vec: *const mjtNum, geomgroup: *const mjtByte, - flg_static: mjtByte, + flg_static: mjtBool, bodyexclude: ::core::ffi::c_int, geomid: *mut ::core::ffi::c_int, dist: *mut mjtNum, + normal: *mut mjtNum, nray: ::core::ffi::c_int, cutoff: mjtNum, ); - pub fn mj_ray( - m: *const mjModel, - d: *const mjData, - pnt: *const [mjtNum; 3usize], - vec: *const [mjtNum; 3usize], - geomgroup: *const mjtByte, - flg_static: mjtByte, - bodyexclude: ::core::ffi::c_int, - geomid: *mut [::core::ffi::c_int; 1usize], - ) -> mjtNum; pub fn mj_rayHfield( m: *const mjModel, d: *const mjData, geomid: ::core::ffi::c_int, pnt: *const [mjtNum; 3usize], vec: *const [mjtNum; 3usize], + normal: *mut [mjtNum; 3usize], ) -> mjtNum; pub fn mj_rayMesh( m: *const mjModel, @@ -3673,6 +3976,7 @@ unsafe extern "C" { geomid: ::core::ffi::c_int, pnt: *const [mjtNum; 3usize], vec: *const [mjtNum; 3usize], + normal: *mut [mjtNum; 3usize], ) -> mjtNum; pub fn mju_rayGeom( pos: *const [mjtNum; 3usize], @@ -3681,19 +3985,21 @@ unsafe extern "C" { pnt: *const [mjtNum; 3usize], vec: *const [mjtNum; 3usize], geomtype: ::core::ffi::c_int, + normal: *mut [mjtNum; 3usize], ) -> mjtNum; - pub fn mju_rayFlex( + pub fn mj_rayFlex( m: *const mjModel, d: *const mjData, flex_layer: ::core::ffi::c_int, - flg_vert: mjtByte, - flg_edge: mjtByte, - flg_face: mjtByte, - flg_skin: mjtByte, + flg_vert: mjtBool, + flg_edge: mjtBool, + flg_face: mjtBool, + flg_skin: mjtBool, flexid: ::core::ffi::c_int, pnt: *const [mjtNum; 3usize], vec: *const [mjtNum; 3usize], vertid: *mut [::core::ffi::c_int; 1usize], + normal: *mut [mjtNum; 3usize], ) -> mjtNum; pub fn mju_raySkin( nface: ::core::ffi::c_int, @@ -3966,18 +4272,25 @@ unsafe extern "C" { ) -> *mut mjuiItem; pub fn mjui_render(ui: *mut mjUI, state: *const mjuiState, con: *const mjrContext); pub fn mju_error(msg: *const ::core::ffi::c_char, ...); - pub fn mju_error_i(msg: *const ::core::ffi::c_char, i: ::core::ffi::c_int); - pub fn mju_error_s(msg: *const ::core::ffi::c_char, text: *const ::core::ffi::c_char); pub fn mju_warning(msg: *const ::core::ffi::c_char, ...); - pub fn mju_warning_i(msg: *const ::core::ffi::c_char, i: ::core::ffi::c_int); - pub fn mju_warning_s(msg: *const ::core::ffi::c_char, text: *const ::core::ffi::c_char); pub fn mju_clearHandlers(); + pub fn mju_setLogHandler(handler: mjfLogHandler) -> mjfLogHandler; + pub fn mju_getLogConfig() -> mjLogConfig; + pub fn mju_setLogConfig(config: mjLogConfig); + pub fn mju_info(topic: ::core::ffi::c_int, msg: *const ::core::ffi::c_char, ...); + pub fn mju_message(msg: *const mjLogMessage); pub fn mju_malloc(size: usize) -> *mut ::core::ffi::c_void; pub fn mju_free(ptr: *mut ::core::ffi::c_void); pub fn mj_warning(d: *mut mjData, warning: ::core::ffi::c_int, info: ::core::ffi::c_int); pub fn mju_writeLog(type_: *const ::core::ffi::c_char, msg: *const ::core::ffi::c_char); pub fn mjs_getError(s: *mut mjSpec) -> *const ::core::ffi::c_char; + pub fn mjs_getTimer(s: *mut mjSpec) -> *const f64; pub fn mjs_isWarning(s: *mut mjSpec) -> ::core::ffi::c_int; + pub fn mjs_numWarnings(spec: *const mjSpec) -> ::core::ffi::c_int; + pub fn mjs_getWarning( + spec: *const mjSpec, + index: ::core::ffi::c_int, + ) -> *const ::core::ffi::c_char; pub fn mju_zero3(res: *mut [mjtNum; 3usize]); pub fn mju_copy3(res: *mut [mjtNum; 3usize], data: *const [mjtNum; 3usize]); pub fn mju_scl3(res: *mut [mjtNum; 3usize], vec: *const [mjtNum; 3usize], scl: mjtNum); @@ -4140,6 +4453,14 @@ unsafe extern "C" { rowadr: *const ::core::ffi::c_int, colind: *const ::core::ffi::c_int, ); + pub fn mju_sym2dense( + res: *mut mjtNum, + mat: *const mjtNum, + n: ::core::ffi::c_int, + rownnz: *const ::core::ffi::c_int, + rowadr: *const ::core::ffi::c_int, + colind: *const ::core::ffi::c_int, + ); pub fn mju_rotVecQuat( res: *mut [mjtNum; 3usize], vec: *const [mjtNum; 3usize], @@ -4248,7 +4569,7 @@ unsafe extern "C" { ntotal: ::core::ffi::c_int, nband: ::core::ffi::c_int, ndense: ::core::ffi::c_int, - flg_sym: mjtByte, + flg_sym: mjtBool, ); pub fn mju_dense2Band( res: *mut mjtNum, @@ -4265,7 +4586,7 @@ unsafe extern "C" { nband: ::core::ffi::c_int, ndense: ::core::ffi::c_int, nvec: ::core::ffi::c_int, - flg_sym: mjtByte, + flg_sym: mjtBool, ); pub fn mju_bandDiag( i: ::core::ffi::c_int, @@ -4375,7 +4696,7 @@ unsafe extern "C" { m: *const mjModel, d: *mut mjData, eps: mjtNum, - flg_centered: mjtByte, + flg_centered: mjtBool, A: *mut mjtNum, B: *mut mjtNum, C: *mut mjtNum, @@ -4385,7 +4706,7 @@ unsafe extern "C" { m: *const mjModel, d: *mut mjData, eps: mjtNum, - flg_actuation: mjtByte, + flg_actuation: mjtBool, DfDq: *mut mjtNum, DfDv: *mut mjtNum, DfDa: *mut mjtNum, @@ -4429,12 +4750,39 @@ unsafe extern "C" { resource: *const mjResource, content_type: *const ::core::ffi::c_char, ) -> *const mjpDecoder; - pub fn mju_threadPoolCreate(number_of_threads: usize) -> *mut mjThreadPool; - pub fn mju_bindThreadPool(d: *mut mjData, thread_pool: *mut ::core::ffi::c_void); - pub fn mju_threadPoolEnqueue(thread_pool: *mut mjThreadPool, task: *mut mjTask); - pub fn mju_threadPoolDestroy(thread_pool: *mut mjThreadPool); - pub fn mju_defaultTask(task: *mut mjTask); - pub fn mju_taskJoin(task: *mut mjTask); + pub fn mjp_registerEncoder(encoder: *const mjpEncoder); + pub fn mjp_defaultEncoder(encoder: *mut mjpEncoder); + pub fn mjp_findEncoder( + filename: *const ::core::ffi::c_char, + content_type: *const ::core::ffi::c_char, + ) -> *const mjpEncoder; + pub fn mju_openResource( + dir: *const ::core::ffi::c_char, + name: *const ::core::ffi::c_char, + vfs: *const mjVFS, + error: *mut ::core::ffi::c_char, + nerror: usize, + ) -> *mut mjResource; + pub fn mju_closeResource(resource: *mut mjResource); + pub fn mju_readResource( + resource: *mut mjResource, + buffer: *mut *const ::core::ffi::c_void, + ) -> ::core::ffi::c_int; + pub fn mju_getResourceDir( + resource: *mut mjResource, + dir: *mut *const ::core::ffi::c_char, + ndir: *mut ::core::ffi::c_int, + ); + pub fn mju_isModifiedResource( + resource: *const mjResource, + timestamp: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; + pub fn mju_decodeResource( + resource: *mut mjResource, + content_type: *const ::core::ffi::c_char, + vfs: *const mjVFS, + ) -> *mut mjSpec; + pub fn mju_threadpool(d: *mut mjData, nthread: ::core::ffi::c_int); pub fn mjs_attach( parent: *mut mjsElement, child: *const mjsElement, @@ -4453,6 +4801,29 @@ unsafe extern "C" { pub fn mjs_addActuator(s: *mut mjSpec, def: *const mjsDefault) -> *mut mjsActuator; pub fn mjs_addSensor(s: *mut mjSpec) -> *mut mjsSensor; pub fn mjs_addFlex(s: *mut mjSpec) -> *mut mjsFlex; + pub fn mjs_makeFlex( + body: *mut mjsBody, + name: *const ::core::ffi::c_char, + type_: *const ::core::ffi::c_char, + dim: ::core::ffi::c_int, + dof: *const ::core::ffi::c_char, + count: *const [::core::ffi::c_int; 3usize], + cellcount: *const [::core::ffi::c_int; 3usize], + spacing: *const [f64; 3usize], + scale: *const [f64; 3usize], + radius: f64, + mass: f64, + inertiabox: f64, + equality: ::core::ffi::c_int, + rigid: ::core::ffi::c_int, + flatskin: ::core::ffi::c_int, + elastic2d: ::core::ffi::c_int, + pos: *const [f64; 3usize], + quat: *const [f64; 4usize], + origin: *const [f64; 3usize], + file: *const ::core::ffi::c_char, + vfs: *const mjVFS, + ) -> *mut mjsFlex; pub fn mjs_addPair(s: *mut mjSpec, def: *const mjsDefault) -> *mut mjsPair; pub fn mjs_addExclude(s: *mut mjSpec) -> *mut mjsExclude; pub fn mjs_addEquality(s: *mut mjSpec, def: *const mjsDefault) -> *mut mjsEquality; @@ -4519,6 +4890,19 @@ unsafe extern "C" { fvmax: f64, ) -> *const ::core::ffi::c_char; pub fn mjs_setToAdhesion(actuator: *mut mjsActuator, gain: f64) -> *const ::core::ffi::c_char; + pub fn mjs_setToDCMotor( + actuator: *mut mjsActuator, + motorconst: *mut [f64; 2usize], + resistance: f64, + nominal: *mut [f64; 3usize], + saturation: *mut [f64; 3usize], + inductance: *mut [f64; 2usize], + cogging: *mut [f64; 3usize], + controller: *mut [f64; 6usize], + thermal: *mut [f64; 6usize], + lugre: *mut [f64; 5usize], + input_mode: ::core::ffi::c_int, + ) -> *const ::core::ffi::c_char; pub fn mjs_addMesh(s: *mut mjSpec, def: *const mjsDefault) -> *mut mjsMesh; pub fn mjs_addHField(s: *mut mjSpec) -> *mut mjsHField; pub fn mjs_addSkin(s: *mut mjSpec) -> *mut mjsSkin; @@ -4530,41 +4914,43 @@ unsafe extern "C" { params: *mut f64, nparams: ::core::ffi::c_int, ) -> ::core::ffi::c_int; - pub fn mjs_getSpec(element: *mut mjsElement) -> *mut mjSpec; - pub fn mjs_findSpec(spec: *mut mjSpec, name: *const ::core::ffi::c_char) -> *mut mjSpec; - pub fn mjs_findBody(s: *mut mjSpec, name: *const ::core::ffi::c_char) -> *mut mjsBody; + pub fn mjs_getSpec(element: *const mjsElement) -> *mut mjSpec; + pub fn mjs_getOriginSpec(element: *const mjsElement) -> *mut mjSpec; + pub fn mjs_getCompiler(element: *const mjsElement) -> *mut mjsCompiler; + pub fn mjs_findSpec(spec: *const mjSpec, name: *const ::core::ffi::c_char) -> *mut mjSpec; + pub fn mjs_findBody(s: *const mjSpec, name: *const ::core::ffi::c_char) -> *mut mjsBody; pub fn mjs_findElement( - s: *mut mjSpec, + s: *const mjSpec, type_: mjtObj, name: *const ::core::ffi::c_char, ) -> *mut mjsElement; - pub fn mjs_findChild(body: *mut mjsBody, name: *const ::core::ffi::c_char) -> *mut mjsBody; - pub fn mjs_getParent(element: *mut mjsElement) -> *mut mjsBody; - pub fn mjs_getFrame(element: *mut mjsElement) -> *mut mjsFrame; - pub fn mjs_findFrame(s: *mut mjSpec, name: *const ::core::ffi::c_char) -> *mut mjsFrame; - pub fn mjs_getDefault(element: *mut mjsElement) -> *mut mjsDefault; + pub fn mjs_findChild(body: *const mjsBody, name: *const ::core::ffi::c_char) -> *mut mjsBody; + pub fn mjs_getParent(element: *const mjsElement) -> *mut mjsBody; + pub fn mjs_getFrame(element: *const mjsElement) -> *mut mjsFrame; + pub fn mjs_findFrame(s: *const mjSpec, name: *const ::core::ffi::c_char) -> *mut mjsFrame; + pub fn mjs_getDefault(element: *const mjsElement) -> *mut mjsDefault; pub fn mjs_findDefault( - s: *mut mjSpec, + s: *const mjSpec, classname: *const ::core::ffi::c_char, ) -> *mut mjsDefault; - pub fn mjs_getSpecDefault(s: *mut mjSpec) -> *mut mjsDefault; - pub fn mjs_getId(element: *mut mjsElement) -> ::core::ffi::c_int; + pub fn mjs_getSpecDefault(s: *const mjSpec) -> *mut mjsDefault; + pub fn mjs_getId(element: *const mjsElement) -> ::core::ffi::c_int; pub fn mjs_firstChild( - body: *mut mjsBody, + body: *const mjsBody, type_: mjtObj, recurse: ::core::ffi::c_int, ) -> *mut mjsElement; pub fn mjs_nextChild( - body: *mut mjsBody, - child: *mut mjsElement, + body: *const mjsBody, + child: *const mjsElement, recurse: ::core::ffi::c_int, ) -> *mut mjsElement; - pub fn mjs_firstElement(s: *mut mjSpec, type_: mjtObj) -> *mut mjsElement; - pub fn mjs_nextElement(s: *mut mjSpec, element: *mut mjsElement) -> *mut mjsElement; - pub fn mjs_getWrapTarget(wrap: *mut mjsWrap) -> *mut mjsElement; - pub fn mjs_getWrapSideSite(wrap: *mut mjsWrap) -> *mut mjsSite; - pub fn mjs_getWrapDivisor(wrap: *mut mjsWrap) -> f64; - pub fn mjs_getWrapCoef(wrap: *mut mjsWrap) -> f64; + pub fn mjs_firstElement(s: *const mjSpec, type_: mjtObj) -> *mut mjsElement; + pub fn mjs_nextElement(s: *const mjSpec, element: *const mjsElement) -> *mut mjsElement; + pub fn mjs_getWrapTarget(wrap: *const mjsWrap) -> *mut mjsElement; + pub fn mjs_getWrapSideSite(wrap: *const mjsWrap) -> *mut mjsSite; + pub fn mjs_getWrapDivisor(wrap: *const mjsWrap) -> f64; + pub fn mjs_getWrapCoef(wrap: *const mjsWrap) -> f64; pub fn mjs_setName( element: *mut mjsElement, name: *const ::core::ffi::c_char, @@ -4580,7 +4966,7 @@ unsafe extern "C" { dest: *mut mjStringVec, i: ::core::ffi::c_int, text: *const ::core::ffi::c_char, - ) -> mjtByte; + ) -> mjtBool; pub fn mjs_appendString(dest: *mut mjStringVec, text: *const ::core::ffi::c_char); pub fn mjs_setInt( dest: *mut mjIntVec, diff --git a/src/functions/attribute_setters.rs b/src/functions/attribute_setters.rs index ae340fc..763a115 100644 --- a/src/functions/attribute_setters.rs +++ b/src/functions/attribute_setters.rs @@ -1,7 +1,7 @@ //! # [Attribute setters](https://mujoco.readthedocs.io/en/stable/APIreference/APIfunctions.html#attribute-setters) use crate::{ - mjtByte, mjByteVec, mjString, mjStringVec, mjIntVec, mjFloatVec, mjDoubleVec, + mjByteVec, mjString, mjStringVec, mjIntVec, mjFloatVec, mjDoubleVec, mjsPlugin, }; @@ -29,7 +29,7 @@ pub fn mjs_setStringVec(dest: &mut mjStringVec, text: &str) { } /// Set entry in string vector. -pub fn mjs_setInStringVec(dest: &mut mjStringVec, i: usize, text: &str) -> mjtByte { +pub fn mjs_setInStringVec(dest: &mut mjStringVec, i: usize, text: &str) -> bool { let text = std::ffi::CString::new(text).expect("`text` must not contain null bytes"); unsafe { crate::bindgen::mjs_setInStringVec(dest, i as i32, text.as_ptr()) } } diff --git a/src/functions/ray_casting.rs b/src/functions/ray_casting.rs index 7505ca8..661c1a6 100644 --- a/src/functions/ray_casting.rs +++ b/src/functions/ray_casting.rs @@ -24,8 +24,8 @@ use crate::{obj, ObjectId, VertexId}; /// Similar semantics to [`mj_ray`](crate::mj_ray), but `vec` is an array of /// `(nray x 3)` directions. /* void mj_multiRay(const mjModel* m, mjData* d, const mjtNum pnt[3], const mjtNum* vec, - const mjtByte* geomgroup, mjtByte flg_static, int bodyexclude, - int* geomid, mjtNum* dist, int nray, mjtNum cutoff); */ + const mjtByte* geomgroup, mjtBool flg_static, int bodyexclude, + int* geomid, mjtNum* dist, mjtNum* normal, int nray, mjtNum cutoff); */ pub fn mj_multiRay( m: &crate::mjModel, d: &mut crate::mjData, @@ -44,12 +44,13 @@ pub fn mj_multiRay( m.as_ptr(), d.as_mut_ptr(), &pnt, - vec.as_ptr(), + vec.as_ptr().cast(), geomgroup.map_or(std::ptr::null(), |g| g.as_ptr()), - flg_static as u8, + flg_static, bodyexclude, geomid.as_mut_ptr(), dist.as_mut_ptr(), + std::ptr::null_mut(), N_RAY as i32, cutoff, ) @@ -75,8 +76,8 @@ pub fn mj_multiRay( /// /// `bodyexclude = None` can be used to indicate that all bodies are included. /* mjtNum mj_ray(const mjModel* m, const mjData* d, const mjtNum pnt[3], const mjtNum vec[3], - const mjtByte* geomgroup, mjtByte flg_static, int bodyexclude, - int geomid[1]); */ + const mjtByte* geomgroup, mjtBool flg_static, int bodyexclude, + int geomid[1], mjtNum normal[3]); */ pub fn mj_ray( m: &crate::mjModel, d: &crate::mjData, @@ -97,9 +98,10 @@ pub fn mj_ray( &pnt, &vec, geomgroup.map_or(std::ptr::null(), |gg| gg.as_ptr()), - flg_static as u8, + flg_static, bodyexclude.index() as i32, &mut geomid, + std::ptr::null_mut(), ) }; @@ -112,7 +114,7 @@ pub fn mj_ray( /// Intersect ray with hfield, return nearest distance or `None` if no intersection. /* mjtNum mj_rayHfield(const mjModel* m, const mjData* d, int geomid, - const mjtNum pnt[3], const mjtNum vec[3]); */ + const mjtNum pnt[3], const mjtNum vec[3], mjtNum normal[3]); */ pub fn mj_rayHfield( m: &crate::mjModel, d: &crate::mjData, @@ -127,6 +129,7 @@ pub fn mj_rayHfield( geomid.index() as i32, &pnt, &vec, + std::ptr::null_mut(), ) }; @@ -139,7 +142,7 @@ pub fn mj_rayHfield( /// Intersect ray with mesh, return nearest distance or `None` if no intersection. /* mjtNum mj_rayMesh(const mjModel* m, const mjData* d, int geomid, - const mjtNum pnt[3], const mjtNum vec[3]); */ + const mjtNum pnt[3], const mjtNum vec[3], mjtNum normal[3]); */ pub fn mj_rayMesh( m: &crate::mjModel, d: &crate::mjData, @@ -154,6 +157,7 @@ pub fn mj_rayMesh( geomid.index() as i32, &pnt, &vec, + std::ptr::null_mut(), ) }; @@ -166,7 +170,8 @@ pub fn mj_rayMesh( /// Intersect ray with pure geom, return nearest distance or `None` if no intersection. /* mjtNum mju_rayGeom(const mjtNum pos[3], const mjtNum mat[9], const mjtNum size[3], - const mjtNum pnt[3], const mjtNum vec[3], int geomtype); */ + const mjtNum pnt[3], const mjtNum vec[3], int geomtype, + mjtNum normal[3]); */ pub fn mju_rayGeom( pos: [f64; 3], mat: [f64; 9], @@ -183,6 +188,7 @@ pub fn mju_rayGeom( &pnt, &vec, geomtype.0 as i32, + std::ptr::null_mut(), ) }; @@ -195,10 +201,10 @@ pub fn mju_rayGeom( /// Intersect ray with flex, return nearest distance or `None` if no intersection, /// and also output nearest vertex id. -/* mjtNum mju_rayFlex(const mjModel* m, const mjData* d, int flex_layer, mjtByte flg_vert, - mjtByte flg_edge, mjtByte flg_face, mjtByte flg_skin, int flexid, - const mjtNum* pnt, const mjtNum* vec, int vertid[1]); */ -pub fn mju_rayFlex( +/* mjtNum mj_rayFlex(const mjModel* m, const mjData* d, int flex_layer, mjtBool flg_vert, + mjtBool flg_edge, mjtBool flg_face, mjtBool flg_skin, int flexid, + const mjtNum* pnt, const mjtNum* vec, int vertid[1], mjtNum normal[3]); */ +pub fn mj_rayFlex( m: &crate::mjModel, d: &crate::mjData, flex_layer: Option, @@ -210,21 +216,22 @@ pub fn mju_rayFlex( pnt: [f64; 3], vec: [f64; 3], ) -> Option<(VertexId, f64)> { - let mut vertid = [-1]; + let mut vertid = [-1i32]; let distance = unsafe { - crate::bindgen::mju_rayFlex( + crate::bindgen::mj_rayFlex( m.as_ptr(), d.as_ptr(), flex_layer.map_or(-1, |l| l as i32), - flg_vert as u8, - flg_edge as u8, - flg_face as u8, - flg_skin as u8, + flg_vert, + flg_edge, + flg_face, + flg_skin, flexid.index() as i32, &pnt, &vec, &mut vertid, + std::ptr::null_mut(), ) }; diff --git a/src/functions/support.rs b/src/functions/support.rs index 645a1ed..378a680 100644 --- a/src/functions/support.rs +++ b/src/functions/support.rs @@ -9,7 +9,7 @@ use crate::{obj, mjContact, mjData, mjModel, ObjectId}; /// Returns the number of mjtNum⁠s required for a given state specification. The bits of the integer spec correspond to element fields of mjtState. pub fn mj_stateSize(m: &mjModel, spec: crate::bindgen::mjtState) -> usize { - unsafe { crate::bindgen::mj_stateSize(m.as_ptr(), spec.0 as u32) as _ } + unsafe { crate::bindgen::mj_stateSize(m.as_ptr(), spec.0 as i32) as _ } } /// Copy concatenated state components specified by spec from d into state. The bits of the integer spec correspond to element fields of mjtState. Fails with mju_error if spec is invalid. @@ -27,7 +27,7 @@ pub fn mj_getState( m.as_ptr(), d.as_ptr(), state.as_mut_ptr(), - spec.0 as u32, + spec.0 as i32, ) } } @@ -47,7 +47,7 @@ pub fn mj_setState( m.as_ptr(), d.as_mut_ptr(), state.as_ptr(), - spec.0 as u32, + spec.0 as i32, ) } } @@ -350,22 +350,15 @@ pub fn mj_id2name( unsafe {std::ffi::CStr::from_ptr(c_name).to_str().unwrap().to_owned()} } -/// Convert sparse inertia matrix M into full (i.e. dense) matrix. -/// `M` must be of the same size as mjData.`qM`. -/// Returned one is of size `nv x nv`, -pub fn mj_fullM( - m: &mjModel, - M: &[f64], -) -> Vec { - #[cfg(debug_assertions)] { - assert_eq!(M.len(), m.nM()); - } +/// Convert the sparse inertia matrix in `d.qM` into a full (i.e. dense) matrix. +/// The returned matrix is of size `nv x nv`. +pub fn mj_fullM(m: &mjModel, d: &mjData) -> Vec { let mut res = vec![0.0; m.nv() * m.nv()]; unsafe { crate::bindgen::mj_fullM( m.as_ptr(), + d.as_ptr(), res.as_mut_ptr(), - M.as_ptr(), ); } res @@ -537,11 +530,11 @@ pub fn mj_objectAcceleration( /// Returned distances are bounded from above by distmax. /// /// If no collision of distance smaller than distmax is found, the function will return distmax and fromto, if given, will be set to (0, 0, 0, 0, 0, 0). -/* mjtNum mj_geomDistance(const mjModel* m, const mjData* d, int geom1, int geom2, +/* mjtNum mj_geomDistance(const mjModel* m, mjData* d, int geom1, int geom2, mjtNum distmax, mjtNum fromto[6]); */ pub fn mj_geomDistance( m: &mjModel, - d: &mjData, + d: &mut mjData, geom1: ObjectId, geom2: ObjectId, distmax: f64, @@ -550,7 +543,7 @@ pub fn mj_geomDistance( let dist = unsafe { crate::bindgen::mj_geomDistance( m.as_ptr(), - d.as_ptr(), + d.as_mut_ptr(), geom1.index() as i32, geom2.index() as i32, distmax, diff --git a/src/types/mjdata.rs b/src/types/mjdata.rs index 6af347f..83f3ac5 100644 --- a/src/types/mjdata.rs +++ b/src/types/mjdata.rs @@ -4,7 +4,7 @@ pub use crate::bindgen::{ mjtConstraint, mjtConstraintState, - mjNSOLVER, mjNISLAND, mjNTIMER, mjNWARNING, mjMAXTHREAD, + mjNSOLVER, mjNISLAND, mjNTIMER, mjNWARNING, }; resource_wrapper!( @@ -27,7 +27,6 @@ fields_mapping!(mjData { // memory utilization statistics maxuse_stack: crate::bindgen::mjtSize = "maximum stack allocation in bytes"; - maxuse_threadstack: [crate::bindgen::mjtSize; mjMAXTHREAD] = "maximum stack allocation per thread in bytes"; maxuse_arena: crate::bindgen::mjtSize = "maximum arena allocation in bytes"; maxuse_con: usize = "maximum number of contacts"; maxuse_efc: usize = "maximum number of scalar constraints"; @@ -149,10 +148,10 @@ impl mjData { } pub fn eq_active(&self, id: ObjectId) -> bool { - (unsafe { self.eq_active.add(id.index()).read() }) != 0 + unsafe { self.eq_active.add(id.index()).read() } } pub fn set_eq_active(&mut self, id: ObjectId, value: bool) { - unsafe { self.eq_active.add(id.index()).write(if value {1} else {0}) }; + unsafe { self.eq_active.add(id.index()).write(value) }; } /// `None` when the body is not a mocap body. @@ -278,17 +277,9 @@ buffer_slices_depending_on_model! { flexedge_J: [f64; nflexedge * nv] = "flex edge Jacobian (nflexedge x nv)"; flexedge_length: [f64; nflexedge * 1] = "flex edge lengths (nflexedge x 1)"; - // computed by mj_fwdPosition/mj_flex - flexedge_J_rownnz: [i32; nflexedge * 1] = "number of non-zeros in Jacobian row (nflexedge x 1)"; - flexedge_J_rowadr: [i32; nflexedge * 1] = "row start address in colind array (nflexedge x 1)"; - flexedge_J_colind: [i32; nflexedge * nv] = "column indices in sparse Jacobian (nflexedge x nv)"; - // computed by mj_fwdPosition/mj_tendon ten_wrapadr: [i32; ntendon * 1] = "start address of tendon's path (ntendon x 1)"; ten_wrapnum: [i32; ntendon * 1] = "number of wrap points in path (ntendon x 1)"; - ten_J_rownnz: [i32; ntendon * 1] = "number of non-zeros in Jacobian row (ntendon x 1)"; - ten_J_rowadr: [i32; ntendon * 1] = "row start address in colind array (ntendon x 1)"; - ten_J_colind: [i32; ntendon * nv] = "column indices in sparse Jacobian (ntendon x nv)"; wrap_obj: [i32; nwrap * 2] = "geom id; -1: site; -2: pulley (nwrap x 2)"; // computed by mj_fwdPosition/mj_tendon @@ -422,7 +413,6 @@ buffer_slices! { efc_pos: [f64; nefc] = "constraint position (equality, contact) (nefc x 1)"; efc_margin: [f64; nefc] = "inclusion margin (contact) (nefc x 1)"; efc_frictionloss: [f64; nefc] = "frictionloss (friction) (nefc x 1)"; - efc_diagApprox: [f64; nefc] = "approximation to diagonal of A (nefc x 1)"; efc_KBIP: [f64; nefc * 4] = "stiffness, damping, impedance, imp' (nefc x 4)"; efc_D: [f64; nefc] = "constraint mass (nefc x 1)"; efc_R: [f64; nefc] = "inverse constraint mass (nefc x 1)"; @@ -436,6 +426,32 @@ buffer_slices! { #[allow(non_snake_case)] impl mjData { + /// number of non-zeros in each flex edge Jacobian row (nflexedge x 1) + pub unsafe fn flexedge_J_rownnz<'m>(&self, model: &'m mjModel) -> &'m [i32] { + model.flexedge_J_rownnz() + } + /// row addresses in the flex edge Jacobian (nflexedge x 1) + pub unsafe fn flexedge_J_rowadr<'m>(&self, model: &'m mjModel) -> &'m [i32] { + model.flexedge_J_rowadr() + } + /// column indices in the sparse flex edge Jacobian (nJfe x 1) + pub unsafe fn flexedge_J_colind<'m>(&self, model: &'m mjModel) -> &'m [i32] { + model.flexedge_J_colind() + } + + /// number of non-zeros in each tendon Jacobian row (ntendon x 1) + pub unsafe fn ten_J_rownnz<'m>(&self, model: &'m mjModel) -> &'m [i32] { + model.ten_J_rownnz() + } + /// row addresses in the tendon Jacobian (ntendon x 1) + pub unsafe fn ten_J_rowadr<'m>(&self, model: &'m mjModel) -> &'m [i32] { + model.ten_J_rowadr() + } + /// column indices in the sparse tendon Jacobian (nJten x 1) + pub unsafe fn ten_J_colind<'m>(&self, model: &'m mjModel) -> &'m [i32] { + model.ten_J_colind() + } + /// body-dof: non-zeros in each row (nbody x 1) pub unsafe fn B_rownnz<'m>(&self, model: &'m mjModel) -> &'m [i32] { model.B_rownnz() diff --git a/src/types/mjmodel.rs b/src/types/mjmodel.rs index 2890ad3..a7b14b1 100644 --- a/src/types/mjmodel.rs +++ b/src/types/mjmodel.rs @@ -35,6 +35,7 @@ fields_mapping!(mjModel { nflexshelldata: usize = "number of shell fragment vertex ids in all flexes"; nflexevpair: usize = "number of element-vertex pairs in all flexes"; nflextexcoord: usize = "number of vertices with texture coordinates"; + nJfe: usize = "number of non-zeros in sparse flex edge Jacobian"; nmesh: usize = "number of meshes"; nmeshvert: usize = "number of vertices in all meshes"; nmeshnormal: usize = "number of normals in all meshes"; @@ -59,6 +60,7 @@ fields_mapping!(mjModel { nexclude: usize = "number of excluded geom pairs"; neq: usize = "number of equality constraints"; ntendon: usize = "number of tendons"; + nJten: usize = "number of non-zeros in sparse tendon Jacobian"; nwrap: usize = "number of wrap objects in all tendon paths"; nsensor: usize = "number of sensors"; nnumeric: usize = "number of numeric custom fields"; @@ -111,7 +113,7 @@ fields_mapping!(mjModel { }); pub use crate::bindgen::{ - mjtSameFrame, mjtJoint, mjtGeom, mjtCamLight, mjtFlexSelf, mjtTexture, mjtEq, mjtObj, mjtWrap, mjtTrn, mjtDyn, mjtGain, mjtBias, mjtSensor, mjtDataType, mjtStage, + mjtSameFrame, mjtJoint, mjtGeom, mjtCamLight, mjtProjection, mjtFlexSelf, mjtTexture, mjtEq, mjtObj, mjtWrap, mjtTrn, mjtDyn, mjtGain, mjtBias, mjtSensor, mjtDataType, mjtStage, mjNREF, mjNIMP, mjNFLUID, mjNTEXROLE, mjNEQDATA, mjNDYN, mjNGAIN, mjNBIAS, }; use crate::{ @@ -334,15 +336,15 @@ impl mjModel { } /// does joint have limits pub fn jnt_limited(&self, id: impl Into>) -> bool { - (unsafe { self.jnt_limited.add(id.into().index()).read() }) != 0 + unsafe { self.jnt_limited.add(id.into().index()).read() } } /// does joint have actuator force limits pub fn jnt_actfrclimited(&self, id: impl Into>) -> bool { - (unsafe { self.jnt_actfrclimited.add(id.into().index()).read() }) != 0 + unsafe { self.jnt_actfrclimited.add(id.into().index()).read() } } /// is gravcomp force applied via actuators pub fn jnt_actgravcomp(&self, id: impl Into>) -> bool { - (unsafe { self.jnt_actgravcomp.add(id.into().index()).read() }) != 0 + unsafe { self.jnt_actgravcomp.add(id.into().index()).read() } } /// constraint solver reference: limit pub fn jnt_solref(&self, id: impl Into>) -> [f64; mjNREF] { @@ -698,9 +700,9 @@ impl mjModel { ] } } - /// orthographic camera - pub fn cam_orthographic(&self, id: ObjectId) -> bool { - (unsafe { self.cam_orthographic.add(id.index()).read() }) != 0 + /// camera projection type + pub fn cam_projection(&self, id: ObjectId) -> mjtProjection { + mjtProjection(unsafe { self.cam_projection.add(id.index()).read() } as u32) } /// y field-of-view (ortho ? len : deg) pub fn cam_fovy(&self, id: ObjectId) -> f64 { @@ -748,7 +750,7 @@ impl mjModel { } /// does light cast shadows pub fn light_castshadow(&self, id: ObjectId) -> bool { - (unsafe { self.light_castshadow.add(id.index()).read() }) != 0 + unsafe { self.light_castshadow.add(id.index()).read() } } /// light radius for soft shadows pub fn light_bulbradius(&self, id: ObjectId) -> f32 { @@ -756,7 +758,7 @@ impl mjModel { } /// is light on pub fn light_active(&self, id: ObjectId) -> bool { - (unsafe { self.light_active.add(id.index()).read() }) != 0 + unsafe { self.light_active.add(id.index()).read() } } /// position relative to body frame pub fn light_pos(&self, id: ObjectId) -> [f64; 3] { @@ -881,7 +883,7 @@ impl mjModel { } /// internal flex collision enabled pub fn flex_internal(&self, id: ObjectId) -> bool { - (unsafe { self.flex_internal.add(id.index()).read() }) != 0 + unsafe { self.flex_internal.add(id.index()).read() } } /// self collision mode (mjtFlexSelf) pub fn flex_selfcollide(&self, id: ObjectId) -> mjtFlexSelf { @@ -1080,19 +1082,19 @@ impl mjModel { } /// are all verices in the same body pub fn flex_rigid(&self, id: ObjectId) -> bool { - (unsafe { self.flex_rigid.add(id.index()).read() }) != 0 + unsafe { self.flex_rigid.add(id.index()).read() } } /// are both edge vertices in same body pub fn flexedge_rigid(&self, id: EdgeId) -> bool { - (unsafe { self.flexedge_rigid.add(id.index()).read() }) != 0 + unsafe { self.flexedge_rigid.add(id.index()).read() } } /// are all vertex coordinates (0,0,0) pub fn flex_centered(&self, id: ObjectId) -> bool { - (unsafe { self.flex_centered.add(id.index()).read() }) != 0 + unsafe { self.flex_centered.add(id.index()).read() } } /// render flex skin with flat shading pub fn flex_flatskin(&self, id: ObjectId) -> bool { - (unsafe { self.flex_flatskin.add(id.index()).read() }) != 0 + unsafe { self.flex_flatskin.add(id.index()).read() } } /// address of bvh root pub fn flex_bvhadr(&self, id: ObjectId) -> Option { @@ -1396,7 +1398,7 @@ impl mjModel { } /// make texture cube uniform pub fn mat_texuniform(&self, id: ObjectId) -> bool { - (unsafe { self.mat_texuniform.add(id.index()).read() }) != 0 + unsafe { self.mat_texuniform.add(id.index()).read() } } /// texture repetition for 2d mapping pub fn mat_texrepeat(&self, id: ObjectId) -> [f32; 2] { @@ -1521,7 +1523,7 @@ impl mjModel { } /// initial enable/disable constraint state pub fn eq_active0(&self, id: ObjectId) -> bool { - (unsafe { self.eq_active0.add(id.index()).read() }) != 0 + unsafe { self.eq_active0.add(id.index()).read() } } /// constraint solver reference pub fn eq_solref(&self, id: ObjectId) -> [f64; mjNREF] { @@ -1564,11 +1566,11 @@ impl mjModel { } /// does tendon have length limits pub fn tendon_limited(&self, id: ObjectId) -> bool { - (unsafe { self.tendon_limited.add(id.index()).read() }) != 0 + unsafe { self.tendon_limited.add(id.index()).read() } } /// does tendon have actuator force limits pub fn tendon_actfrclimited(&self, id: ObjectId) -> bool { - (unsafe { self.tendon_actfrclimited.add(id.index()).read() }) != 0 + unsafe { self.tendon_actfrclimited.add(id.index()).read() } } /// width for rendering pub fn tendon_width(&self, id: ObjectId) -> f64 { @@ -1724,15 +1726,15 @@ impl mjModel { } /// is control limited pub fn actuator_ctrllimited(&self, id: ObjectId) -> bool { - (unsafe { self.actuator_ctrllimited.add(id.index()).read() }) != 0 + unsafe { self.actuator_ctrllimited.add(id.index()).read() } } /// is force limited pub fn actuator_forcelimited(&self, id: ObjectId) -> bool { - (unsafe { self.actuator_forcelimited.add(id.index()).read() }) != 0 + unsafe { self.actuator_forcelimited.add(id.index()).read() } } /// is activation limited pub fn actuator_actlimited(&self, id: ObjectId) -> bool { - (unsafe { self.actuator_actlimited.add(id.index()).read() }) != 0 + unsafe { self.actuator_actlimited.add(id.index()).read() } } /// dynamics parameters pub fn actuator_dynprm(&self, id: ObjectId) -> [f64; mjNDYN] { @@ -1757,7 +1759,7 @@ impl mjModel { } /// step activation before force pub fn actuator_actearly(&self, id: ObjectId) -> bool { - (unsafe { self.actuator_actearly.add(id.index()).read() }) != 0 + unsafe { self.actuator_actearly.add(id.index()).read() } } /// range of controls pub fn actuator_ctrlrange(&self, id: ObjectId) -> Option> { @@ -1961,6 +1963,32 @@ impl mjModel { #[allow(non_snake_case)] impl mjModel { + /// number of non-zeros in each flex edge Jacobian row (nflexedge x 1) + pub fn flexedge_J_rownnz(&self) -> &[i32] { + unsafe { slice((*self.as_ptr()).flexedge_J_rownnz as *const i32, self.nflexedge()) } + } + /// row addresses in the flex edge Jacobian (nflexedge x 1) + pub fn flexedge_J_rowadr(&self) -> &[i32] { + unsafe { slice((*self.as_ptr()).flexedge_J_rowadr as *const i32, self.nflexedge()) } + } + /// column indices in the sparse flex edge Jacobian (nJfe x 1) + pub fn flexedge_J_colind(&self) -> &[i32] { + unsafe { slice((*self.as_ptr()).flexedge_J_colind as *const i32, self.nJfe()) } + } + + /// number of non-zeros in each tendon Jacobian row (ntendon x 1) + pub fn ten_J_rownnz(&self) -> &[i32] { + unsafe { slice((*self.as_ptr()).ten_J_rownnz as *const i32, self.ntendon()) } + } + /// row addresses in the tendon Jacobian (ntendon x 1) + pub fn ten_J_rowadr(&self) -> &[i32] { + unsafe { slice((*self.as_ptr()).ten_J_rowadr as *const i32, self.ntendon()) } + } + /// column indices in the sparse tendon Jacobian (nJten x 1) + pub fn ten_J_colind(&self) -> &[i32] { + unsafe { slice((*self.as_ptr()).ten_J_colind as *const i32, self.nJten()) } + } + /// body-dof: non-zeros in each row (nbody x 1) pub fn B_rownnz(&self) -> &[i32] { unsafe { slice((*self.as_ptr()).B_rownnz as *const i32, self.nbody()) } diff --git a/vendor/include/mujoco/mjassert.h b/vendor/include/mujoco/mjassert.h new file mode 100644 index 0000000..58e055a --- /dev/null +++ b/vendor/include/mujoco/mjassert.h @@ -0,0 +1,156 @@ +// Copyright 2026 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_MJASSERT_H_ +#define MUJOCO_MJASSERT_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(__cplusplus) + #define MJ_ASSERT_SIZE(type, size) \ + static_assert(sizeof(type) == (size), #type " must be " #size " bytes for MuJoCo ABI stability") + #define MJ_STATIC_ASSERT(expr) static_assert(expr) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define MJ_ASSERT_SIZE(type, size) \ + _Static_assert(sizeof(type) == (size), #type " must be " #size " bytes for MuJoCo ABI stability") + #define MJ_STATIC_ASSERT(expr) _Static_assert(expr, #expr) +#else + #define MJ_ASSERT_SIZE(type, size) \ + typedef char mj_assert_##type[sizeof(type) == (size) ? 1 : -1] + #define MJ_STATIC_ASSERT(expr) +#endif + +// primitive types +#if !defined(mjUSESINGLE) +MJ_ASSERT_SIZE(mjtNum, 8); +#else +MJ_ASSERT_SIZE(mjtNum, 4); +#endif +MJ_ASSERT_SIZE(mjtByte, 1); +MJ_ASSERT_SIZE(mjtBool, 1); +MJ_ASSERT_SIZE(mjtSize, 8); + +// mjModel enums +MJ_ASSERT_SIZE(mjtDisableBit, 4); +MJ_ASSERT_SIZE(mjtEnableBit, 4); +MJ_ASSERT_SIZE(mjtJoint, 4); +MJ_ASSERT_SIZE(mjtGeom, 4); +MJ_ASSERT_SIZE(mjtProjection, 4); +MJ_ASSERT_SIZE(mjtCamLight, 4); +MJ_ASSERT_SIZE(mjtLightType, 4); +MJ_ASSERT_SIZE(mjtTexture, 4); +MJ_ASSERT_SIZE(mjtTextureRole, 4); +MJ_ASSERT_SIZE(mjtColorSpace, 4); +MJ_ASSERT_SIZE(mjtIntegrator, 4); +MJ_ASSERT_SIZE(mjtCone, 4); +MJ_ASSERT_SIZE(mjtJacobian, 4); +MJ_ASSERT_SIZE(mjtSolver, 4); +MJ_ASSERT_SIZE(mjtEq, 4); +MJ_ASSERT_SIZE(mjtWrap, 4); +MJ_ASSERT_SIZE(mjtTrn, 4); +MJ_ASSERT_SIZE(mjtDyn, 4); +MJ_ASSERT_SIZE(mjtGain, 4); +MJ_ASSERT_SIZE(mjtBias, 4); +MJ_ASSERT_SIZE(mjtObj, 4); +MJ_ASSERT_SIZE(mjtSensor, 4); +MJ_ASSERT_SIZE(mjtStage, 4); +MJ_ASSERT_SIZE(mjtDataType, 4); +MJ_ASSERT_SIZE(mjtConDataField, 4); +MJ_ASSERT_SIZE(mjtRayDataField, 4); +MJ_ASSERT_SIZE(mjtCamOutBit, 4); +MJ_ASSERT_SIZE(mjtSameFrame, 4); +MJ_ASSERT_SIZE(mjtSleepPolicy, 4); +MJ_ASSERT_SIZE(mjtLRMode, 4); +MJ_ASSERT_SIZE(mjtFlexSelf, 4); +MJ_ASSERT_SIZE(mjtSDFType, 4); + +// mjData enums +MJ_ASSERT_SIZE(mjtState, 4); +MJ_ASSERT_SIZE(mjtConstraint, 4); +MJ_ASSERT_SIZE(mjtConstraintState, 4); +MJ_ASSERT_SIZE(mjtWarning, 4); +MJ_ASSERT_SIZE(mjtTimer, 4); +MJ_ASSERT_SIZE(mjtSleepState, 4); + +// mjspec.h +MJ_ASSERT_SIZE(mjtGeomInertia, 4); +MJ_ASSERT_SIZE(mjtMeshInertia, 4); +MJ_ASSERT_SIZE(mjtMeshBuiltin, 4); +MJ_ASSERT_SIZE(mjtBuiltin, 4); +MJ_ASSERT_SIZE(mjtMark, 4); +MJ_ASSERT_SIZE(mjtLimited, 4); +MJ_ASSERT_SIZE(mjtAlignFree, 4); +MJ_ASSERT_SIZE(mjtInertiaFromGeom, 4); +MJ_ASSERT_SIZE(mjtOrientation, 4); + +// mjvisualize.h +MJ_ASSERT_SIZE(mjtCatBit, 4); +MJ_ASSERT_SIZE(mjtMouse, 4); +MJ_ASSERT_SIZE(mjtPertBit, 4); +MJ_ASSERT_SIZE(mjtCamera, 4); +MJ_ASSERT_SIZE(mjtLabel, 4); +MJ_ASSERT_SIZE(mjtFrame, 4); +MJ_ASSERT_SIZE(mjtVisFlag, 4); +MJ_ASSERT_SIZE(mjtRndFlag, 4); +MJ_ASSERT_SIZE(mjtStereo, 4); + +// mjrender.h +MJ_ASSERT_SIZE(mjtGridPos, 4); +MJ_ASSERT_SIZE(mjtFramebuffer, 4); +MJ_ASSERT_SIZE(mjtDepthMap, 4); +MJ_ASSERT_SIZE(mjtFontScale, 4); +MJ_ASSERT_SIZE(mjtFont, 4); + +// mjui.h +MJ_ASSERT_SIZE(mjtButton, 4); +MJ_ASSERT_SIZE(mjtEvent, 4); +MJ_ASSERT_SIZE(mjtItem, 4); +MJ_ASSERT_SIZE(mjtSection, 4); + +// mjplugin.h +MJ_ASSERT_SIZE(mjtPluginCapabilityBit, 4); + +// authored bitmask field count assertions +// each authored bitmask is uint64_t, so each FIELDS macro must have <= 64 entries +#define X(type, name, dim) +1 +#define XVEC(type, name, dim) +1 + +// mjsCompiler +MJ_STATIC_ASSERT((0 MJSCOMPILER_FIELDS) <= 64); + +// mjOption and mjVisual +MJ_STATIC_ASSERT((0 MJOPTION_FIELDS) <= 64); +MJ_STATIC_ASSERT((0 MJVISUAL_GLOBAL_FIELDS) <= 64); +MJ_STATIC_ASSERT((0 MJVISUAL_QUALITY_FIELDS) <= 64); +MJ_STATIC_ASSERT((0 MJVISUAL_HEADLIGHT_FIELDS) <= 64); +MJ_STATIC_ASSERT((0 MJVISUAL_MAP_FIELDS) <= 64); +MJ_STATIC_ASSERT((0 MJVISUAL_SCALE_FIELDS) <= 64); +MJ_STATIC_ASSERT((0 MJVISUAL_RGBA_FIELDS) <= 64); + +#undef X +#undef XVEC + +#undef MJ_ASSERT_SIZE +#undef MJ_STATIC_ASSERT + +#endif // MUJOCO_MJASSERT_H_ diff --git a/vendor/include/mujoco/mjdata.h b/vendor/include/mujoco/mjdata.h index a813ee1..e0d796a 100644 --- a/vendor/include/mujoco/mjdata.h +++ b/vendor/include/mujoco/mjdata.h @@ -18,119 +18,30 @@ #include #include -#include +#include #include -#include - -//---------------------------------- primitive types (mjt) ----------------------------------------- - -typedef enum mjtState_ { // state elements - mjSTATE_TIME = 1<<0, // time - mjSTATE_QPOS = 1<<1, // position - mjSTATE_QVEL = 1<<2, // velocity - mjSTATE_ACT = 1<<3, // actuator activation - mjSTATE_WARMSTART = 1<<4, // acceleration used for warmstart - mjSTATE_CTRL = 1<<5, // control - mjSTATE_QFRC_APPLIED = 1<<6, // applied generalized force - mjSTATE_XFRC_APPLIED = 1<<7, // applied Cartesian force/torque - mjSTATE_EQ_ACTIVE = 1<<8, // enable/disable constraints - mjSTATE_MOCAP_POS = 1<<9, // positions of mocap bodies - mjSTATE_MOCAP_QUAT = 1<<10, // orientations of mocap bodies - mjSTATE_USERDATA = 1<<11, // user data - mjSTATE_PLUGIN = 1<<12, // plugin state - - mjNSTATE = 13, // number of state elements - - // convenience values for commonly used state specifications - mjSTATE_PHYSICS = mjSTATE_QPOS | mjSTATE_QVEL | mjSTATE_ACT, - mjSTATE_FULLPHYSICS = mjSTATE_TIME | mjSTATE_PHYSICS | mjSTATE_PLUGIN, - mjSTATE_USER = mjSTATE_CTRL | mjSTATE_QFRC_APPLIED | mjSTATE_XFRC_APPLIED | - mjSTATE_EQ_ACTIVE | mjSTATE_MOCAP_POS | mjSTATE_MOCAP_QUAT | - mjSTATE_USERDATA, - mjSTATE_INTEGRATION = mjSTATE_FULLPHYSICS | mjSTATE_USER | mjSTATE_WARMSTART -} mjtState; - - -typedef enum mjtConstraint_ { // type of constraint - mjCNSTR_EQUALITY = 0, // equality constraint - mjCNSTR_FRICTION_DOF, // dof friction - mjCNSTR_FRICTION_TENDON, // tendon friction - mjCNSTR_LIMIT_JOINT, // joint limit - mjCNSTR_LIMIT_TENDON, // tendon limit - mjCNSTR_CONTACT_FRICTIONLESS, // frictionless contact - mjCNSTR_CONTACT_PYRAMIDAL, // frictional contact, pyramidal friction cone - mjCNSTR_CONTACT_ELLIPTIC // frictional contact, elliptic friction cone -} mjtConstraint; - - -typedef enum mjtConstraintState_ { // constraint state - mjCNSTRSTATE_SATISFIED = 0, // constraint satisfied, zero cost (limit, contact) - mjCNSTRSTATE_QUADRATIC, // quadratic cost (equality, friction, limit, contact) - mjCNSTRSTATE_LINEARNEG, // linear cost, negative side (friction) - mjCNSTRSTATE_LINEARPOS, // linear cost, positive side (friction) - mjCNSTRSTATE_CONE // squared distance to cone cost (elliptic contact) -} mjtConstraintState; - - -typedef enum mjtWarning_ { // warning types - 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_ { // internal timers - // 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_CONSTRAINT, // fwdConstraint - mjTIMER_ADVANCE, // mj_Euler, mj_implicit - - // 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 mj_collision - mjTIMER_COL_BROAD, // broadphase - mjTIMER_COL_NARROW, // narrowphase - - mjNTIMER // number of timers -} mjtTimer; - - -typedef enum mjtSleepState_ { // sleep state of an object - mjS_STATIC = -1, // object is static - mjS_ASLEEP = 0, // object is asleep - mjS_AWAKE = 1 // object is awake -} mjtSleepState; - - -//---------------------------------- mjContact ----------------------------------------------------- + + + + +//------------------------------------- Contact ---------------------------------------------------- + +struct mjPreContact_ { // contact parameters set by narrowphase collision functions + mjtNum dist; + mjtNum pos[3]; + mjtNum normal[3]; // contact normal of the collision + mjtNum tangent[3]; // first tangent direction +}; +typedef struct mjPreContact_ mjPreContact; struct mjContact_ { // result of collision detection functions - // contact parameters set by near-phase collision function + // contact parameters set by narrowphase collision function mjtNum dist; // distance between nearest points; neg: penetration mjtNum pos[3]; // position of contact point: midpoint between geoms mjtNum frame[9]; // normal is in [0-2], points from geom[0] to geom[1] // contact parameters set by mj_collideGeoms - mjtNum includemargin; // include if dist #include - -#include +#include // global constants #define mjPI 3.14159265358979323846 @@ -42,406 +41,12 @@ #define mjNFLUID 12 // number of fluid interaction parameters #define mjNREF 2 // number of solver reference parameters #define mjNIMP 5 // number of solver impedance parameters +#define mjNPOLY 2 // number of high-order polynomial coefficients #define mjNSENS 3 // number of sensor parameters #define mjNSOLVER 200 // size of one mjData.solver array #define mjNISLAND 20 // number of mjData.solver arrays -//---------------------------------- enum types (mjt) ---------------------------------------------- - -typedef enum mjtDisableBit_ { // disable default feature bitflags - mjDSBL_CONSTRAINT = 1<<0, // entire constraint solver - mjDSBL_EQUALITY = 1<<1, // equality constraints - mjDSBL_FRICTIONLOSS = 1<<2, // joint and tendon frictionloss constraints - mjDSBL_LIMIT = 1<<3, // joint and tendon limit constraints - mjDSBL_CONTACT = 1<<4, // contact constraints - mjDSBL_SPRING = 1<<5, // passive spring forces - mjDSBL_DAMPER = 1<<6, // passive damping forces - mjDSBL_GRAVITY = 1<<7, // gravitational forces - mjDSBL_CLAMPCTRL = 1<<8, // clamp control to specified range - mjDSBL_WARMSTART = 1<<9, // warmstart constraint solver - mjDSBL_FILTERPARENT = 1<<10, // remove collisions with parent body - mjDSBL_ACTUATION = 1<<11, // apply actuation forces - mjDSBL_REFSAFE = 1<<12, // integrator safety: make ref[0]>=2*timestep - mjDSBL_SENSOR = 1<<13, // sensors - mjDSBL_MIDPHASE = 1<<14, // mid-phase collision filtering - mjDSBL_EULERDAMP = 1<<15, // implicit integration of joint damping in Euler integrator - mjDSBL_AUTORESET = 1<<16, // automatic reset when numerical issues are detected - mjDSBL_NATIVECCD = 1<<17, // native convex collision detection - mjDSBL_ISLAND = 1<<18, // constraint island discovery - - mjNDISABLE = 19 // number of disable flags -} mjtDisableBit; - - -typedef enum mjtEnableBit_ { // enable optional feature bitflags - mjENBL_OVERRIDE = 1<<0, // override contact parameters - mjENBL_ENERGY = 1<<1, // energy computation - mjENBL_FWDINV = 1<<2, // record solver statistics - mjENBL_INVDISCRETE = 1<<3, // discrete-time inverse dynamics - // experimental features: - mjENBL_MULTICCD = 1<<4, // multi-point convex collision detection - mjENBL_SLEEP = 1<<5, // sleeping - - mjNENABLE = 6 // number of enable flags -} mjtEnableBit; - - -typedef enum mjtJoint_ { // type of degree of freedom - mjJNT_FREE = 0, // global position and orientation (quat) (7) - mjJNT_BALL, // orientation (quat) relative to parent (4) - mjJNT_SLIDE, // sliding distance along body-fixed axis (1) - mjJNT_HINGE // rotation angle (rad) around body-fixed axis (1) -} mjtJoint; - - -typedef enum mjtGeom_ { // type of geometric shape - // regular geom types - mjGEOM_PLANE = 0, // plane - mjGEOM_HFIELD, // height field - mjGEOM_SPHERE, // sphere - mjGEOM_CAPSULE, // capsule - mjGEOM_ELLIPSOID, // ellipsoid - mjGEOM_CYLINDER, // cylinder - mjGEOM_BOX, // box - mjGEOM_MESH, // mesh - mjGEOM_SDF, // signed distance field - - mjNGEOMTYPES, // number of regular geom types - - // rendering-only geom types: not used in mjModel, not counted in mjNGEOMTYPES - mjGEOM_ARROW = 100, // arrow - mjGEOM_ARROW1, // arrow without wedges - mjGEOM_ARROW2, // arrow in both directions - mjGEOM_LINE, // line - mjGEOM_LINEBOX, // box with line edges - mjGEOM_FLEX, // flex - mjGEOM_SKIN, // skin - mjGEOM_LABEL, // text label - mjGEOM_TRIANGLE, // triangle - - mjGEOM_NONE = 1001 // missing geom type -} mjtGeom; - - -typedef enum mjtCamLight_ { // tracking mode for camera and light - mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body - mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global - mjCAMLIGHT_TRACKCOM, // pos tracks subtree com, rot fixed in body - mjCAMLIGHT_TARGETBODY, // pos fixed in body, rot tracks target body - mjCAMLIGHT_TARGETBODYCOM // pos fixed in body, rot tracks target subtree com -} mjtCamLight; - - -typedef enum mjtLightType_ { // type of light - mjLIGHT_SPOT = 0, // spot - mjLIGHT_DIRECTIONAL, // directional - mjLIGHT_POINT, // point - mjLIGHT_IMAGE, // image-based -} mjtLightType; - - -typedef enum mjtTexture_ { // type of texture - mjTEXTURE_2D = 0, // 2d texture, suitable for planes and hfields - mjTEXTURE_CUBE, // cube texture, suitable for all other geom types - mjTEXTURE_SKYBOX // cube texture used as skybox -} mjtTexture; - - -typedef enum mjtTextureRole_ { // role of texture map in rendering - mjTEXROLE_USER = 0, // unspecified - mjTEXROLE_RGB, // base color (albedo) - mjTEXROLE_OCCLUSION, // ambient occlusion - mjTEXROLE_ROUGHNESS, // roughness - mjTEXROLE_METALLIC, // metallic - mjTEXROLE_NORMAL, // normal (bump) map - mjTEXROLE_OPACITY, // transperancy - mjTEXROLE_EMISSIVE, // light emission - mjTEXROLE_RGBA, // base color, opacity - mjTEXROLE_ORM, // occlusion, roughness, metallic - mjNTEXROLE -} mjtTextureRole; - - -typedef enum mjtColorSpace_ { // type of color space encoding - mjCOLORSPACE_AUTO = 0, // attempts to autodetect color space, defaults to linear - mjCOLORSPACE_LINEAR, // linear color space - mjCOLORSPACE_SRGB // standard RGB color space -} mjtColorSpace; - - -typedef enum mjtIntegrator_ { // integrator mode - mjINT_EULER = 0, // semi-implicit Euler - mjINT_RK4, // 4th-order Runge Kutta - mjINT_IMPLICIT, // implicit in velocity - mjINT_IMPLICITFAST // implicit in velocity, no rne derivative -} mjtIntegrator; - - -typedef enum mjtCone_ { // type of friction cone - mjCONE_PYRAMIDAL = 0, // pyramidal - mjCONE_ELLIPTIC // elliptic -} mjtCone; - - -typedef enum mjtJacobian_ { // type of constraint Jacobian - mjJAC_DENSE = 0, // dense - mjJAC_SPARSE, // sparse - mjJAC_AUTO // dense if nv<60, sparse otherwise -} mjtJacobian; - - -typedef enum mjtSolver_ { // constraint solver algorithm - mjSOL_PGS = 0, // PGS (dual) - mjSOL_CG, // CG (primal) - mjSOL_NEWTON // Newton (primal) -} mjtSolver; - - -typedef enum mjtEq_ { // type of equality constraint - mjEQ_CONNECT = 0, // connect two bodies at a point (ball joint) - mjEQ_WELD, // fix relative position and orientation of two bodies - mjEQ_JOINT, // couple the values of two scalar joints with cubic - mjEQ_TENDON, // couple the lengths of two tendons with cubic - mjEQ_FLEX, // fix all edge lengths of a flex - mjEQ_DISTANCE // unsupported, will cause an error if used -} mjtEq; - - -typedef enum mjtWrap_ { // type of tendon wrap object - mjWRAP_NONE = 0, // null object - mjWRAP_JOINT, // constant moment arm - mjWRAP_PULLEY, // pulley used to split tendon - mjWRAP_SITE, // pass through site - mjWRAP_SPHERE, // wrap around sphere - mjWRAP_CYLINDER // wrap around (infinite) cylinder -} mjtWrap; - - -typedef enum mjtTrn_ { // type of actuator transmission - mjTRN_JOINT = 0, // force on joint - mjTRN_JOINTINPARENT, // force on joint, expressed in parent frame - mjTRN_SLIDERCRANK, // force via slider-crank linkage - mjTRN_TENDON, // force on tendon - mjTRN_SITE, // force on site - mjTRN_BODY, // adhesion force on a body's geoms - - mjTRN_UNDEFINED = 1000 // undefined transmission type -} mjtTrn; - - -typedef enum mjtDyn_ { // type of actuator dynamics - mjDYN_NONE = 0, // no internal dynamics; ctrl specifies force - mjDYN_INTEGRATOR, // integrator: da/dt = u - mjDYN_FILTER, // linear filter: da/dt = (u-a) / tau - mjDYN_FILTEREXACT, // linear filter: da/dt = (u-a) / tau, with exact integration - mjDYN_MUSCLE, // piece-wise linear filter with two time constants - mjDYN_USER // user-defined dynamics type -} mjtDyn; - - -typedef enum mjtGain_ { // type of actuator gain - mjGAIN_FIXED = 0, // fixed gain - mjGAIN_AFFINE, // const + kp*length + kv*velocity - mjGAIN_MUSCLE, // muscle FLV curve computed by mju_muscleGain() - mjGAIN_USER // user-defined gain type -} mjtGain; - - -typedef enum mjtBias_ { // type of actuator bias - mjBIAS_NONE = 0, // no bias - mjBIAS_AFFINE, // const + kp*length + kv*velocity - mjBIAS_MUSCLE, // muscle passive force computed by mju_muscleBias() - mjBIAS_USER // user-defined bias type -} mjtBias; - - -typedef enum mjtObj_ { // type of MujoCo object - mjOBJ_UNKNOWN = 0, // unknown object type - mjOBJ_BODY, // body - mjOBJ_XBODY, // body, used to access regular frame instead of i-frame - mjOBJ_JOINT, // joint - mjOBJ_DOF, // dof - mjOBJ_GEOM, // geom - mjOBJ_SITE, // site - mjOBJ_CAMERA, // camera - mjOBJ_LIGHT, // light - mjOBJ_FLEX, // flex - mjOBJ_MESH, // mesh - mjOBJ_SKIN, // skin - mjOBJ_HFIELD, // heightfield - mjOBJ_TEXTURE, // texture - mjOBJ_MATERIAL, // material for rendering - mjOBJ_PAIR, // geom pair to include - mjOBJ_EXCLUDE, // body pair to exclude - mjOBJ_EQUALITY, // equality constraint - mjOBJ_TENDON, // tendon - mjOBJ_ACTUATOR, // actuator - mjOBJ_SENSOR, // sensor - mjOBJ_NUMERIC, // numeric - mjOBJ_TEXT, // text - mjOBJ_TUPLE, // tuple - mjOBJ_KEY, // keyframe - mjOBJ_PLUGIN, // plugin instance - - mjNOBJECT, // number of object types - - // meta elements, do not appear in mjModel - mjOBJ_FRAME = 100, // frame - mjOBJ_DEFAULT, // default - mjOBJ_MODEL // entire model - -} mjtObj; - - -typedef enum mjtSensor_ { // type of sensor - // common robotic sensors, attached to a site - mjSENS_TOUCH = 0, // scalar contact normal forces summed over sensor zone - mjSENS_ACCELEROMETER, // 3D linear acceleration, in local frame - mjSENS_VELOCIMETER, // 3D linear velocity, in local frame - mjSENS_GYRO, // 3D angular velocity, in local frame - mjSENS_FORCE, // 3D force between site's body and its parent body - mjSENS_TORQUE, // 3D torque between site's body and its parent body - mjSENS_MAGNETOMETER, // 3D magnetometer - mjSENS_RANGEFINDER, // scalar distance to nearest geom or site along z-axis - mjSENS_CAMPROJECTION, // pixel coordinates of a site in the camera image - - // sensors related to scalar joints, tendons, actuators - mjSENS_JOINTPOS, // scalar joint position (hinge and slide only) - mjSENS_JOINTVEL, // scalar joint velocity (hinge and slide only) - mjSENS_TENDONPOS, // scalar tendon position - mjSENS_TENDONVEL, // scalar tendon velocity - mjSENS_ACTUATORPOS, // scalar actuator position - mjSENS_ACTUATORVEL, // scalar actuator velocity - mjSENS_ACTUATORFRC, // scalar actuator force - mjSENS_JOINTACTFRC, // scalar actuator force, measured at the joint - mjSENS_TENDONACTFRC, // scalar actuator force, measured at the tendon - - // sensors related to ball joints - mjSENS_BALLQUAT, // 4D ball joint quaternion - mjSENS_BALLANGVEL, // 3D ball joint angular velocity - - // joint and tendon limit sensors, in constraint space - mjSENS_JOINTLIMITPOS, // joint limit distance-margin - mjSENS_JOINTLIMITVEL, // joint limit velocity - mjSENS_JOINTLIMITFRC, // joint limit force - mjSENS_TENDONLIMITPOS, // tendon limit distance-margin - mjSENS_TENDONLIMITVEL, // tendon limit velocity - mjSENS_TENDONLIMITFRC, // tendon limit force - - // sensors attached to an object with spatial frame: (x)body, geom, site, camera - mjSENS_FRAMEPOS, // 3D position - mjSENS_FRAMEQUAT, // 4D unit quaternion orientation - mjSENS_FRAMEXAXIS, // 3D unit vector: x-axis of object's frame - mjSENS_FRAMEYAXIS, // 3D unit vector: y-axis of object's frame - mjSENS_FRAMEZAXIS, // 3D unit vector: z-axis of object's frame - mjSENS_FRAMELINVEL, // 3D linear velocity - mjSENS_FRAMEANGVEL, // 3D angular velocity - mjSENS_FRAMELINACC, // 3D linear acceleration - mjSENS_FRAMEANGACC, // 3D angular acceleration - - // sensors related to kinematic subtrees; attached to a body (which is the subtree root) - mjSENS_SUBTREECOM, // 3D center of mass of subtree - mjSENS_SUBTREELINVEL, // 3D linear velocity of subtree - mjSENS_SUBTREEANGMOM, // 3D angular momentum of subtree - - // sensors of geometric relationships - mjSENS_INSIDESITE, // 1 if object is inside a site, 0 otherwise - mjSENS_GEOMDIST, // signed distance between two geoms - mjSENS_GEOMNORMAL, // normal direction between two geoms - mjSENS_GEOMFROMTO, // segment between two geoms - - // sensors for reporting contacts which occurred during the simulation - mjSENS_CONTACT, // contacts which occurred during the simulation - - // global sensors - mjSENS_E_POTENTIAL, // potential energy - mjSENS_E_KINETIC, // kinetic energy - mjSENS_CLOCK, // simulation time - - // sensors related to SDFs - mjSENS_TACTILE, // tactile sensor - - // plugin-controlled sensors - mjSENS_PLUGIN, // plugin-controlled - - // user-defined sensor - mjSENS_USER // sensor data provided by mjcb_sensor callback -} mjtSensor; - - -typedef enum mjtStage_ { // computation stage - mjSTAGE_NONE = 0, // no computations - mjSTAGE_POS, // position-dependent computations - mjSTAGE_VEL, // velocity-dependent computations - mjSTAGE_ACC // acceleration/force-dependent computations -} mjtStage; - - -typedef enum mjtDataType_ { // data type for sensors - mjDATATYPE_REAL = 0, // real values, no constraints - mjDATATYPE_POSITIVE, // positive values; 0 or negative: inactive - mjDATATYPE_AXIS, // 3D unit vector - mjDATATYPE_QUATERNION // unit quaternion -} mjtDataType; - - -typedef enum mjtConDataField_ { // data fields returned by contact sensors - mjCONDATA_FOUND = 0, // whether a contact was found - mjCONDATA_FORCE, // contact force - mjCONDATA_TORQUE, // contact torque - mjCONDATA_DIST, // contact penetration distance - mjCONDATA_POS, // contact position - mjCONDATA_NORMAL, // contact frame normal - mjCONDATA_TANGENT, // contact frame first tangent - - mjNCONDATA = 7 // number of contact sensor data fields -} mjtConDataField; - - -typedef enum mjtSameFrame_ { // frame alignment of bodies with their children - mjSAMEFRAME_NONE = 0, // no alignment - mjSAMEFRAME_BODY, // frame is same as body frame - mjSAMEFRAME_INERTIA, // frame is same as inertial frame - mjSAMEFRAME_BODYROT, // frame orientation is same as body orientation - mjSAMEFRAME_INERTIAROT // frame orientation is same as inertia orientation -} mjtSameFrame; - - -typedef enum mjtSleepPolicy_ { // per-tree sleep policy - mjSLEEP_AUTO = 0, // compiler chooses sleep policy - mjSLEEP_AUTO_NEVER, // compiler sleep policy: never - mjSLEEP_AUTO_ALLOWED, // compiler sleep policy: allowed - mjSLEEP_NEVER, // user sleep policy: never - mjSLEEP_ALLOWED, // user sleep policy: allowed - mjSLEEP_INIT, // user sleep policy: initialized asleep -} mjtSleepPolicy; - - -typedef enum mjtLRMode_ { // mode for actuator length range computation - mjLRMODE_NONE = 0, // do not process any actuators - mjLRMODE_MUSCLE, // process muscle actuators - mjLRMODE_MUSCLEUSER, // process muscle and user actuators - mjLRMODE_ALL // process all actuators -} mjtLRMode; - - -typedef enum mjtFlexSelf_ { // mode for flex selfcollide - mjFLEXSELF_NONE = 0, // no self-collisions - mjFLEXSELF_NARROW, // skip midphase, go directly to narrowphase - mjFLEXSELF_BVH, // use BVH in midphase (if midphase enabled) - mjFLEXSELF_SAP, // use SAP in midphase - mjFLEXSELF_AUTO // choose between BVH and SAP automatically -} mjtFlexSelf; - - -typedef enum mjtSDFType_ { // signed distance function (SDF) type - mjSDFTYPE_SINGLE = 0, // single SDF - mjSDFTYPE_INTERSECTION, // max(A, B) - mjSDFTYPE_MIDSURFACE, // A - B - mjSDFTYPE_COLLISION, // A + B + abs(max(A, B)) -} mjtSDFType; - //---------------------------------- mjLROpt ------------------------------------------------------- @@ -471,8 +76,8 @@ typedef struct mjCache_ mjCache; //---------------------------------- mjVFS --------------------------------------------------------- -struct mjVFS_ { // virtual file system for loading from memory - void* impl_; // internal pointer to VFS memory +struct mjVFS_ { // virtual file system for loading from memory + void* impl_; // internal pointer to VFS memory }; typedef struct mjVFS_ mjVFS; @@ -530,7 +135,7 @@ typedef struct mjOption_ mjOption; struct mjVisual_ { // visualization options struct { // global parameters int cameraid; // initial camera id (-1: free) - int orthographic; // is the free camera orthographic (0: no, 1: yes) + int orthographic; // is the free camera orthographic (0: no, 1: yes) float fovy; // y field-of-view of free camera (orthographic ? length : degree) float ipd; // inter-pupilary distance for free camera float azimuth; // initial azimuth of free camera (degrees) @@ -644,93 +249,100 @@ struct mjModel_ { // ------------------------------- sizes // sizes needed at mjModel construction - int nq; // number of generalized coordinates = dim(qpos) - int nv; // number of degrees of freedom = dim(qvel) - int nu; // number of actuators/controls = dim(ctrl) - int na; // number of activation states = dim(act) - int nbody; // number of bodies - int nbvh; // number of total bounding volumes in all bodies - int nbvhstatic; // number of static bounding volumes (aabb stored in mjModel) - int nbvhdynamic; // number of dynamic bounding volumes (aabb stored in mjData) - int noct; // number of total octree cells in all meshes - int njnt; // number of joints - int ntree; // number of kinematic trees under world body - int nM; // number of non-zeros in sparse inertia matrix - int nB; // number of non-zeros in sparse body-dof matrix - int nC; // number of non-zeros in sparse reduced dof-dof matrix - int nD; // number of non-zeros in sparse dof-dof matrix - int ngeom; // number of geoms - int nsite; // number of sites - int ncam; // number of cameras - int nlight; // number of lights - int nflex; // number of flexes - int nflexnode; // number of dofs in all flexes - int nflexvert; // number of vertices in all flexes - int nflexedge; // number of edges in all flexes - int nflexelem; // number of elements in all flexes - int nflexelemdata; // number of element vertex ids in all flexes - int nflexelemedge; // number of element edge ids in all flexes - int nflexshelldata; // number of shell fragment vertex ids in all flexes - int nflexevpair; // number of element-vertex pairs in all flexes - int nflextexcoord; // number of vertices with texture coordinates - int nmesh; // number of meshes - int nmeshvert; // number of vertices in all meshes - int nmeshnormal; // number of normals in all meshes - int nmeshtexcoord; // number of texcoords in all meshes - int nmeshface; // number of triangular faces in all meshes - int nmeshgraph; // number of ints in mesh auxiliary data - int nmeshpoly; // number of polygons in all meshes - int nmeshpolyvert; // number of vertices in all polygons - int nmeshpolymap; // number of polygons in vertex map - int nskin; // number of skins - int nskinvert; // number of vertices in all skins - int nskintexvert; // number of vertiex with texcoords in all skins - int nskinface; // number of triangular faces in all skins - int nskinbone; // number of bones in all skins - int nskinbonevert; // number of vertices in all skin bones - int nhfield; // number of heightfields - int nhfielddata; // number of data points in all heightfields - int ntex; // number of textures - int ntexdata; // number of bytes in texture rgb data - int nmat; // number of materials - int npair; // number of predefined geom pairs - int nexclude; // number of excluded geom pairs - int neq; // number of equality constraints - int ntendon; // number of tendons - int nwrap; // number of wrap objects in all tendon paths - int nsensor; // number of sensors - int nnumeric; // number of numeric custom fields - int nnumericdata; // number of mjtNums in all numeric fields - int ntext; // number of text custom fields - int ntextdata; // number of mjtBytes in all text fields - int ntuple; // number of tuple custom fields - int ntupledata; // number of objects in all tuple fields - int nkey; // number of keyframes - int nmocap; // number of mocap bodies - int nplugin; // number of plugin instances - int npluginattr; // number of chars in all plugin config attributes - int nuser_body; // number of mjtNums in body_user - int nuser_jnt; // number of mjtNums in jnt_user - int nuser_geom; // number of mjtNums in geom_user - int nuser_site; // number of mjtNums in site_user - int nuser_cam; // number of mjtNums in cam_user - int nuser_tendon; // number of mjtNums in tendon_user - int nuser_actuator; // number of mjtNums in actuator_user - int nuser_sensor; // number of mjtNums in sensor_user - int nnames; // number of chars in all names - int npaths; // number of chars in all paths + mjtSize nq; // number of generalized coordinates = dim(qpos) + mjtSize nv; // number of degrees of freedom = dim(qvel) + mjtSize nu; // number of actuators/controls = dim(ctrl) + mjtSize na; // number of activation states = dim(act) + mjtSize nbody; // number of bodies + mjtSize nbvh; // number of total bounding volumes in all bodies + mjtSize nbvhstatic; // number of static bounding volumes (aabb stored in mjModel) + mjtSize nbvhdynamic; // number of dynamic bounding volumes (aabb stored in mjData) + mjtSize noct; // number of total octree cells in all meshes + mjtSize njnt; // number of joints + mjtSize ntree; // number of kinematic trees under world body + mjtSize nM; // number of non-zeros in sparse inertia matrix + mjtSize nB; // number of non-zeros in sparse body-dof matrix + mjtSize nC; // number of non-zeros in sparse reduced dof-dof matrix + mjtSize nD; // number of non-zeros in sparse dof-dof matrix + mjtSize ngeom; // number of geoms + mjtSize nsite; // number of sites + mjtSize ncam; // number of cameras + mjtSize nlight; // number of lights + mjtSize nflex; // number of flexes + mjtSize nflexnode; // number of dofs in all flexes + mjtSize nflexvert; // number of vertices in all flexes + mjtSize nflexedge; // number of edges in all flexes + mjtSize nflexelem; // number of elements in all flexes + mjtSize nflexelemdata; // number of element vertex ids in all flexes + mjtSize nflexstiffness; // number of stiffness parameters in all flexes + mjtSize nflexbending; // number of bending parameters in all flexes + mjtSize nflexelemedge; // number of element edge ids in all flexes + mjtSize nflexshelldata; // number of shell fragment vertex ids in all flexes + mjtSize nflexevpair; // number of element-vertex pairs in all flexes + mjtSize nflextexcoord; // number of vertices with texture coordinates + mjtSize nJfe; // number of non-zeros in sparse flexedge Jacobian matrix + mjtSize nJfv; // number of non-zeros in sparse flexvert Jacobian matrix + mjtSize nmesh; // number of meshes + mjtSize nmeshvert; // number of vertices in all meshes + mjtSize nmeshnormal; // number of normals in all meshes + mjtSize nmeshtexcoord; // number of texcoords in all meshes + mjtSize nmeshface; // number of triangular faces in all meshes + mjtSize nmeshgraph; // number of ints in mesh auxiliary data + mjtSize nmeshpoly; // number of polygons in all meshes + mjtSize nmeshpolyvert; // number of vertices in all polygons + mjtSize nmeshpolymap; // number of polygons in vertex map + mjtSize nskin; // number of skins + mjtSize nskinvert; // number of vertices in all skins + mjtSize nskintexvert; // number of vertices with texcoords in all skins + mjtSize nskinface; // number of triangular faces in all skins + mjtSize nskinbone; // number of bones in all skins + mjtSize nskinbonevert; // number of vertices in all skin bones + mjtSize nhfield; // number of heightfields + mjtSize nhfielddata; // number of data points in all heightfields + mjtSize ntex; // number of textures + mjtSize ntexdata; // number of bytes in texture rgb data + mjtSize nmat; // number of materials + mjtSize npair; // number of predefined geom pairs + mjtSize nexclude; // number of excluded geom pairs + mjtSize neq; // number of equality constraints + mjtSize ntendon; // number of tendons + mjtSize nJten; // number of non-zeros in sparse ten_J matrix + mjtSize nwrap; // number of wrap objects in all tendon paths + mjtSize nsensor; // number of sensors + mjtSize nnumeric; // number of numeric custom fields + mjtSize nnumericdata; // number of mjtNums in all numeric fields + mjtSize ntext; // number of text custom fields + mjtSize ntextdata; // number of mjtBytes in all text fields + mjtSize ntuple; // number of tuple custom fields + mjtSize ntupledata; // number of objects in all tuple fields + mjtSize nkey; // number of keyframes + mjtSize nmocap; // number of mocap bodies + mjtSize nplugin; // number of plugin instances + mjtSize npluginattr; // number of chars in all plugin config attributes + mjtSize nuser_body; // number of mjtNums in body_user + mjtSize nuser_jnt; // number of mjtNums in jnt_user + mjtSize nuser_geom; // number of mjtNums in geom_user + mjtSize nuser_site; // number of mjtNums in site_user + mjtSize nuser_cam; // number of mjtNums in cam_user + mjtSize nuser_tendon; // number of mjtNums in tendon_user + mjtSize nuser_actuator; // number of mjtNums in actuator_user + mjtSize nuser_sensor; // number of mjtNums in sensor_user + mjtSize nnames; // number of chars in all names + mjtSize npaths; // number of chars in all paths // sizes set after mjModel construction - int nnames_map; // number of slots in the names hash map - int nJmom; // number of non-zeros in sparse actuator_moment matrix - int ngravcomp; // number of bodies with nonzero gravcomp - int nemax; // number of potential equality-constraint rows - int njmax; // number of available rows in constraint Jacobian (legacy) - int nconmax; // number of potential contacts in contact list (legacy) - int nuserdata; // number of mjtNums reserved for the user - int nsensordata; // number of mjtNums in sensor data vector - int npluginstate; // number of mjtNums in plugin state vector - + mjtSize nnames_map; // number of slots in the names hash map + mjtSize nJmom; // number of non-zeros in sparse actuator_moment matrix + mjtSize ngravcomp; // number of bodies with nonzero gravcomp + mjtSize nemax; // number of potential equality-constraint rows + mjtSize njmax; // number of available rows in constraint Jacobian (legacy) + mjtSize nconmax; // number of potential contacts in contact list (legacy) + mjtSize nuserdata; // number of mjtNums reserved for the user + mjtSize nsensordata; // number of mjtNums in sensor data vector + mjtSize npluginstate; // number of mjtNums in plugin state vector + mjtSize nhistory; // number of mjtNums in history buffer + + // buffer sizes mjtSize narena; // number of bytes in the mjData arena (inclusive of stack) mjtSize nbuffer; // number of bytes in buffer @@ -751,8 +363,8 @@ struct mjModel_ { // bodies int* body_parentid; // id of body's parent (nbody x 1) - int* body_rootid; // id of root above body (nbody x 1) - int* body_weldid; // id of body that this body is welded to (nbody x 1) + int* body_rootid; // ancestor that is direct child of world (nbody x 1) + int* body_weldid; // top ancestor with no dofs to this body (nbody x 1) int* body_mocapid; // id of mocap data; -1: none (nbody x 1) int* body_jntnum; // number of joints for this body (nbody x 1) int* body_jntadr; // start addr of joints; -1: no joints (nbody x 1) @@ -797,15 +409,17 @@ struct mjModel_ { int* jnt_qposadr; // start addr in 'qpos' for joint's data (njnt x 1) int* jnt_dofadr; // start addr in 'qvel' for joint's data (njnt x 1) int* jnt_bodyid; // id of joint's body (njnt x 1) + int* jnt_actuatorid; // actuator contributing damping / armature (njnt x 1) int* jnt_group; // group for visibility (njnt x 1) - mjtByte* jnt_limited; // does joint have limits (njnt x 1) - mjtByte* jnt_actfrclimited; // does joint have actuator force limits (njnt x 1) - mjtByte* jnt_actgravcomp; // is gravcomp force applied via actuators (njnt x 1) + mjtBool* jnt_limited; // does joint have limits (njnt x 1) + mjtBool* jnt_actfrclimited; // does joint have actuator force limits (njnt x 1) + mjtBool* jnt_actgravcomp; // is gravcomp force applied via actuators (njnt x 1) mjtNum* jnt_solref; // constraint solver reference: limit (njnt x mjNREF) mjtNum* jnt_solimp; // constraint solver impedance: limit (njnt x mjNIMP) mjtNum* jnt_pos; // local anchor position (njnt x 3) mjtNum* jnt_axis; // local joint axis (njnt x 3) - mjtNum* jnt_stiffness; // stiffness coefficient (njnt x 1) + mjtNum* jnt_stiffness; // linear stiffness coefficient (njnt x 1) + mjtNum* jnt_stiffnesspoly; // high-order stiffness coefficients (njnt x mjNPOLY) mjtNum* jnt_range; // joint limits (njnt x 2) mjtNum* jnt_actfrcrange; // range of total actuator force (njnt x 2) mjtNum* jnt_margin; // min distance for limit detection (njnt x 1) @@ -822,7 +436,8 @@ struct mjModel_ { mjtNum* dof_solimp; // constraint solver impedance:frictionloss (nv x mjNIMP) mjtNum* dof_frictionloss; // dof friction loss (nv x 1) mjtNum* dof_armature; // dof armature inertia/mass (nv x 1) - mjtNum* dof_damping; // damping coefficient (nv x 1) + mjtNum* dof_damping; // linear damping coefficient (nv x 1) + mjtNum* dof_dampingpoly; // high-order damping coefficients (nv x mjNPOLY) mjtNum* dof_invweight0; // diag. inverse inertia in qpos0 (nv x 1) mjtNum* dof_M0; // diag. inertia in qpos0 (nv x 1) mjtNum* dof_length; // linear: 1; angular: approx. length scale (nv x 1) @@ -855,8 +470,8 @@ struct mjModel_ { mjtNum* geom_pos; // local position offset rel. to body (ngeom x 3) mjtNum* geom_quat; // local orientation offset rel. to body (ngeom x 4) mjtNum* geom_friction; // friction for (slide, spin, roll) (ngeom x 3) - mjtNum* geom_margin; // detect contact if dist #include #include -#include +#include #include @@ -27,12 +27,16 @@ struct mjResource_ { char* name; // name of resource (filename, etc) void* data; // opaque data pointer + mjVFS* vfs; // pointer to the VFS char timestamp[512]; // timestamp of the resource const struct mjpResourceProvider* provider; // pointer to the provider }; typedef struct mjResource_ mjResource; -// callback for opening a resource, returns zero on failure +// callback for opening a resource, returns zero on failure. +// Note: If opening fails, the close callback will not be called. Therefore, the +// open callback is responsible for cleaning up any allocated memory before +// returning 0. typedef int (*mjfOpenResource)(mjResource* resource); // callback for reading a resource @@ -42,9 +46,11 @@ typedef int (*mjfReadResource)(mjResource* resource, const void** buffer); // callback for closing a resource (responsible for freeing any allocated memory) typedef void (*mjfCloseResource)(mjResource* resource); -// callback for returning the directory of a resource -// sets dir to directory string with ndir being size of directory string -typedef void (*mjfGetResourceDir)(mjResource* resource, const char** dir, int* ndir); +// callback for mounting a resource (provider), returns zero on failure +typedef int (*mjfMountResource)(mjResource* resource); + +// callback for unmounting a resource (provider), returns zero on failure +typedef int (*mjfUnmountResource)(mjResource* resource); // callback for checking if the current resource was modified from the time // specified by the timestamp @@ -59,7 +65,8 @@ struct mjpResourceProvider { mjfOpenResource open; // opening callback mjfReadResource read; // reading callback mjfCloseResource close; // closing callback - mjfGetResourceDir getdir; // get directory callback (optional) + mjfMountResource mount; // mounting callback (optional) + mjfUnmountResource unmount; // unmounting callback (optional) mjfResourceModified modified; // resource modified callback (optional) void* data; // opaque data pointer (resource invariant) }; @@ -69,7 +76,7 @@ typedef struct mjpResourceProvider mjpResourceProvider; // function pointer types // return an mjSpec representing the decoded resource. -typedef mjSpec* (*mjfDecode)(const mjResource* resource); +typedef mjSpec* (*mjfDecode)(mjResource* resource, const mjVFS* vfs); // return true if the given resource can be decoded. typedef int (*mjfCanDecode)(const mjResource* resource); @@ -85,6 +92,19 @@ struct mjpDecoder { }; typedef struct mjpDecoder mjpDecoder; +//---------------------------------- Encoder ------------------------------------------------------- + +typedef int (*mjfEncode)(const mjSpec* s, const mjModel* m, const mjVFS* vfs, + mjResource* resource); + +struct mjpEncoder { + const char* content_type; + const char* extension; + mjfEncode encode; // Function to encode an mjSpec and mjModel to a mjResource. + mjfCloseResource close_resource; // Function to close/free the resource. +}; +typedef struct mjpEncoder mjpEncoder; + //---------------------------------- Plugins ------------------------------------------------------- typedef enum mjtPluginCapabilityBit_ { @@ -165,39 +185,46 @@ struct mjSDF_ { }; typedef struct mjSDF_ mjSDF; -#if defined(__has_attribute) +//------------------------------------ Initialization ---------------------------------------------- +#if defined(__has_attribute) #if __has_attribute(constructor) - #define mjPLUGIN_LIB_INIT __attribute__((constructor)) static void _mjplugin_init(void) - #endif // __has_attribute(constructor) - -#elif defined(_MSC_VER) - - #ifndef mjDLLMAIN - #define mjDLLMAIN DllMain + #define mjPLUGIN_LIB_INIT(n) \ + static void _mj_init_##n(void) __attribute__((constructor)); \ + static void _mj_init_##n(void) #endif - - #if !defined(mjEXTERNC) - #if defined(__cplusplus) - #define mjEXTERNC extern "C" +#elif defined(_MSC_VER) + // on x86, symbols are decorated with a leading underscore + #ifdef _M_IX86 + #define LINKER_NAME "__mj_ptr_" #else - #define mjEXTERNC - #endif // defined(__cplusplus) - #endif // !defined(mjEXTERNC) - - // NOLINTBEGIN(runtime/int) - #define mjPLUGIN_LIB_INIT \ - static void _mjplugin_dllmain(void); \ - mjEXTERNC int __stdcall mjDLLMAIN(void* hinst, unsigned long reason, void* reserved) { \ - if (reason == 1) { \ - _mjplugin_dllmain(); \ - } \ - return 1; \ - } \ - static void _mjplugin_dllmain(void) - // NOLINTEND(runtime/int) - -#endif // defined(_MSC_VER) + #define LINKER_NAME "_mj_ptr_" + #endif + + #pragma section(".CRT$XCU", read) + + #if !defined(mjEXTERNC) + #if defined(__cplusplus) + #define mjEXTERNC extern "C" + #else + #define mjEXTERNC + #endif // defined(__cplusplus) + #endif // !defined(mjEXTERNC) + + #define mjPLUGIN_LIB_INIT(n) \ + static void __cdecl _mj_init_##n(void); \ + /* use mjEXTERNC to prevent C++ name mangling */ \ + /* allocate the function pointer to the .CRT$XCU section of the executable */ \ + /* functions in this section are executed on startup before calling main() */ \ + mjEXTERNC __declspec(allocate(".CRT$XCU")) \ + void (__cdecl * _mj_ptr_##n)(void) = _mj_init_##n; \ + /* Force the linker to include the pointer symbol */ \ + __pragma(comment(linker, "/include:" LINKER_NAME #n)) \ + static void __cdecl _mj_init_##n(void) + +#else + #error "Unknown compiler: Plugin registration not supported." +#endif // function pointer type for mj_loadAllPluginLibraries callback typedef void (*mjfPluginLibraryLoadCallback)(const char* filename, int first, int count); diff --git a/vendor/include/mujoco/mjrender.h b/vendor/include/mujoco/mjrender.h index 4eeacea..5a927c3 100644 --- a/vendor/include/mujoco/mjrender.h +++ b/vendor/include/mujoco/mjrender.h @@ -15,7 +15,8 @@ #ifndef MUJOCO_MJRENDER_H_ #define MUJOCO_MJRENDER_H_ -#include +#include +#include #if defined(__cplusplus) extern "C" { @@ -44,11 +45,13 @@ typedef enum mjtFramebuffer_ { // OpenGL framebuffer option mjFB_OFFSCREEN // offscreen buffer } mjtFramebuffer; + typedef enum mjtDepthMap_ { // depth mapping for `mjr_readPixels` mjDEPTH_ZERONEAR = 0, // standard depth map; 0: znear, 1: zfar mjDEPTH_ZEROFAR = 1 // reversed depth map; 1: znear, 0: zfar } mjtDepthMap; + 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 @@ -66,6 +69,46 @@ typedef enum mjtFont_ { // font type, used at each text operation } mjtFont; +typedef enum mjrPixelFormat_ { // pixel format for textures + mjPIXEL_FORMAT_UNKNOWN = 0, // unknown/unspecified + mjPIXEL_FORMAT_R8, // 1 channel, 8 bit + mjPIXEL_FORMAT_RGB8, // 3 channels, 8 bits per channel + mjPIXEL_FORMAT_RGBA8, // 4 channels, 8 bits per channel + mjPIXEL_FORMAT_R32F, // 1 channel, 32 bit float + mjPIXEL_FORMAT_DEPTH32F, // 1 channel, 32 bit float, for depth buffers + mjPIXEL_FORMAT_KTX, // ktx compressed data +} mjrPixelFormat; + + +typedef enum mjrVertexAttributeUsage_ { // usage/purpose of a vertex attribute + mjVERTEX_ATTRIBUTE_USAGE_POSITION = 0, // vertex position + mjVERTEX_ATTRIBUTE_USAGE_NORMAL, // vertex normal + mjVERTEX_ATTRIBUTE_USAGE_TANGENTS, // vertex tangents + mjVERTEX_ATTRIBUTE_USAGE_UV, // vertex texture coordinates + mjVERTEX_ATTRIBUTE_USAGE_COLOR, // vertex color +} mjrVertexAttributeUsage; + + +typedef enum mjrVertexAttributeType_ { // data format of a vertex attribute + mjVERTEX_ATTRIBUTE_TYPE_FLOAT2 = 0, // 2D 32-bit float vector + mjVERTEX_ATTRIBUTE_TYPE_FLOAT3, // 3D 32-bit float vector + mjVERTEX_ATTRIBUTE_TYPE_FLOAT4, // 4D 32-bit float vector + mjVERTEX_ATTRIBUTE_TYPE_UBYTE4, // 4D unsigned 8-bit byte vector +} mjrVertexAttributeType; + + +typedef enum mjrIndexType_ { // data type of index buffer data + mjINDEX_TYPE_U16 = 0, // 16-bit unsigned integer + mjINDEX_TYPE_U32, // 32-bit unsigned integer +} mjrIndexType; + + +typedef enum mjrMeshPrimitiveType_ { // type of mesh primitive + mjMESH_PRIMITIVE_TYPE_TRIANGLES = 0, // triangles + mjMESH_PRIMITIVE_TYPE_LINES, // lines +} mjrMeshPrimitiveType; + + struct mjrRect_ { // OpenGL rectangle int left; // left (usually 0) int bottom; // bottom (usually 0) @@ -75,6 +118,21 @@ struct mjrRect_ { // OpenGL rectangle typedef struct mjrRect_ mjrRect; +struct mjrVertexAttribute_ { // vertex attribute format specification + const void* bytes; // vertex data + int usage; // mjrVertexAttributeUsage; e.g. position, normal, etc. + int type; // mjrVertexAttributeType; e.g. float3, ubyte4, etc. +}; +typedef struct mjrVertexAttribute_ mjrVertexAttribute; + + +// alias non-rendering types into mjr namespace +typedef mjtTexture mjrSamplerType; +typedef mjtColorSpace mjrColorSpace; +typedef mjtLightType mjrLightType; +typedef mjvGLCamera mjrCamera; + + //---------------------------------- mjrContext ---------------------------------------------------- struct mjrContext_ { // custom OpenGL context diff --git a/vendor/include/mujoco/mjrfilament.h b/vendor/include/mujoco/mjrfilament.h new file mode 100644 index 0000000..d6e0003 --- /dev/null +++ b/vendor/include/mujoco/mjrfilament.h @@ -0,0 +1,494 @@ +// Copyright 2025 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_MJRFILAMENT_H_ +#define MUJOCO_MJRFILAMENT_H_ + +#include + +#include +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +// IMPORTANT: This API should still be considered experimental and is likely change frequently. + +// This library provides a C API for the filament rendering library (github.com/google/filament) +// that is designed to work with the MuJoCo library for visualizing simulations. +// +// The filament renderer is a real-time physically based rendering (PBR) engine developed by Google. +// It is designed to be as small as possible and as efficient as possible, while still providing +// high-quality results. It works across all major platforms (Linux, Windows, macOS, Android, iOS, +// Web) and supports OpenGL, Vulkan, and Metal. +// +// For the purposes of this API, we assume the reader has a basic understanding of rendering +// concepts (e.g. textures, vertices, cameras, framebuffers, etc.). We will also highlight some of +// the key differences between this renderer and the legacy/classic MuJoCo (mjr) renderer. +// +// ## API Overview +// +// There are seven key components: Context, Texture, Mesh, Scene, Light, Renderable, and +// RenderTarget. We'll describe these in detail further below. +// +// Each object is created using a `create` function and destroyed using a `destroy` function, e.g. +// `mjrf_createTexture` and `mjrf_destroyTexture`. The `create` functions accept a pointer to a +// configuration struct (e.g. `mjrTextureConfig`) which describes the parameters for the object to +// be created. Each of these structs has a corresponding `default` function (e.g. +// `mjrf_defaultTextureConfig`) which can be used to initialize the struct to default values. Default +// values are assumed to be 0/NULL unless otherwise specified. +// +// For now, we'll just define opaque handles for each of our components. +typedef struct mjrfContext_ {} mjrfContext; +typedef struct mjrfTexture_ {} mjrfTexture; +typedef struct mjrfMesh_ {} mjrfMesh; +typedef struct mjrfScene_ {} mjrfScene; +typedef struct mjrfLight_ {} mjrfLight; +typedef struct mjrfRenderable_ {} mjrfRenderable; +typedef struct mjrfRenderTarget_ {} mjrfRenderTarget; + +// ## Rendering Context (mjrfContext) +// +// The Context is the main entry point for the library. It manages all the core filament objects +// that are responsible for the rendering of an image. +// +// All other objects (e.g. Textures, Meshes, Scenes, etc.) need a Context in order to be created. +// Otherwise, the main function to use with the Context is `mjrf_render()` which does the actual +// rendering. +// +// Filament uses a separate thread for doing the actual rendering. However, despite that, this API +// is not thread-safe; calls are expected to be made from a single thread. Also, due to the +// asynchronous nature of filament, some APIs provide handles or callbacks to signal when an +// operation is complete. (Note: for WASM builds, filament does not use a separate thread.) +// +// There are two key differences between the mjrfContext and the classic mjrContext. Firstly, the +// filament context will manage the underlying graphics context itself. This means users do not need +// to initialize EGL or similar libraries beforehand. Secondly, the filament context is independent +// of a MuJoCo model. That means you can use a single mjrfContext to render images for multiple +// models. + +// Callback function type for rendering operations. +typedef void (*mjrfCallback)(void* user_data); + +typedef enum mjrGraphicsApi_ { // underlying graphics API to use for rendering + mjGRAPHICS_API_DEFAULT = 0, // default (platform-dependent) + mjGRAPHICS_API_OPENGL, // desktop, mobile (GLES), web (WebGL) + mjGRAPHICS_API_VULKAN, // vulkan +} mjrGraphicsApi; + +struct mjrfContextConfig_ { // parameters for creating filament context (mjrfContext) + int graphics_api; // mjrGraphicsApi; rendering graphics API + mjtBool force_software_rendering; // force backend to use software rendering + void* native_window; // platform-dependent window handle (or nullptr for windowless) +}; +typedef struct mjrfContextConfig_ mjrfContextConfig; + +// Initializes the mjrfContextConfig to default values. +void mjrf_defaultContextConfig(mjrfContextConfig* config); + +// Creates a filament rendering context. +mjrfContext* mjrf_createContext(const mjrfContextConfig* config); + +// Destroys the filament rendering context. +void mjrf_destroyContext(mjrfContext* ctx); + +typedef enum mjrDrawMode_ { // how to draw objects in the scene + mjDRAW_MODE_DEFAULT, // default colors and lighting + mjDRAW_MODE_DEFAULT_NO_TEXTURES, // default, but without textures + mjDRAW_MODE_WIREFRAME, // wireframe rendering + mjDRAW_MODE_DEPTH, // grayscale depth map + mjDRAW_MODE_ISLANDS, // color objects based on island and sleep state + mjDRAW_MODE_SEGMENTATION_BY_ID, // color objects based on segmentation id + mjDRAW_MODE_SEGMENTATION_BY_COLOR, // generate visually distinct colors using segmentation id +} mjrDrawMode; + +struct mjrfRenderRequest_ { // a single rendering operation + mjrfScene* scene; // scene to render + mjrCamera camera; // camera (viewpoint) from which to render scene + mjrRect viewport; // viewport (rect area) into which to render + mjrfRenderTarget* target; // target used for rendering (or nullptr for window rendering) + int draw_mode; // mjrDrawMode; method to use for drawing objects + mjtBool enable_post_processing; // enable post processing, enabled by default + mjtBool enable_reflections; // enable reflections, enabled by default + mjtBool enable_shadows; // enable shadows, enabled by default +}; +typedef struct mjrfRenderRequest_ mjrfRenderRequest; + +// Initializes the mjrfRenderRequest to default values. +void mjrf_defaultRenderRequest(mjrfRenderRequest* request); + +struct mjrfReadPixelsRequest_ { // a single read operation + mjrfRenderTarget* target; // render target from which to read the image pixels + void* output; // buffer into which the pixels will be stored + mjtSize num_bytes; // size of output buffer + mjrfCallback read_completed; // callback when read is complete; can use to free output + void* user_data; // user data for read_completed_callback +}; +typedef struct mjrfReadPixelsRequest_ mjrfReadPixelsRequest; + +// Initializes the mjrfReadPixelsRequest to default values. +void mjrf_defaultReadPixelsRequest(mjrfReadPixelsRequest* request); + +// Unique handle assigned to each render request; used to block until request is completed or query +// the status of the request. +typedef uint64_t mjrfFrameHandle; + +// Submits the given requests for rendering. Because rendering happens asynchronously, callers have +// to submit both the render and read requests in the same call. Multiple requests and reads can be +// submitted in a single call. These requests will be processed in order, so some care must be +// taken. Firstly, requests should be grouped by target. Next, the combined area of the viewports +// for all requests for a given target must be contained within the dimensions of the target itself. +// +// Callbacks will be invoked from within this function, though there is no guarantee on when exactly +// that will be done. +mjrfFrameHandle mjrf_render(mjrfContext* ctx, const mjrfRenderRequest* req, int nreq, + const mjrfReadPixelsRequest* read_req, int nread_req); + +// Waits for all rendering operations to complete for the given frame handle, +// triggering any callbacks as needed. +void mjrf_waitForFrame(mjrfContext* ctx, mjrfFrameHandle frame); + +// Sets the clear color for the renderer. +void mjrf_setClearColor(mjrfContext* ctx, const float color[3]); + +struct mjrfFrameStats_ { // stats for a single frame of rendering + double frame_rate; // frame rate, in frames per second +}; +typedef struct mjrfFrameStats_ mjrfFrameStats; + +// Initializes the mjrFrameStats to default values. +void mjrf_defaultFrameStats(mjrfFrameStats* stats); + +// Returns the stats for the given frame but updating the given `stats_out`. +void mjrf_getFrameStats(mjrfContext* ctx, mjrfFrameHandle frame, mjrfFrameStats* stats_out); + +// ## Textures (mjrfTexture) +// +// A texture is a 2D or 3D (cubemap) image that adds visual detail to a rendered model, such as +// color or bumpiness, without increasing geometric complexity. +// +// For textures intended to be used for image-based lights (see `mjrfLight` below), you should use +// filament's `cmgen` tool to generate a KTX image from your source image. This tool will calculate +// additional data (i.e. the spherical harmonics) and encode that information into the KTX file. + +struct mjrfTextureConfig_ { // parameters for creating a texture (mjrfTexture) + int width; // texture width; or number of bytes for compressed data (e.g. KTX) + int height; // texture height; or 0 for compressed data (e.g. KTX) + int format; // mjrPixelFormat; (e.g. RGB8, RGBA8, KTX, etc.) + int color_space; // mjrColorSpace; (e.g. LINEAR, sRGB, etc.) + int sampler_type; // mjrSamplerType; texture sampler (e.g. 2D, cube, etc.) +}; +typedef struct mjrfTextureConfig_ mjrfTextureConfig; + +// Initializes the mjrfTextureConfig to default values. +void mjrf_defaultTextureConfig(mjrfTextureConfig* config); + +// Creates a filament texture. Note that the texture will not be created on the +// GPU until `mjrf_setTextureData()` is called. +mjrfTexture* mjrf_createTexture(mjrfContext* ctx, + const mjrfTextureConfig* config); + +// Destroys the texture. +void mjrf_destroyTexture(mjrfTexture* texture); + +struct mjrfTextureData_ { // binary data for a texture (mjrfTexture) + const void* bytes; // pointer to image data, or nullptr for empty texture + mjtSize num_bytes; // number of bytes in the image data + mjrfCallback release; // callback when data has finished uploading + void* user_data; // user data for release callback +}; +typedef struct mjrfTextureData_ mjrfTextureData; + +// Initializes the mjrfTextureData to default values. +void mjrf_defaultTextureData(mjrfTextureData* data); + +// Uploads the given texture data to the texture. +void mjrf_setTextureData(mjrfTexture* texture, const mjrfTextureData* data); + +// Returns the width of the texture. +int mjrf_getTextureWidth(const mjrfTexture* texture); + +// Returns the height of the texture. +int mjrf_getTextureHeight(const mjrfTexture* texture); + +// Returns the sampler type (mjrSamplerType) used by the texture. +int mjrf_getSamplerType(const mjrfTexture* texture); + +// ## Meshes (mjrfMesh) +// +// A mesh describes the surface geometry of an object to be rendered. It is defined as a collection +// of vertices (i.e. a VertexBuffer), a set of indices (i.e. an IndexBuffer) that describes the +// order in which the vertices should be processed, and a primitive type that defined how the +// vertices are to be interpreted (e.g. triangles, lines, etc.) when rendering the surface. +// +// Filament does not directly support normals. Instead, it encodes the normal, tangent, and +// bitangent into a 4-component quaternion describing the "orientation" of the vertex. Ideally, you +// should preprocess your assets to generate this data offline, but we will compute it on the fly if +// needed (at a performance cost). +// +// Vertex data may or may not be interleaved. Interleaved data assumes that the attributes are +// packed in the order specified in the attributes array, with no padding in-between. Additionally, +// the `data` pointer for each attribute is assumed to point to the first element of that type. For +// non-interleaved data, each attribute is assumed to be stored in a separate array. +// +// Additionally, the bounds of the mesh should be computed in order to allow the filament renderer +// to perform frustum-based culling. Alternatively, the bounds can be computed at runtime (though +// there is a small performance cost). If no bounds are provided (or calculated), then frustum +// culling will not be performed. + +// Maximum number of vertex attributes in a mesh. +enum { mjMAX_VERTEX_ATTRIBUTES = 16 }; + +struct mjrfMeshData_ { // binary data for a mesh (mjrfMesh) + mjtSize num_vertices; // number of vertices; all vertex attributes share this size + int num_attributes; // number of attributes defined + mjrVertexAttribute attributes[mjMAX_VERTEX_ATTRIBUTES]; // per-vertex attribute information + mjtBool interleaved; // true if vertex attributes are interleaved + mjtSize num_indices; // number of indices + const void* indices; // indices data array + int index_type; // mjrIndexType; (e.g. UINT16 or UINT32) + int primitive_type; // mjrMeshPrimitiveType; (e.g. TRIANGLES, etc.) + mjtBool compute_bounds; // if true, compute bounds from vertex positions + float bounds_min[3]; // min/max bounds; assume unset if bounds_min == bounds_max + float bounds_max[3]; + mjrfCallback release; // callback when data has finished uploading + void* user_data; // user data for release callback +}; +typedef struct mjrfMeshData_ mjrfMeshData; + +// Initializes the mjrfMeshData to default values. +void mjrf_defaultMeshData(mjrfMeshData* data); + +// Creates a mesh with the given data. +mjrfMesh* mjrf_createMesh(mjrfContext* ctx, const mjrfMeshData* data); + +// Destroys the mesh. +void mjrf_destroyMesh(mjrfMesh* mesh); + +// ## Scenes (mjrfScene) +// +// A scene is a collection of entities (Lights and Renderables) that describes what is to be +// rendered. + +struct mjrfSceneParams_ { // parameters for creating a scene (mjrfScene) +}; +typedef struct mjrfSceneParams_ mjrfSceneParams; + +// Initializes the mjrfSceneParams to default values. +void mjrf_defaultSceneParams(mjrfSceneParams* params); + +// Creates a scene with the given parameters. +mjrfScene* mjrf_createScene(mjrfContext* ctx, const mjrfSceneParams* params); + +// Destroys the scene. +void mjrf_destroyScene(mjrfScene* scene); + +// Adds a light to the scene. +void mjrf_addLightToScene(mjrfScene* scene, mjrfLight* light); + +// Removes the light from the scene. +void mjrf_removeLightFromScene(mjrfScene* scene, mjrfLight* light); + +// Adds a renderable to the scene. +void mjrf_addRenderableToScene(mjrfScene* scene, mjrfRenderable* renderable); + +// Removes the renderable from the scene. +void mjrf_removeRenderableFromScene(mjrfScene* scene, mjrfRenderable* renderable); + +// Sets the skybox (cube texture) for the scene. +void mjrf_setSceneSkybox(mjrfScene* scene, const mjrfTexture* texture); + +// Configures the scene based on the parameters in an mjModel. +void mjrf_configureSceneFromModel(mjrfScene* scene, const mjModel* model); + +// ## Lights (mjrfLight) +// +// A light is a source of illumination in the scene. (Without lights, a scene will be completely +// black.) There are several different types of lights such as directional, spot, point, and image +// lights. +// +// The primary light in a scene is the image light (also sometimes known as the environment light). +// This is a light that "surrounds" the entire scene and is defined as a 3D texture. Each "pixel" of +// the cubemap is interpreted as the color of projected into the scene from a particular direction. +// +// Directional lights are the next most common type of light and is usually used to simulate the +// sun; a uniformly colored light that is emitted in a single direction. +// +// Filament only supports a single image and directional light. You can define as many point or spot +// lights as you want. Each light source (except image based lights) may or may not cast shadows. +// Each shadow-casting light incurs a performance cost. + +struct mjrfLightParams_ { // parameters for creating a light (mjrfLight) + int type; // mjrLightType; type of light (e.g. spot, point, image, etc.) + const mjrfTexture* texture; // texture; only for image lights + float color[3]; // RGB color + float intensity; // light intensity, in candela + mjtBool cast_shadows; // if true, cast shadows + float range; // effective range of light, in meters + float spot_cone_angle; // spot light cone angle, in degrees + int shadow_map_size; // size of shadow map texture, 0 to use default size + float bulb_radius; // bulb radius, used for soft shadows + float vsm_blur_width; // variance shadow map blur width +}; +typedef struct mjrfLightParams_ mjrfLightParams; + +// Initializes the mjrfLightParams to default values. +void mjrf_defaultLightParams(mjrfLightParams* params); + +// Creates a light for the filament renderer. +mjrfLight* mjrf_createLight(mjrfContext* ctx, const mjrfLightParams* params); + +// Destroys the light. +void mjrf_destroyLight(mjrfLight* light); + +// Enables or disables the light. +void mjrf_setLightEnabled(mjrfLight* light, mjtBool enabled); + +// Sets the intensity of the light, in candela. +void mjrf_setLightIntensity(mjrfLight* light, float intensity); + +// Sets the RGB color of the light. +void mjrf_setLightColor(mjrfLight* light, const float color[3]); + +// Sets the position and direction of the light. +void mjrf_setLightTransform(mjrfLight* light, const float position[3], const float direction[3]); + +// Returns the type of the light (mjrLightType). +int mjrf_getLightType(const mjrfLight* light); + +// ## Renderables (mjrfRenderable) +// +// A renderable is a single drawable object in the scene. It is defined as a combination of a mesh +// (i.e. surface geometry) and a material (i.e. surface appearance and properties). +// +// In terms of materials, there are three lighting models currently supported: +// +// 1. Metallic-roughness (PBR): this is the preferred model for rendering models based standard +// metallic-roughness workflows. +// 2. Specular-glossiness (non-PBR): this is a legacy model designed to be compatible with classic +// mjr renderer, though it is not 100% identical. +// 3. Unlit: this model ignores lighting and used for rendering UX or decorative elements like +// contact forces and labels. +// +// Which lighting model is used is determined by the mjrfMaterial properties. + +struct mjrfMaterial_ { // material properties for a renderable (mjrfMaterial) + float color[4]; // object color; defaults to white + int32_t segmentation_id; // ID for segmentation rendering; maps to RGB8 color (i.e. 24 bits) + int32_t island_id; // ID to which the renderable belongs + int sleep_state; // mjtSleepState; sleep state of the renderable + float uv_scale[3]; // scale applied to UV coordinates; defaults to (1,1,1) + float uv_offset[3]; // offset applied to UV coordinates; defaults to (0,0,0) + float scissor[4]; // if non-zero, applies scissor testing when rendering + float metallic; // metallic factory [0, 1]; disabled if < 0 + float roughness; // roughness factor [0, 1]; disabled if < 0 + float specular; // specular factor [0, 1]; disabled if < 0 + float glossiness; // glossiness factor [0, 1]; disabled if < 0 + float emissive; // emissive/glow factor [0, 1]; disabled if < 0 + float reflectance; // blend factor for reflective surfaces [0, 1]; applies only to planes + mjtBool decor_ux; // for ux elements, does not apply any lighting + mjtBool selected; // for "selected" ux elements, adds additional styling + const mjrfTexture* color_texture; // color/albedo texture (RGB8) + const mjrfTexture* opacity_texture; // opacity texture (A8) + const mjrfTexture* normal_texture; // normal map texture (RGB8) + const mjrfTexture* metallic_texture; // metallic map texture (R8) + const mjrfTexture* roughness_texture; // roughness map texture (R8) + const mjrfTexture* occlusion_texture; // ambient occlusion texture (R8) + const mjrfTexture* orm_texture; // occlusion/roughness/metallic texture (RGB8) + const mjrfTexture* emissive_texture; // emissive texture (RGB8) + const mjrfTexture* reflection_texture; // reflection texture, for internal use only +}; +typedef struct mjrfMaterial_ mjrfMaterial; + +// Initializes the mjrfMaterial to default values. +void mjrf_defaultMaterial(mjrfMaterial* material); + +struct mjrfRenderableParams_ { // parameters for creating a renderable (mjrfRenderable) + mjtBool cast_shadows; // if true, casts shadows + mjtBool receive_shadows; // if true, receives shadows + uint16_t blend_order; // controls draw order for transparent objects [0, 8] +}; +typedef struct mjrfRenderableParams_ mjrfRenderableParams; + +// Initializes the mjrfRenderableParams to default values. +void mjrf_defaultRenderableParams(mjrfRenderableParams* params); + +// Creates a renderable with the given parameters. +mjrfRenderable* mjrf_createRenderable(mjrfContext* ctx, const mjrfRenderableParams* params); + +// Destroys the renderable. +void mjrf_destroyRenderable(mjrfRenderable* renderable); + +// Sets the mesh of the renderable. +void mjrf_setRenderableMesh(mjrfRenderable* renderable, const mjrfMesh* mesh, int elem_offset, + int elem_count); + +// Sets the mesh of the renderable to a built-in mesh based on the geom type. Note: using the same +// parameters (nstack, nslice, nquad) will have better performance as the internal mesh data can be +// shared across renderables. +void mjrf_setRenderableGeomMesh(mjrfRenderable* renderable, int type, int nstack, int nslice, + int nquad); + +// Sets the material properties and textures of the renderable. +void mjrf_setRenderableMaterial(mjrfRenderable* renderable, const mjrfMaterial* material); + +// Copies the material properties of the renderable into the given mjrfMaterial. +void mjrf_getRenderableMaterial(mjrfRenderable* renderable, mjrfMaterial* material); + +// Sets the transform position and rotation of the renderable. +void mjrf_setRenderableTransform(mjrfRenderable* renderable, const float position[3], + const float rotation[9]); + +// Sets the size of the renderable. Note that, for most renderables, this is equivalent to setting +// the scale. However, for some geom-based renderables, the size scale is not applied uniformly +// (e.g. the spherical ends of a capsule are scaled such that they always remain spherical). +void mjrf_setRenderableSize(mjrfRenderable* renderable, const float size[3]); + +// ## Render Targets (mjrfRenderTarget) +// +// A render target is a memory buffer that holds the results of a rendering operation. (This is an +// alternative to rendering directly to the screen.) See mjrf_render for more details. + +struct mjrfRenderTargetConfig_ { // parameters for creating a render target (mjrfRenderTarget) + int width; // texture width + int height; // texture height + int color_format; // mjrPixelFormat; pixel format for color buffer + int depth_format; // mjrPixelFormat; pixel format for depth buffer +}; +typedef struct mjrfRenderTargetConfig_ mjrfRenderTargetConfig; + +// Initializes the RenderTargetConfig to default values. +void mjrf_defaultRenderTargetConfig(mjrfRenderTargetConfig* config); + +// Creates a render target for the filament renderer. +mjrfRenderTarget* mjrf_createRenderTarget(mjrfContext* ctx, const mjrfRenderTargetConfig* config); + +// Destroys the render target. +void mjrf_destroyRenderTarget(mjrfRenderTarget* render_target); + +// Resizes the render target to the given width and height. +void mjrf_resizeRenderTarget(mjrfRenderTarget* render_target, int width, int height); + +// ## Debug-only functions. + +// Draws an ImGui editor for the given scene, exposing filament-specific settings. +void mjrf_DEBUG_drawImguiEditor(mjrfScene* scene); + +#if defined(__cplusplus) +} // extern "C" +#endif + +#endif // MUJOCO_MJRFILAMENT_H_ diff --git a/vendor/include/mujoco/mjsan.h b/vendor/include/mujoco/mjsan.h index 4d45997..880dc88 100644 --- a/vendor/include/mujoco/mjsan.h +++ b/vendor/include/mujoco/mjsan.h @@ -15,6 +15,17 @@ #ifndef MUJOCO_INCLUDE_MJSAN_H_ #define MUJOCO_INCLUDE_MJSAN_H_ +// Define ADDRESS_SANITIZER if implied by other macros. +#if !defined(ADDRESS_SANITIZER) + #if defined(__SANITIZE_ADDRESS__) + #define ADDRESS_SANITIZER + #elif defined(__has_feature) + #if __has_feature(address_sanitizer) + #define ADDRESS_SANITIZER + #endif + #endif +#endif + // Include asan interface header, or provide stubs for poison/unpoison macros when not using asan. #ifdef ADDRESS_SANITIZER #include diff --git a/vendor/include/mujoco/mjspec.h b/vendor/include/mujoco/mjspec.h index 6c1ced2..6d9d623 100644 --- a/vendor/include/mujoco/mjspec.h +++ b/vendor/include/mujoco/mjspec.h @@ -17,7 +17,7 @@ #include #include -#include +#include // this is a C-API @@ -128,6 +128,29 @@ typedef enum mjtOrientation_ { // type of orientation specifier mjORIENTATION_EULER, // Euler angles } mjtOrientation; +typedef enum mjtConflict_ { // conflict resolution for attach + mjCONFLICT_WARNING = 0, // keep parent, warn on conflict + mjCONFLICT_MERGE, // merge: min/max/error per field + mjCONFLICT_ERROR, // error on any conflict +} mjtConflict; + +typedef enum mjtCTimer_ { // compiler timing categories + // top-level timers (wall-clock) + mjCTIMER_TOTAL = 0, // total compile time + mjCTIMER_ASSETS, // asset compilation + + // asset sub-timers (CPU time, summed across all assets) + mjCTIMER_TEXTURE, // textures + mjCTIMER_MESH_LOAD, // mesh: file loading + mjCTIMER_MESH_HULL, // mesh: convex hull + mjCTIMER_MESH_POLYGON, // mesh: normals and polygons + mjCTIMER_MESH_INERTIA, // mesh: volume, CoM, inertia + mjCTIMER_MESH_BVH, // mesh: bounding volume hierarchy + mjCTIMER_MESH_OCTREE, // mesh: octree and SDF + + mjNCTIMER // number of compiler timers +} mjtCTimer; + //-------------------------------- attribute structs (mjs) ----------------------------------------- @@ -153,12 +176,28 @@ typedef struct mjsCompiler_ { // compiler options int inertiagrouprange[2]; // range of geom groups used to compute inertia mjtByte saveinertial; // save explicit inertial clause for all bodies to XML int alignfree; // align free joints with inertial frame + int conflict; // conflict resolution for attach (mjtConflict) mjLROpt LRopt; // options for lengthrange computation mjString* meshdir; // mesh and hfield directory mjString* texturedir; // texture directory + uint64_t authored; // bitmask of authored compiler fields } mjsCompiler; +typedef struct mjsAuthored_ { // authored tracking bitmasks for mjModel structs + uint64_t option; // authored mjOption fields + int disableflags; // individual authored disable flags + int enableflags; // individual authored enable flags + int disableactuator; // individual authored actuator groups + uint64_t visual_global; // authored visual.global fields + uint64_t visual_quality; // authored visual.quality fields + uint64_t visual_headlight; // authored visual.headlight fields + uint64_t visual_map; // authored visual.map fields + uint64_t visual_scale; // authored visual.scale fields + uint64_t visual_rgba; // authored visual.rgba fields +} mjsAuthored; + + typedef struct mjSpec_ { // model specification mjsElement* element; // element type mjString* modelname; // model name @@ -195,6 +234,9 @@ typedef struct mjSpec_ { // model specification // other mjtByte hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator + + // authored tracking bitmasks for mjModel structs + mjsAuthored authored; } mjSpec; @@ -265,7 +307,7 @@ typedef struct mjsJoint_ { // joint specification int align; // align free joint with body com (mjtAlignFree) // stiffness - double stiffness; // stiffness coefficient + double stiffness[mjNPOLY+1]; // stiffness coefficients double springref; // spring reference value: qpos_spring double springdamper[2]; // timeconst, dampratio @@ -280,7 +322,7 @@ typedef struct mjsJoint_ { // joint specification // dof properties double armature; // armature inertia (mass for slider) - double damping; // damping coefficient + double damping[mjNPOLY+1]; // damping coefficients double frictionloss; // friction loss mjtNum solref_friction[mjNREF]; // solver reference: dof friction mjtNum solimp_friction[mjNIMP]; // solver impedance: dof friction @@ -314,7 +356,7 @@ typedef struct mjsGeom_ { // geom specification mjtNum solref[mjNREF]; // solver reference mjtNum solimp[mjNIMP]; // solver impedance double margin; // margin for contact detection - double gap; // include in solver if dist < margin-gap + double gap; // additional contact detection buffer // inertia inference double mass; // used to compute density @@ -373,12 +415,13 @@ typedef struct mjsCamera_ { // camera specification mjString* targetbody; // target body for tracking/targeting // intrinsics - int orthographic; // is camera orthographic + mjtProjection proj; // camera projection type + int resolution[2]; // resolution (pixel) + int output; // bit flags for output type double fovy; // y-field of view - double ipd; // inter-pupilary distance + double ipd; // inter-pupillary distance float intrinsic[4]; // camera intrinsics (length) float sensor_size[2]; // sensor size (length) - float resolution[2]; // resolution (pixel) float focal_length[2]; // focal length (length) float focal_pixel[2]; // focal length (pixel) float principal_length[2]; // principal point (length) @@ -432,18 +475,18 @@ typedef struct mjsFlex_ { // flex specification mjtNum solref[mjNREF]; // solver reference mjtNum solimp[mjNIMP]; // solver impedance double margin; // margin for contact detection - double gap; // include in solver if dist - - -//---------------------------------- floating-point definition ------------------------------------- - -// floating point data type and minval -#ifndef mjUSESINGLE - typedef double mjtNum; - #define mjMINVAL 1E-15 // minimum value in any denominator -#else - typedef float mjtNum; - #define mjMINVAL 1E-15f -#endif - - - -//-------------------------------------- byte definition ------------------------------------------- - -typedef unsigned char mjtByte; // used for true/false - - - -//-------------------------------------- size definition --------------------------------------------- - -typedef int64_t mjtSize; // used for buffer sizes - - - -#endif // MUJOCO_INCLUDE_MJTNUM_H_ diff --git a/vendor/include/mujoco/mjtype.h b/vendor/include/mujoco/mjtype.h new file mode 100644 index 0000000..c6d322a --- /dev/null +++ b/vendor/include/mujoco/mjtype.h @@ -0,0 +1,622 @@ +// 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_INCLUDE_MJTYPE_H_ +#define MUJOCO_INCLUDE_MJTYPE_H_ + +#include +#include + + +//---------------------------------- floating-point definition ------------------------------------- + +// floating point data type and minval +#ifndef mjUSESINGLE + typedef double mjtNum; + #define mjMINVAL 1E-15 // minimum value in any denominator +#else + typedef float mjtNum; + #define mjMINVAL 1E-15f +#endif + + + +//---------------------------------- byte definition ----------------------------------------------- + +typedef unsigned char mjtByte; // used for small integers and binary data + +#ifndef __cplusplus + typedef _Bool mjtBool; // used for boolean values +#else + typedef bool mjtBool; // used for boolean values +#endif + +//---------------------------------- size definition ----------------------------------------------- + +typedef int64_t mjtSize; // used for buffer sizes + + + +//---------------------------------- enum types (mjModel) ------------------------------------------ + +typedef enum mjtDisableBit_ { // disable default feature bitflags + mjDSBL_CONSTRAINT = 1<<0, // entire constraint solver + mjDSBL_EQUALITY = 1<<1, // equality constraints + mjDSBL_FRICTIONLOSS = 1<<2, // joint and tendon frictionloss constraints + mjDSBL_LIMIT = 1<<3, // joint and tendon limit constraints + mjDSBL_CONTACT = 1<<4, // contact constraints + mjDSBL_SPRING = 1<<5, // passive spring forces + mjDSBL_DAMPER = 1<<6, // passive damping forces + mjDSBL_GRAVITY = 1<<7, // gravitational forces + mjDSBL_CLAMPCTRL = 1<<8, // clamp control to specified range + mjDSBL_WARMSTART = 1<<9, // warmstart constraint solver + mjDSBL_FILTERPARENT = 1<<10, // remove collisions with parent body + mjDSBL_ACTUATION = 1<<11, // apply actuation forces + mjDSBL_REFSAFE = 1<<12, // integrator safety: make ref[0]>=2*timestep + mjDSBL_SENSOR = 1<<13, // sensors + mjDSBL_MIDPHASE = 1<<14, // mid-phase collision filtering + mjDSBL_EULERDAMP = 1<<15, // implicit integration of joint damping in Euler integrator + mjDSBL_AUTORESET = 1<<16, // automatic reset when numerical issues are detected + mjDSBL_NATIVECCD = 1<<17, // native convex collision detection + mjDSBL_ISLAND = 1<<18, // constraint island discovery + mjDSBL_MULTICCD = 1<<19, // multiple CCD contact points + + mjNDISABLE = 20 // number of disable flags +} mjtDisableBit; + + +typedef enum mjtEnableBit_ { // enable optional feature bitflags + mjENBL_OVERRIDE = 1<<0, // override contact parameters + mjENBL_ENERGY = 1<<1, // energy computation + mjENBL_FWDINV = 1<<2, // record solver statistics + mjENBL_INVDISCRETE = 1<<3, // discrete-time inverse dynamics + mjENBL_SLEEP = 1<<4, // sleeping + mjENBL_DIAGEXACT = 1<<5, // exact diagonal of constraint inertia + + mjNENABLE = 6 // number of enable flags +} mjtEnableBit; + + +typedef enum mjtJoint_ { // type of degree of freedom + mjJNT_FREE = 0, // global position and orientation (quat) (7) + mjJNT_BALL, // orientation (quat) relative to parent (4) + mjJNT_SLIDE, // sliding distance along body-fixed axis (1) + mjJNT_HINGE // rotation angle (rad) around body-fixed axis (1) +} mjtJoint; + + +typedef enum mjtGeom_ { // type of geometric shape + // regular geom types + mjGEOM_PLANE = 0, // plane + mjGEOM_HFIELD, // height field + mjGEOM_SPHERE, // sphere + mjGEOM_CAPSULE, // capsule + mjGEOM_ELLIPSOID, // ellipsoid + mjGEOM_CYLINDER, // cylinder + mjGEOM_BOX, // box + mjGEOM_MESH, // mesh + mjGEOM_SDF, // signed distance field + + mjNGEOMTYPES, // number of regular geom types + + // rendering-only geom types: not used in mjModel, not counted in mjNGEOMTYPES + mjGEOM_ARROW = 100, // arrow + mjGEOM_ARROW1, // arrow without wedges + mjGEOM_ARROW2, // arrow in both directions + mjGEOM_LINE, // line + mjGEOM_LINEBOX, // box with line edges + mjGEOM_FLEX, // flex + mjGEOM_SKIN, // skin + mjGEOM_LABEL, // text label + mjGEOM_TRIANGLE, // triangle + + mjGEOM_NONE = 1001 // missing geom type +} mjtGeom; + + +typedef enum mjtProjection_ { // type of camera projection + mjPROJ_PERSPECTIVE = 0, // perspective + mjPROJ_ORTHOGRAPHIC // orthographic +} mjtProjection; + + +typedef enum mjtCamLight_ { // tracking mode for camera and light + mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body + mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global + mjCAMLIGHT_TRACKCOM, // pos tracks subtree com, rot fixed in body + mjCAMLIGHT_TARGETBODY, // pos fixed in body, rot tracks target body + mjCAMLIGHT_TARGETBODYCOM // pos fixed in body, rot tracks target subtree com +} mjtCamLight; + + +typedef enum mjtLightType_ { // type of light + mjLIGHT_SPOT = 0, // spot + mjLIGHT_DIRECTIONAL, // directional + mjLIGHT_POINT, // point + mjLIGHT_IMAGE, // image-based +} mjtLightType; + + +typedef enum mjtTexture_ { // type of texture + mjTEXTURE_2D = 0, // 2d texture, suitable for planes and hfields + mjTEXTURE_CUBE, // cube texture, suitable for all other geom types + mjTEXTURE_SKYBOX // cube texture used as skybox +} mjtTexture; + + +typedef enum mjtTextureRole_ { // role of texture map in rendering + mjTEXROLE_USER = 0, // unspecified + mjTEXROLE_RGB, // base color (albedo) + mjTEXROLE_OCCLUSION, // ambient occlusion + mjTEXROLE_ROUGHNESS, // roughness + mjTEXROLE_METALLIC, // metallic + mjTEXROLE_NORMAL, // normal (bump) map + mjTEXROLE_OPACITY, // opacity + mjTEXROLE_EMISSIVE, // light emission + mjTEXROLE_RGBA, // base color, opacity + mjTEXROLE_ORM, // occlusion, roughness, metallic + mjNTEXROLE +} mjtTextureRole; + + +typedef enum mjtColorSpace_ { // type of color space encoding + mjCOLORSPACE_AUTO = 0, // attempts to autodetect color space, defaults to linear + mjCOLORSPACE_LINEAR, // linear color space + mjCOLORSPACE_SRGB // standard RGB color space +} mjtColorSpace; + + +typedef enum mjtIntegrator_ { // integrator mode + mjINT_EULER = 0, // semi-implicit Euler + mjINT_RK4, // 4th-order Runge Kutta + mjINT_IMPLICIT, // implicit in velocity + mjINT_IMPLICITFAST // implicit in velocity, no rne derivative +} mjtIntegrator; + + +typedef enum mjtCone_ { // type of friction cone + mjCONE_PYRAMIDAL = 0, // pyramidal + mjCONE_ELLIPTIC // elliptic +} mjtCone; + + +typedef enum mjtJacobian_ { // type of constraint Jacobian + mjJAC_DENSE = 0, // dense + mjJAC_SPARSE, // sparse + mjJAC_AUTO // dense if nv<60, sparse otherwise +} mjtJacobian; + + +typedef enum mjtSolver_ { // constraint solver algorithm + mjSOL_PGS = 0, // PGS (dual) + mjSOL_CG, // CG (primal) + mjSOL_NEWTON // Newton (primal) +} mjtSolver; + + +typedef enum mjtEq_ { // type of equality constraint + mjEQ_CONNECT = 0, // connect two bodies at a point (ball joint) + mjEQ_WELD, // fix relative position and orientation of two bodies + mjEQ_JOINT, // couple the values of two scalar joints with cubic + mjEQ_TENDON, // couple the lengths of two tendons with cubic + mjEQ_FLEX, // fix all edge lengths of a flex + mjEQ_FLEXVERT, // fix all vertex lengths of a flex + mjEQ_FLEXSTRAIN, // constrain strain of a trilinear/quadratic flex (B-bar) + mjEQ_DISTANCE // unsupported, will cause an error if used +} mjtEq; + + +typedef enum mjtWrap_ { // type of tendon wrap object + mjWRAP_NONE = 0, // null object + mjWRAP_JOINT, // constant moment arm + mjWRAP_PULLEY, // pulley used to split tendon + mjWRAP_SITE, // pass through site + mjWRAP_SPHERE, // wrap around sphere + mjWRAP_CYLINDER // wrap around (infinite) cylinder +} mjtWrap; + + +typedef enum mjtTrn_ { // type of actuator transmission + mjTRN_JOINT = 0, // force on joint + mjTRN_JOINTINPARENT, // force on joint, expressed in parent frame + mjTRN_SLIDERCRANK, // force via slider-crank linkage + mjTRN_TENDON, // force on tendon + mjTRN_SITE, // force on site + mjTRN_BODY, // adhesion force on a body's geoms + + mjTRN_UNDEFINED = 1000 // undefined transmission type +} mjtTrn; + + +typedef enum mjtDyn_ { // type of actuator dynamics + mjDYN_NONE = 0, // no internal dynamics; ctrl specifies force + mjDYN_INTEGRATOR, // integrator: da/dt = u + mjDYN_FILTER, // linear filter: da/dt = (u-a) / tau + mjDYN_FILTEREXACT, // linear filter: da/dt = (u-a) / tau, with exact integration + mjDYN_MUSCLE, // piecewise linear filter with two time constants + mjDYN_DCMOTOR, // DC motor electrical dynamics + mjDYN_USER // user-defined dynamics type +} mjtDyn; + + +typedef enum mjtGain_ { // type of actuator gain + mjGAIN_FIXED = 0, // fixed gain + mjGAIN_AFFINE, // const + kp*length + kv*velocity + mjGAIN_MUSCLE, // muscle FLV curve computed by mju_muscleGain() + mjGAIN_DCMOTOR, // DC motor gain: K or K/R + mjGAIN_USER // user-defined gain type +} mjtGain; + + +typedef enum mjtBias_ { // type of actuator bias + mjBIAS_NONE = 0, // no bias + mjBIAS_AFFINE, // const + kp*length + kv*velocity + mjBIAS_MUSCLE, // muscle passive force computed by mju_muscleBias() + mjBIAS_DCMOTOR, // DC motor bias: back-EMF, cogging, LuGre friction + mjBIAS_USER // user-defined bias type +} mjtBias; + + +typedef enum mjtObj_ { // type of MujoCo object + mjOBJ_UNKNOWN = 0, // unknown object type + mjOBJ_BODY, // body + mjOBJ_XBODY, // body, used to access regular frame instead of i-frame + mjOBJ_JOINT, // joint + mjOBJ_DOF, // dof + mjOBJ_GEOM, // geom + mjOBJ_SITE, // site + mjOBJ_CAMERA, // camera + mjOBJ_LIGHT, // light + mjOBJ_FLEX, // flex + mjOBJ_MESH, // mesh + mjOBJ_SKIN, // skin + mjOBJ_HFIELD, // heightfield + mjOBJ_TEXTURE, // texture + mjOBJ_MATERIAL, // material for rendering + mjOBJ_PAIR, // geom pair to include + mjOBJ_EXCLUDE, // body pair to exclude + mjOBJ_EQUALITY, // equality constraint + mjOBJ_TENDON, // tendon + mjOBJ_ACTUATOR, // actuator + mjOBJ_SENSOR, // sensor + mjOBJ_NUMERIC, // numeric + mjOBJ_TEXT, // text + mjOBJ_TUPLE, // tuple + mjOBJ_KEY, // keyframe + mjOBJ_PLUGIN, // plugin instance + + mjNOBJECT, // number of object types + + // meta elements, do not appear in mjModel + mjOBJ_FRAME = 100, // frame + mjOBJ_DEFAULT, // default + mjOBJ_MODEL // entire model +} mjtObj; + + +typedef enum mjtSensor_ { // type of sensor + // common robotic sensors, attached to a site + mjSENS_TOUCH = 0, // scalar contact normal forces summed over sensor zone + mjSENS_ACCELEROMETER, // 3D linear acceleration, in local frame + mjSENS_VELOCIMETER, // 3D linear velocity, in local frame + mjSENS_GYRO, // 3D angular velocity, in local frame + mjSENS_FORCE, // 3D force between site's body and its parent body + mjSENS_TORQUE, // 3D torque between site's body and its parent body + mjSENS_MAGNETOMETER, // 3D magnetometer + mjSENS_RANGEFINDER, // scalar distance to nearest geom along z-axis + mjSENS_CAMPROJECTION, // pixel coordinates of a site in the camera image + + // sensors related to scalar joints, tendons, actuators + mjSENS_JOINTPOS, // scalar joint position (hinge and slide only) + mjSENS_JOINTVEL, // scalar joint velocity (hinge and slide only) + mjSENS_TENDONPOS, // scalar tendon position + mjSENS_TENDONVEL, // scalar tendon velocity + mjSENS_ACTUATORPOS, // scalar actuator position + mjSENS_ACTUATORVEL, // scalar actuator velocity + mjSENS_ACTUATORFRC, // scalar actuator force + mjSENS_JOINTACTFRC, // scalar actuator force, measured at the joint + mjSENS_TENDONACTFRC, // scalar actuator force, measured at the tendon + + // sensors related to ball joints + mjSENS_BALLQUAT, // 4D ball joint quaternion + mjSENS_BALLANGVEL, // 3D ball joint angular velocity + + // joint and tendon limit sensors, in constraint space + mjSENS_JOINTLIMITPOS, // joint limit distance-margin + mjSENS_JOINTLIMITVEL, // joint limit velocity + mjSENS_JOINTLIMITFRC, // joint limit force + mjSENS_TENDONLIMITPOS, // tendon limit distance-margin + mjSENS_TENDONLIMITVEL, // tendon limit velocity + mjSENS_TENDONLIMITFRC, // tendon limit force + + // sensors attached to an object with spatial frame: (x)body, geom, site, camera + mjSENS_FRAMEPOS, // 3D position + mjSENS_FRAMEQUAT, // 4D unit quaternion orientation + mjSENS_FRAMEXAXIS, // 3D unit vector: x-axis of object's frame + mjSENS_FRAMEYAXIS, // 3D unit vector: y-axis of object's frame + mjSENS_FRAMEZAXIS, // 3D unit vector: z-axis of object's frame + mjSENS_FRAMELINVEL, // 3D linear velocity + mjSENS_FRAMEANGVEL, // 3D angular velocity + mjSENS_FRAMELINACC, // 3D linear acceleration + mjSENS_FRAMEANGACC, // 3D angular acceleration + + // sensors related to kinematic subtrees; attached to a body (which is the subtree root) + mjSENS_SUBTREECOM, // 3D center of mass of subtree + mjSENS_SUBTREELINVEL, // 3D linear velocity of subtree + mjSENS_SUBTREEANGMOM, // 3D angular momentum of subtree + + // sensors of geometric relationships + mjSENS_INSIDESITE, // 1 if object is inside a site, 0 otherwise + mjSENS_GEOMDIST, // signed distance between two geoms + mjSENS_GEOMNORMAL, // normal direction between two geoms + mjSENS_GEOMFROMTO, // segment between two geoms + + // sensors for reporting contacts which occurred during the simulation + mjSENS_CONTACT, // contacts which occurred during the simulation + + // global sensors + mjSENS_E_POTENTIAL, // potential energy + mjSENS_E_KINETIC, // kinetic energy + mjSENS_CLOCK, // simulation time + + // sensors related to SDFs + mjSENS_TACTILE, // tactile sensor + + // plugin-controlled sensors + mjSENS_PLUGIN, // plugin-controlled + + // user-defined sensor + mjSENS_USER // sensor data provided by mjcb_sensor callback +} mjtSensor; + + +typedef enum mjtStage_ { // computation stage + mjSTAGE_NONE = 0, // no computations + mjSTAGE_POS, // position-dependent computations + mjSTAGE_VEL, // velocity-dependent computations + mjSTAGE_ACC // acceleration/force-dependent computations +} mjtStage; + + +typedef enum mjtDataType_ { // data type for sensors + mjDATATYPE_REAL = 0, // real values, no constraints + mjDATATYPE_POSITIVE, // positive values; 0 or negative: inactive + mjDATATYPE_AXIS, // 3D unit vector + mjDATATYPE_QUATERNION // unit quaternion +} mjtDataType; + + +typedef enum mjtConDataField_ { // data fields returned by contact sensors + mjCONDATA_FOUND = 0, // whether a contact was found + mjCONDATA_FORCE, // contact force + mjCONDATA_TORQUE, // contact torque + mjCONDATA_DIST, // contact penetration distance + mjCONDATA_POS, // contact position + mjCONDATA_NORMAL, // contact frame normal + mjCONDATA_TANGENT, // contact frame first tangent + + mjNCONDATA // number of contact sensor data fields +} mjtConDataField; + + +typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors + mjRAYDATA_DIST = 0, // distance from ray origin to nearest surface + mjRAYDATA_DIR, // normalized ray direction + mjRAYDATA_ORIGIN, // ray origin + mjRAYDATA_POINT, // point at which ray intersects nearest surface + mjRAYDATA_NORMAL, // surface normal at intersection point + mjRAYDATA_DEPTH, // depth along z-axis + + mjNRAYDATA // number of rangefinder sensor data fields +} mjtRayDataField; + + +typedef enum mjtCamOutBit_ { // camera output type bitflags + mjCAMOUT_RGB = 1<<0, // RGB image + mjCAMOUT_DEPTH = 1<<1, // depth image (distance from camera plane) + mjCAMOUT_DIST = 1<<2, // distance image (distance from camera origin) + mjCAMOUT_NORMAL = 1<<3, // normal image + mjCAMOUT_SEG = 1<<4, // segmentation image + + mjNCAMOUT = 5 // number of camera output types +} mjtCamOutBit; + + +typedef enum mjtSameFrame_ { // frame alignment of bodies with their children + mjSAMEFRAME_NONE = 0, // no alignment + mjSAMEFRAME_BODY, // frame is same as body frame + mjSAMEFRAME_INERTIA, // frame is same as inertial frame + mjSAMEFRAME_BODYROT, // frame orientation is same as body orientation + mjSAMEFRAME_INERTIAROT // frame orientation is same as inertia orientation +} mjtSameFrame; + + +typedef enum mjtSleepPolicy_ { // per-tree sleep policy + mjSLEEP_AUTO = 0, // compiler chooses sleep policy + mjSLEEP_AUTO_NEVER, // compiler sleep policy: never + mjSLEEP_AUTO_ALLOWED, // compiler sleep policy: allowed + mjSLEEP_NEVER, // user sleep policy: never + mjSLEEP_ALLOWED, // user sleep policy: allowed + mjSLEEP_INIT, // user sleep policy: initialized asleep +} mjtSleepPolicy; + + +typedef enum mjtLRMode_ { // mode for actuator length range computation + mjLRMODE_NONE = 0, // do not process any actuators + mjLRMODE_MUSCLE, // process muscle actuators + mjLRMODE_MUSCLEUSER, // process muscle and user actuators + mjLRMODE_ALL // process all actuators +} mjtLRMode; + + +typedef enum mjtFlexSelf_ { // mode for flex selfcollide + mjFLEXSELF_NONE = 0, // no self-collisions + mjFLEXSELF_NARROW, // skip midphase, go directly to narrowphase + mjFLEXSELF_BVH, // use BVH in midphase (if midphase enabled) + mjFLEXSELF_SAP, // use SAP in midphase + mjFLEXSELF_AUTO // choose between BVH and SAP automatically +} mjtFlexSelf; + + +typedef enum mjtSDFType_ { // signed distance function (SDF) type + mjSDFTYPE_SINGLE = 0, // single SDF + mjSDFTYPE_INTERSECTION, // max(A, B) + mjSDFTYPE_MIDSURFACE, // A - B + mjSDFTYPE_COLLISION, // A + B + abs(max(A, B)) +} mjtSDFType; + + + +//---------------------------------- enum types (mjData) ------------------------------------------- + +typedef enum mjtState_ { // state elements + mjSTATE_TIME = 1<<0, // time + mjSTATE_QPOS = 1<<1, // position + mjSTATE_QVEL = 1<<2, // velocity + mjSTATE_ACT = 1<<3, // actuator activation + mjSTATE_HISTORY = 1<<4, // history buffers (control, sensor) + mjSTATE_WARMSTART = 1<<5, // acceleration used for warmstart + mjSTATE_CTRL = 1<<6, // control + mjSTATE_QFRC_APPLIED = 1<<7, // applied generalized force + mjSTATE_XFRC_APPLIED = 1<<8, // applied Cartesian force/torque + mjSTATE_EQ_ACTIVE = 1<<9, // enable/disable constraints + mjSTATE_MOCAP_POS = 1<<10, // positions of mocap bodies + mjSTATE_MOCAP_QUAT = 1<<11, // orientations of mocap bodies + mjSTATE_USERDATA = 1<<12, // user data + mjSTATE_PLUGIN = 1<<13, // plugin state + + mjNSTATE = 14, // number of state elements + + // convenience values for commonly used state specifications + mjSTATE_PHYSICS = mjSTATE_QPOS | mjSTATE_QVEL | mjSTATE_ACT | mjSTATE_HISTORY, + mjSTATE_FULLPHYSICS = mjSTATE_TIME | mjSTATE_PHYSICS | mjSTATE_PLUGIN, + mjSTATE_USER = mjSTATE_CTRL | mjSTATE_QFRC_APPLIED | mjSTATE_XFRC_APPLIED | + mjSTATE_EQ_ACTIVE | mjSTATE_MOCAP_POS | mjSTATE_MOCAP_QUAT | + mjSTATE_USERDATA, + mjSTATE_INTEGRATION = mjSTATE_FULLPHYSICS | mjSTATE_USER | mjSTATE_WARMSTART +} mjtState; + + +typedef enum mjtConstraint_ { // type of constraint + mjCNSTR_EQUALITY = 0, // equality constraint + mjCNSTR_FRICTION_DOF, // dof friction + mjCNSTR_FRICTION_TENDON, // tendon friction + mjCNSTR_LIMIT_JOINT, // joint limit + mjCNSTR_LIMIT_TENDON, // tendon limit + mjCNSTR_CONTACT_FRICTIONLESS, // frictionless contact + mjCNSTR_CONTACT_PYRAMIDAL, // frictional contact, pyramidal friction cone + mjCNSTR_CONTACT_ELLIPTIC // frictional contact, elliptic friction cone +} mjtConstraint; + + +typedef enum mjtConstraintState_ { // constraint state + mjCNSTRSTATE_SATISFIED = 0, // constraint satisfied, zero cost (limit, contact) + mjCNSTRSTATE_QUADRATIC, // quadratic cost (equality, friction, limit, contact) + mjCNSTRSTATE_LINEARNEG, // linear cost, negative side (friction) + mjCNSTRSTATE_LINEARPOS, // linear cost, positive side (friction) + mjCNSTRSTATE_CONE // squared distance to cone cost (elliptic contact) +} mjtConstraintState; + + +typedef enum mjtWarning_ { // warning types + mjWARN_INERTIA = 0, // (near) singular inertia matrix + mjWARN_CONTACTFULL, // too many contacts in contact list + mjWARN_CNSTRFULL, // too many constraints + 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_ { // internal timers + // 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_CONSTRAINT, // fwdConstraint + mjTIMER_ADVANCE, // mj_Euler, mj_implicit + + // 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 mj_collision + mjTIMER_COL_BROAD, // broadphase + mjTIMER_COL_NARROW, // narrowphase + + mjNTIMER // number of timers +} mjtTimer; + + +typedef enum mjtSleepState_ { // sleep state of an object + mjS_STATIC = -1, // object is static + mjS_ASLEEP = 0, // object is asleep + mjS_AWAKE = 1 // object is awake +} mjtSleepState; + + + +//---------------------------------- logging ------------------------------------------------------- + +typedef enum mjtLogLevel_ { // log message severity + mjLOG_DEBUG = 0, // internal engine debug trace (opt-in via topic filtering) + mjLOG_INFO, // informational (opt-in via topic filtering) + mjLOG_WARNING, // warning + mjLOG_ERROR, // error +} mjtLogLevel; + +typedef enum mjtLogTopic_ { // log topic identifiers + mjTOPIC_NONE = 0, // no topic (always passes filtering) + // INFO topics: + mjTOPIC_TIME_STP = 1, // timing diagnostics (step) + mjTOPIC_TIME_CMP = 2, // timing diagnostics (compile) + // DEBUG topics: + mjTOPIC_SLEEP = 3, // sleep/wake events + + mjNTOPIC = 3 // number of filterable topics +} mjtLogTopic; + +typedef struct mjLogMessage_ { // structured log message + int level; // mjtLogLevel + int topic; // mjtLogTopic (0 for error/warning/user) + char subject[1024]; // message subject (one-liner, printf-formatted) + const char* body; // message body (multi-line detail, or NULL) + const char* func; // __func__ or NULL + const char* file; // __FILE__ or NULL + int line; // __LINE__ or 0 + mjtBool timestamp; // prepend timestamp to output +} mjLogMessage; + +typedef struct mjLogConfig_ { // log handler default configuration + mjtBool logto_console; // print to console (default: true) + mjtBool logto_file; // print to log file (default: true) + char logfile[1024]; // log file path (default: "MUJOCO_LOG.TXT") + int topics; // enabled info topic bitmask (default: 0) +} mjLogConfig; + +// function type for log handler callback; must be thread-safe, must not call mju_error +typedef void (*mjfLogHandler)(const mjLogMessage*); + +#endif // MUJOCO_INCLUDE_MJTYPE_H_ diff --git a/vendor/include/mujoco/mjvisualize.h b/vendor/include/mujoco/mjvisualize.h index 25a2861..2379f82 100644 --- a/vendor/include/mujoco/mjvisualize.h +++ b/vendor/include/mujoco/mjvisualize.h @@ -17,7 +17,7 @@ #include #include -#include +#include #define mjNGROUP 6 // number of geom, site, joint, skin groups with visflags @@ -146,6 +146,7 @@ typedef enum mjtRndFlag_ { // flags enabling rendering effects mjRND_SKYBOX, // skybox mjRND_FOG, // fog mjRND_HAZE, // haze + mjRND_DEPTH, // depth mjRND_SEGMENT, // segmentation with random color mjRND_IDCOLOR, // segmentation with segid+1 color mjRND_CULL_FACE, // cull backward faces @@ -354,7 +355,9 @@ struct mjvScene_ { // abstract scene passed to OpenGL renderer // framing int framewidth; // frame pixel width; 0: disable framing float framergb[3]; // frame color - int status; // status; 0: ok, 1: geoms exhausted + + // geom buffer status + int status; // 0: ok, 1: geoms exhausted, warning issued }; typedef struct mjvScene_ mjvScene; diff --git a/vendor/include/mujoco/mjxmacro.h b/vendor/include/mujoco/mjxmacro.h index 7c73c59..fbd3491 100644 --- a/vendor/include/mujoco/mjxmacro.h +++ b/vendor/include/mujoco/mjxmacro.h @@ -18,140 +18,240 @@ //-------------------------------- mjOption -------------------------------------------------------- -// scalar fields of mjOption -#define MJOPTION_FLOATS \ - X( mjtNum, timestep ) \ - X( mjtNum, apirate ) \ - X( mjtNum, impratio ) \ - X( mjtNum, tolerance ) \ - X( mjtNum, ls_tolerance ) \ - X( mjtNum, noslip_tolerance ) \ - X( mjtNum, ccd_tolerance ) \ - X( mjtNum, density ) \ - X( mjtNum, viscosity ) \ - X( mjtNum, o_margin ) \ - - -#define MJOPTION_INTS \ - X( int, integrator ) \ - X( int, cone ) \ - X( int, jacobian ) \ - X( int, solver ) \ - X( int, iterations ) \ - X( int, ls_iterations ) \ - X( int, noslip_iterations ) \ - X( int, ccd_iterations ) \ - X( int, disableflags ) \ - X( int, enableflags ) \ - X( int, disableactuator ) \ - X( int, sdf_initpoints ) \ - X( int, sdf_iterations ) - - -#define MJOPTION_SCALARS \ - MJOPTION_FLOATS \ - MJOPTION_INTS - - -// vector fields of mjOption -#define MJOPTION_VECTORS \ - X( gravity, 3 ) \ - X( wind, 3 ) \ - X( magnetic, 3 ) \ - X( o_solref, mjNREF ) \ - X( o_solimp, mjNIMP ) \ - X( o_friction, 5 ) +// fields of mjOption +// XVEC means that a field is a vector (i.e. size > 1) +#define MJOPTION_FIELDS \ + X ( mjtNum, timestep, 1 ) \ + X ( mjtNum, impratio, 1 ) \ + X ( mjtNum, tolerance, 1 ) \ + X ( mjtNum, ls_tolerance, 1 ) \ + X ( mjtNum, noslip_tolerance, 1 ) \ + X ( mjtNum, ccd_tolerance, 1 ) \ + X ( mjtNum, sleep_tolerance, 1 ) \ + XVEC( mjtNum, gravity, 3 ) \ + XVEC( mjtNum, wind, 3 ) \ + XVEC( mjtNum, magnetic, 3 ) \ + X ( mjtNum, density, 1 ) \ + X ( mjtNum, viscosity, 1 ) \ + X ( mjtNum, o_margin, 1 ) \ + XVEC( mjtNum, o_solref, mjNREF ) \ + XVEC( mjtNum, o_solimp, mjNIMP ) \ + XVEC( mjtNum, o_friction, 5 ) \ + X ( int, integrator, 1 ) \ + X ( int, cone, 1 ) \ + X ( int, jacobian, 1 ) \ + X ( int, solver, 1 ) \ + X ( int, iterations, 1 ) \ + X ( int, ls_iterations, 1 ) \ + X ( int, noslip_iterations, 1 ) \ + X ( int, ccd_iterations, 1 ) \ + X ( int, disableflags, 1 ) \ + X ( int, enableflags, 1 ) \ + X ( int, disableactuator, 1 ) \ + X ( int, sdf_initpoints, 1 ) \ + X ( int, sdf_iterations, 1 ) + + +//-------------------------------- mjStatistic ----------------------------------------------------- + +// fields of mjStatistic +#define MJSTATISTIC_FIELDS \ + X ( meaninertia, 1 ) \ + X ( meanmass, 1 ) \ + X ( meansize, 1 ) \ + X ( extent, 1 ) \ + XVEC( center, 3 ) + + +//-------------------------------- mjVisual -------------------------------------------------------- + +// fields of mjVisual +#define MJVISUAL_GLOBAL_FIELDS \ + X ( int, cameraid, 1 ) \ + X ( int, orthographic, 1 ) \ + X ( float, fovy, 1 ) \ + X ( float, ipd, 1 ) \ + X ( float, azimuth, 1 ) \ + X ( float, elevation, 1 ) \ + X ( float, linewidth, 1 ) \ + X ( float, glow, 1 ) \ + X ( float, realtime, 1 ) \ + X ( int, offwidth, 1 ) \ + X ( int, offheight, 1 ) \ + X ( int, ellipsoidinertia, 1 ) \ + X ( int, bvactive, 1 ) + +#define MJVISUAL_QUALITY_FIELDS \ + X ( int, shadowsize, 1 ) \ + X ( int, offsamples, 1 ) \ + X ( int, numslices, 1 ) \ + X ( int, numstacks, 1 ) \ + X ( int, numquads, 1 ) + +#define MJVISUAL_HEADLIGHT_FIELDS \ + XVEC( float, ambient, 3 ) \ + XVEC( float, diffuse, 3 ) \ + XVEC( float, specular, 3 ) \ + X ( int, active, 1 ) + +#define MJVISUAL_MAP_FIELDS \ + X ( float, stiffness, 1 ) \ + X ( float, stiffnessrot, 1 ) \ + X ( float, force, 1 ) \ + X ( float, torque, 1 ) \ + X ( float, alpha, 1 ) \ + X ( float, fogstart, 1 ) \ + X ( float, fogend, 1 ) \ + X ( float, znear, 1 ) \ + X ( float, zfar, 1 ) \ + X ( float, haze, 1 ) \ + X ( float, shadowclip, 1 ) \ + X ( float, shadowscale, 1 ) \ + X ( float, actuatortendon, 1 ) + +#define MJVISUAL_SCALE_FIELDS \ + X ( float, forcewidth, 1 ) \ + X ( float, contactwidth, 1 ) \ + X ( float, contactheight, 1 ) \ + X ( float, connect, 1 ) \ + X ( float, com, 1 ) \ + X ( float, camera, 1 ) \ + X ( float, light, 1 ) \ + X ( float, selectpoint, 1 ) \ + X ( float, jointlength, 1 ) \ + X ( float, jointwidth, 1 ) \ + X ( float, actuatorlength, 1 ) \ + X ( float, actuatorwidth, 1 ) \ + X ( float, framelength, 1 ) \ + X ( float, framewidth, 1 ) \ + X ( float, constraint, 1 ) \ + X ( float, slidercrank, 1 ) \ + X ( float, frustum, 1 ) + +#define MJVISUAL_RGBA_FIELDS \ + XVEC( float, fog, 4 ) \ + XVEC( float, haze, 4 ) \ + XVEC( float, force, 4 ) \ + XVEC( float, inertia, 4 ) \ + XVEC( float, joint, 4 ) \ + XVEC( float, actuator, 4 ) \ + XVEC( float, actuatornegative, 4 ) \ + XVEC( float, actuatorpositive, 4 ) \ + XVEC( float, com, 4 ) \ + XVEC( float, camera, 4 ) \ + XVEC( float, light, 4 ) \ + XVEC( float, selectpoint, 4 ) \ + XVEC( float, connect, 4 ) \ + XVEC( float, contactpoint, 4 ) \ + XVEC( float, contactforce, 4 ) \ + XVEC( float, contactfriction, 4 ) \ + XVEC( float, contacttorque, 4 ) \ + XVEC( float, contactgap, 4 ) \ + XVEC( float, rangefinder, 4 ) \ + XVEC( float, constraint, 4 ) \ + XVEC( float, slidercrank, 4 ) \ + XVEC( float, crankbroken, 4 ) \ + XVEC( float, frustum, 4 ) \ + XVEC( float, bv, 4 ) \ + XVEC( float, bvactive, 4 ) //-------------------------------- mjModel --------------------------------------------------------- -// int fields of mjModel -#define MJMODEL_INTS \ - X ( nq ) \ - XMJV( nv ) \ - XMJV( nu ) \ - XMJV( na ) \ - XMJV( nbody ) \ - XMJV( nbvh ) \ - XMJV( nbvhstatic ) \ - X ( nbvhdynamic ) \ - XMJV( njnt ) \ - XMJV( ngeom ) \ - XMJV( nsite ) \ - XMJV( ncam ) \ - XMJV( nlight ) \ - XMJV( nflex ) \ - X ( nflexnode ) \ - XMJV( nflexvert ) \ - X ( nflexedge ) \ - X ( nflexelem ) \ - X ( nflexelemdata ) \ - X ( nflexelemedge ) \ - X ( nflexshelldata ) \ - X ( nflexevpair ) \ - XMJV( nflextexcoord ) \ - XMJV( nmesh ) \ - X ( nmeshvert ) \ - X ( nmeshnormal ) \ - X ( nmeshtexcoord ) \ - X ( nmeshface ) \ - X ( nmeshgraph ) \ - X ( nmeshpoly ) \ - X ( nmeshpolyvert ) \ - X ( nmeshpolymap ) \ - XMJV( nskin ) \ - XMJV( nskinvert ) \ - X ( nskintexvert ) \ - XMJV( nskinface ) \ - XMJV( nskinbone ) \ - XMJV( nskinbonevert ) \ - X ( nhfield ) \ - X ( nhfielddata ) \ - X ( ntex ) \ - X ( ntexdata ) \ - XMJV( nmat ) \ - X ( npair ) \ - X ( nexclude ) \ - XMJV( neq ) \ - XMJV( ntendon ) \ - XMJV( nwrap ) \ - XMJV( nsensor ) \ - X ( nnumeric ) \ - X ( nnumericdata ) \ - X ( ntext ) \ - X ( ntextdata ) \ - X ( ntuple ) \ - X ( ntupledata ) \ - X ( nkey ) \ - X ( nmocap ) \ - X ( nplugin ) \ - X ( npluginattr ) \ - X ( nuser_body ) \ - X ( nuser_jnt ) \ - X ( nuser_geom ) \ - X ( nuser_site ) \ - X ( nuser_cam ) \ - X ( nuser_tendon ) \ - X ( nuser_actuator ) \ - X ( nuser_sensor ) \ - XMJV( nnames ) \ - XMJV( npaths ) \ - X ( nnames_map ) \ - X ( nM ) \ - X ( nB ) \ - X ( nC ) \ - X ( nD ) \ - X ( nJmom ) \ - XMJV( ntree ) \ - X ( ngravcomp ) \ - X ( nemax ) \ - X ( njmax ) \ - X ( nconmax ) \ - X ( nuserdata ) \ - XMJV( nsensordata ) \ - X ( npluginstate ) \ - X ( narena ) \ - X ( nbuffer ) +// size fields of mjModel +#define MJMODEL_SIZES \ + X( nq ) \ + X( nv ) \ + X( nu ) \ + X( na ) \ + X( nbody ) \ + X( nbvh ) \ + X( nbvhstatic ) \ + X( nbvhdynamic ) \ + X( noct ) \ + X( njnt ) \ + X( ntree ) \ + X( nM ) \ + X( nB ) \ + X( nC ) \ + X( nD ) \ + X( ngeom ) \ + X( nsite ) \ + X( ncam ) \ + X( nlight ) \ + X( nflex ) \ + X( nflexnode ) \ + X( nflexvert ) \ + X( nflexedge ) \ + X( nflexelem ) \ + X( nflexelemdata ) \ + X( nflexstiffness ) \ + X( nflexbending ) \ + X( nflexelemedge ) \ + X( nflexshelldata ) \ + X( nflexevpair ) \ + X( nflextexcoord ) \ + X( nJfe ) \ + X( nJfv ) \ + X( nmesh ) \ + X( nmeshvert ) \ + X( nmeshnormal ) \ + X( nmeshtexcoord ) \ + X( nmeshface ) \ + X( nmeshgraph ) \ + X( nmeshpoly ) \ + X( nmeshpolyvert ) \ + X( nmeshpolymap ) \ + X( nskin ) \ + X( nskinvert ) \ + X( nskintexvert ) \ + X( nskinface ) \ + X( nskinbone ) \ + X( nskinbonevert ) \ + X( nhfield ) \ + X( nhfielddata ) \ + X( ntex ) \ + X( ntexdata ) \ + X( nmat ) \ + X( npair ) \ + X( nexclude ) \ + X( neq ) \ + X( ntendon ) \ + X( nJten ) \ + X( nwrap ) \ + X( nsensor ) \ + X( nnumeric ) \ + X( nnumericdata ) \ + X( ntext ) \ + X( ntextdata ) \ + X( ntuple ) \ + X( ntupledata ) \ + X( nkey ) \ + X( nmocap ) \ + X( nplugin ) \ + X( npluginattr ) \ + X( nuser_body ) \ + X( nuser_jnt ) \ + X( nuser_geom ) \ + X( nuser_site ) \ + X( nuser_cam ) \ + X( nuser_tendon ) \ + X( nuser_actuator ) \ + X( nuser_sensor ) \ + X( nnames ) \ + X( npaths ) \ + X( nnames_map ) \ + X( nJmom ) \ + X( ngravcomp ) \ + X( nemax ) \ + X( njmax ) \ + X( nconmax ) \ + X( nuserdata ) \ + X( nsensordata ) \ + X( npluginstate ) \ + X( nhistory ) \ + X( narena ) \ + X( nbuffer ) /* nbuffer needs to be the final field */ @@ -178,31 +278,29 @@ // pointer fields of mjModel -// XMJV means that the field is required to construct mjvScene -// (by default we define XMJV to be the same as X) -#define MJMODEL_POINTERS \ - X ( mjtNum, qpos0, nq, 1 ) \ - X ( mjtNum, qpos_spring, nq, 1 ) \ - XMJV( int, body_parentid, nbody, 1 ) \ - XMJV( int, body_rootid, nbody, 1 ) \ - XMJV( int, body_weldid, nbody, 1 ) \ - XMJV( int, body_mocapid, nbody, 1 ) \ - XMJV( int, body_jntnum, nbody, 1 ) \ - XMJV( int, body_jntadr, nbody, 1 ) \ - XMJV( int, body_dofnum, nbody, 1 ) \ - XMJV( int, body_dofadr, nbody, 1 ) \ +// XNV means that the field is not required to construct mjvScene +// (by default we define XNV to be the same as X) +#define MJMODEL_POINTERS_BODY \ + X ( int, body_parentid, nbody, 1 ) \ + X ( int, body_rootid, nbody, 1 ) \ + X ( int, body_weldid, nbody, 1 ) \ + X ( int, body_mocapid, nbody, 1 ) \ + X ( int, body_jntnum, nbody, 1 ) \ + X ( int, body_jntadr, nbody, 1 ) \ + X ( int, body_dofnum, nbody, 1 ) \ + X ( int, body_dofadr, nbody, 1 ) \ X ( int, body_treeid, nbody, 1 ) \ - XMJV( int, body_geomnum, nbody, 1 ) \ - XMJV( int, body_geomadr, nbody, 1 ) \ + X ( int, body_geomnum, nbody, 1 ) \ + X ( int, body_geomadr, nbody, 1 ) \ X ( mjtByte, body_simple, nbody, 1 ) \ X ( mjtByte, body_sameframe, nbody, 1 ) \ X ( mjtNum, body_pos, nbody, 3 ) \ X ( mjtNum, body_quat, nbody, 4 ) \ X ( mjtNum, body_ipos, nbody, 3 ) \ - XMJV( mjtNum, body_iquat, nbody, 4 ) \ - XMJV( mjtNum, body_mass, nbody, 1 ) \ + X ( mjtNum, body_iquat, nbody, 4 ) \ + X ( mjtNum, body_mass, nbody, 1 ) \ X ( mjtNum, body_subtreemass, nbody, 1 ) \ - XMJV( mjtNum, body_inertia, nbody, 3 ) \ + X ( mjtNum, body_inertia, nbody, 3 ) \ X ( mjtNum, body_invweight0, nbody, 2 ) \ X ( mjtNum, body_gravcomp, nbody, 1 ) \ X ( mjtNum, body_margin, nbody, 1 ) \ @@ -210,29 +308,31 @@ X ( int, body_plugin, nbody, 1 ) \ X ( int, body_contype, nbody, 1 ) \ X ( int, body_conaffinity, nbody, 1 ) \ - XMJV( int, body_bvhadr, nbody, 1 ) \ - XMJV( int, body_bvhnum, nbody, 1 ) \ - XMJV( int, bvh_depth, nbvh, 1 ) \ - XMJV( int, bvh_child, nbvh, 2 ) \ - XMJV( int, bvh_nodeid, nbvh, 1 ) \ - XMJV( mjtNum, bvh_aabb, nbvhstatic, 6 ) \ - XMJV( int, jnt_type, njnt, 1 ) \ + X ( int, body_bvhadr, nbody, 1 ) \ + X ( int, body_bvhnum, nbody, 1 ) + +#define MJMODEL_POINTERS_JOINT \ + X ( int, jnt_type, njnt, 1 ) \ X ( int, jnt_qposadr, njnt, 1 ) \ X ( int, jnt_dofadr, njnt, 1 ) \ - XMJV( int, jnt_bodyid, njnt, 1 ) \ - XMJV( int, jnt_group, njnt, 1 ) \ - X ( mjtByte, jnt_limited, njnt, 1 ) \ - X ( mjtByte, jnt_actfrclimited, njnt, 1 ) \ - X ( mjtByte, jnt_actgravcomp, njnt, 1 ) \ + X ( int, jnt_bodyid, njnt, 1 ) \ + X ( int, jnt_actuatorid, njnt, 1 ) \ + X ( int, jnt_group, njnt, 1 ) \ + X ( mjtBool, jnt_limited, njnt, 1 ) \ + X ( mjtBool, jnt_actfrclimited, njnt, 1 ) \ + X ( mjtBool, jnt_actgravcomp, njnt, 1 ) \ X ( mjtNum, jnt_solref, njnt, mjNREF ) \ X ( mjtNum, jnt_solimp, njnt, mjNIMP ) \ X ( mjtNum, jnt_pos, njnt, 3 ) \ X ( mjtNum, jnt_axis, njnt, 3 ) \ X ( mjtNum, jnt_stiffness, njnt, 1 ) \ + X ( mjtNum, jnt_stiffnesspoly, njnt, mjNPOLY ) \ X ( mjtNum, jnt_range, njnt, 2 ) \ X ( mjtNum, jnt_actfrcrange, njnt, 2 ) \ X ( mjtNum, jnt_margin, njnt, 1 ) \ - X ( mjtNum, jnt_user, njnt, MJ_M(nuser_jnt) ) \ + X ( mjtNum, jnt_user, njnt, MJ_M(nuser_jnt) ) + +#define MJMODEL_POINTERS_DOF \ X ( int, dof_bodyid, nv, 1 ) \ X ( int, dof_jntid, nv, 1 ) \ X ( int, dof_parentid, nv, 1 ) \ @@ -244,43 +344,58 @@ X ( mjtNum, dof_frictionloss, nv, 1 ) \ X ( mjtNum, dof_armature, nv, 1 ) \ X ( mjtNum, dof_damping, nv, 1 ) \ + X ( mjtNum, dof_dampingpoly, nv, mjNPOLY ) \ X ( mjtNum, dof_invweight0, nv, 1 ) \ X ( mjtNum, dof_M0, nv, 1 ) \ - XMJV( int, geom_type, ngeom, 1 ) \ - XMJV( int, geom_contype, ngeom, 1 ) \ - XMJV( int, geom_conaffinity, ngeom, 1 ) \ + X ( mjtNum, dof_length, nv, 1 ) + +#define MJMODEL_POINTERS_TREE \ + X ( int, tree_bodyadr, ntree, 1 ) \ + X ( int, tree_bodynum, ntree, 1 ) \ + X ( int, tree_dofadr, ntree, 1 ) \ + X ( int, tree_dofnum, ntree, 1 ) \ + X ( int, tree_sleep_policy, ntree, 1 ) + +#define MJMODEL_POINTERS_GEOM \ + X ( int, geom_type, ngeom, 1 ) \ + X ( int, geom_contype, ngeom, 1 ) \ + X ( int, geom_conaffinity, ngeom, 1 ) \ X ( int, geom_condim, ngeom, 1 ) \ - XMJV( int, geom_bodyid, ngeom, 1 ) \ - XMJV( int, geom_dataid, ngeom, 1 ) \ - XMJV( int, geom_matid, ngeom, 1 ) \ - XMJV( int, geom_group, ngeom, 1 ) \ + X ( int, geom_bodyid, ngeom, 1 ) \ + X ( int, geom_dataid, ngeom, 1 ) \ + X ( int, geom_matid, ngeom, 1 ) \ + X ( int, geom_group, ngeom, 1 ) \ X ( int, geom_priority, ngeom, 1 ) \ X ( int, geom_plugin, ngeom, 1 ) \ X ( mjtByte, geom_sameframe, ngeom, 1 ) \ X ( mjtNum, geom_solmix, ngeom, 1 ) \ X ( mjtNum, geom_solref, ngeom, mjNREF ) \ X ( mjtNum, geom_solimp, ngeom, mjNIMP ) \ - XMJV( mjtNum, geom_size, ngeom, 3 ) \ - XMJV( mjtNum, geom_aabb, ngeom, 6 ) \ - XMJV( mjtNum, geom_rbound, ngeom, 1 ) \ + X ( mjtNum, geom_size, ngeom, 3 ) \ + X ( mjtNum, geom_aabb, ngeom, 6 ) \ + X ( mjtNum, geom_rbound, ngeom, 1 ) \ X ( mjtNum, geom_pos, ngeom, 3 ) \ X ( mjtNum, geom_quat, ngeom, 4 ) \ X ( mjtNum, geom_friction, ngeom, 3 ) \ X ( mjtNum, geom_margin, ngeom, 1 ) \ X ( mjtNum, geom_gap, ngeom, 1 ) \ - X ( mjtNum, geom_fluid, ngeom, mjNFLUID ) \ + XNV ( mjtNum, geom_fluid, ngeom, mjNFLUID ) \ X ( mjtNum, geom_user, ngeom, MJ_M(nuser_geom) ) \ - XMJV( float, geom_rgba, ngeom, 4 ) \ - XMJV( int, site_type, nsite, 1 ) \ - XMJV( int, site_bodyid, nsite, 1 ) \ - XMJV( int, site_matid, nsite, 1 ) \ - XMJV( int, site_group, nsite, 1 ) \ + X ( float, geom_rgba, ngeom, 4 ) + +#define MJMODEL_POINTERS_SITE \ + X ( int, site_type, nsite, 1 ) \ + X ( int, site_bodyid, nsite, 1 ) \ + X ( int, site_matid, nsite, 1 ) \ + X ( int, site_group, nsite, 1 ) \ X ( mjtByte, site_sameframe, nsite, 1 ) \ - XMJV( mjtNum, site_size, nsite, 3 ) \ + X ( mjtNum, site_size, nsite, 3 ) \ X ( mjtNum, site_pos, nsite, 3 ) \ X ( mjtNum, site_quat, nsite, 4 ) \ X ( mjtNum, site_user, nsite, MJ_M(nuser_site) ) \ - XMJV( float, site_rgba, nsite, 4 ) \ + X ( float, site_rgba, nsite, 4 ) + +#define MJMODEL_POINTERS_CAMERA \ X ( int, cam_mode, ncam, 1 ) \ X ( int, cam_bodyid, ncam, 1 ) \ X ( int, cam_targetbodyid, ncam, 1 ) \ @@ -289,31 +404,39 @@ X ( mjtNum, cam_poscom0, ncam, 3 ) \ X ( mjtNum, cam_pos0, ncam, 3 ) \ X ( mjtNum, cam_mat0, ncam, 9 ) \ - XMJV( int, cam_orthographic, ncam, 1 ) \ - XMJV( mjtNum, cam_fovy, ncam, 1 ) \ - XMJV( mjtNum, cam_ipd, ncam, 1 ) \ - XMJV( int, cam_resolution, ncam, 2 ) \ - XMJV( float, cam_sensorsize, ncam, 2 ) \ - XMJV( float, cam_intrinsic, ncam, 4 ) \ - X ( mjtNum, cam_user, ncam, MJ_M(nuser_cam) ) \ + X ( int, cam_projection, ncam, 1 ) \ + X ( mjtNum, cam_fovy, ncam, 1 ) \ + X ( mjtNum, cam_ipd, ncam, 1 ) \ + X ( int, cam_resolution, ncam, 2 ) \ + X ( int, cam_output, ncam, 1 ) \ + X ( float, cam_sensorsize, ncam, 2 ) \ + X ( float, cam_intrinsic, ncam, 4 ) \ + X ( mjtNum, cam_user, ncam, MJ_M(nuser_cam) ) + +#define MJMODEL_POINTERS_LIGHT \ X ( int, light_mode, nlight, 1 ) \ X ( int, light_bodyid, nlight, 1 ) \ X ( int, light_targetbodyid, nlight, 1 ) \ - XMJV( mjtByte, light_directional, nlight, 1 ) \ - XMJV( mjtByte, light_castshadow, nlight, 1 ) \ - XMJV( float, light_bulbradius, nlight, 1 ) \ - XMJV( mjtByte, light_active, nlight, 1 ) \ + X ( int, light_type, nlight, 1 ) \ + X ( int, light_texid, nlight, 1 ) \ + X ( mjtBool, light_castshadow, nlight, 1 ) \ + X ( float, light_bulbradius, nlight, 1 ) \ + X ( float, light_intensity, nlight, 1 ) \ + X ( float, light_range, nlight, 1 ) \ + X ( mjtBool, light_active, nlight, 1 ) \ X ( mjtNum, light_pos, nlight, 3 ) \ X ( mjtNum, light_dir, nlight, 3 ) \ X ( mjtNum, light_poscom0, nlight, 3 ) \ X ( mjtNum, light_pos0, nlight, 3 ) \ X ( mjtNum, light_dir0, nlight, 3 ) \ - XMJV( float, light_attenuation, nlight, 3 ) \ - XMJV( float, light_cutoff, nlight, 1 ) \ - XMJV( float, light_exponent, nlight, 1 ) \ - XMJV( float, light_ambient, nlight, 3 ) \ - XMJV( float, light_diffuse, nlight, 3 ) \ - XMJV( float, light_specular, nlight, 3 ) \ + X ( float, light_attenuation, nlight, 3 ) \ + X ( float, light_cutoff, nlight, 1 ) \ + X ( float, light_exponent, nlight, 1 ) \ + X ( float, light_ambient, nlight, 3 ) \ + X ( float, light_diffuse, nlight, 3 ) \ + X ( float, light_specular, nlight, 3 ) + +#define MJMODEL_POINTERS_FLEX \ X ( int, flex_contype, nflex, 1 ) \ X ( int, flex_conaffinity, nflex, 1 ) \ X ( int, flex_condim, nflex, 1 ) \ @@ -324,71 +447,89 @@ X ( mjtNum, flex_friction, nflex, 3 ) \ X ( mjtNum, flex_margin, nflex, 1 ) \ X ( mjtNum, flex_gap, nflex, 1 ) \ - X ( mjtByte, flex_internal, nflex, 1 ) \ + X ( mjtBool, flex_internal, nflex, 1 ) \ X ( int, flex_selfcollide, nflex, 1 ) \ X ( int, flex_activelayers, nflex, 1 ) \ - XMJV( int, flex_dim, nflex, 1 ) \ - XMJV( int, flex_matid, nflex, 1 ) \ - XMJV( int, flex_group, nflex, 1 ) \ - XMJV( int, flex_interp, nflex, 1 ) \ - XMJV( int, flex_nodeadr, nflex, 1 ) \ - XMJV( int, flex_nodenum, nflex, 1 ) \ - XMJV( int, flex_vertadr, nflex, 1 ) \ - XMJV( int, flex_vertnum, nflex, 1 ) \ + X ( int, flex_passive, nflex, 1 ) \ + X ( int, flex_dim, nflex, 1 ) \ + X ( int, flex_matid, nflex, 1 ) \ + X ( int, flex_group, nflex, 1 ) \ + X ( int, flex_interp, nflex, 1 ) \ + X ( int, flex_cellnum, nflex, 3 ) \ + X ( int, flex_nodeadr, nflex, 1 ) \ + X ( int, flex_nodenum, nflex, 1 ) \ + X ( int, flex_vertadr, nflex, 1 ) \ + X ( int, flex_vertnum, nflex, 1 ) \ X ( int, flex_edgeadr, nflex, 1 ) \ X ( int, flex_edgenum, nflex, 1 ) \ - XMJV( int, flex_elemadr, nflex, 1 ) \ - XMJV( int, flex_elemnum, nflex, 1 ) \ - XMJV( int, flex_elemdataadr, nflex, 1 ) \ + X ( int, flex_elemadr, nflex, 1 ) \ + X ( int, flex_elemnum, nflex, 1 ) \ + X ( int, flex_elemdataadr, nflex, 1 ) \ + X ( int, flex_stiffnessadr, nflex, 1 ) \ X ( int, flex_elemedgeadr, nflex, 1 ) \ - XMJV( int, flex_shellnum, nflex, 1 ) \ - XMJV( int, flex_shelldataadr, nflex, 1 ) \ + X ( int, flex_bendingadr, nflex, 1 ) \ + X ( int, flex_shellnum, nflex, 1 ) \ + X ( int, flex_shelldataadr, nflex, 1 ) \ X ( int, flex_evpairadr, nflex, 1 ) \ X ( int, flex_evpairnum, nflex, 1 ) \ - XMJV( int, flex_texcoordadr, nflex, 1 ) \ - XMJV( int, flex_nodebodyid, nflexnode, 1 ) \ + X ( int, flex_texcoordadr, nflex, 1 ) \ + X ( int, flex_nodebodyid, nflexnode, 1 ) \ X ( int, flex_vertbodyid, nflexvert, 1 ) \ + X ( int, flex_vertedgeadr, nflexvert, 1 ) \ + X ( int, flex_vertedgenum, nflexvert, 1 ) \ + X ( int, flex_vertedge, nflexedge, 2 ) \ X ( int, flex_edge, nflexedge, 2 ) \ - XMJV( int, flex_elem, nflexelemdata, 1 ) \ - XMJV( int, flex_elemtexcoord, nflexelemdata, 1 ) \ + X ( int, flex_edgeflap, nflexedge, 2 ) \ + X ( int, flex_elem, nflexelemdata, 1 ) \ + X ( int, flex_elemtexcoord, nflexelemdata, 1 ) \ X ( int, flex_elemedge, nflexelemedge, 1 ) \ - XMJV( int, flex_elemlayer, nflexelem, 1 ) \ - XMJV( int, flex_shell, nflexshelldata,1 ) \ + X ( int, flex_elemlayer, nflexelem, 1 ) \ + X ( int, flex_shell, nflexshelldata,1 ) \ X ( int, flex_evpair, nflexevpair, 2 ) \ X ( mjtNum, flex_vert, nflexvert, 3 ) \ X ( mjtNum, flex_vert0, nflexvert, 3 ) \ - XMJV( mjtNum, flex_node, nflexnode, 3 ) \ + X ( mjtNum, flex_vertmetric, nflexvert, 4 ) \ + X ( mjtNum, flex_node, nflexnode, 3 ) \ X ( mjtNum, flex_node0, nflexnode, 3 ) \ X ( mjtNum, flexedge_length0, nflexedge, 1 ) \ X ( mjtNum, flexedge_invweight0, nflexedge, 1 ) \ - XMJV( mjtNum, flex_radius, nflex, 1 ) \ - X ( mjtNum, flex_stiffness, nflexelem, 21 ) \ + X ( mjtNum, flex_radius, nflex, 1 ) \ + X ( mjtNum, flex_size, nflex, 3 ) \ + X ( mjtNum, flex_stiffness, nflexstiffness, 1 ) \ + X ( mjtNum, flex_bending, nflexbending, 1 ) \ X ( mjtNum, flex_damping, nflex, 1 ) \ X ( mjtNum, flex_edgestiffness, nflex, 1 ) \ X ( mjtNum, flex_edgedamping, nflex, 1 ) \ - X ( mjtByte, flex_edgeequality, nflex, 1 ) \ - X ( mjtByte, flex_rigid, nflex, 1 ) \ - X ( mjtByte, flexedge_rigid, nflexedge, 1 ) \ - XMJV( mjtByte, flex_centered, nflex, 1 ) \ - XMJV( mjtByte, flex_flatskin, nflex, 1 ) \ - XMJV( int, flex_bvhadr, nflex, 1 ) \ - XMJV( int, flex_bvhnum, nflex, 1 ) \ - XMJV( float, flex_rgba, nflex, 4 ) \ - XMJV( float, flex_texcoord, nflextexcoord, 2 ) \ + X ( int, flex_edgeequality, nflex, 1 ) \ + X ( mjtBool, flex_rigid, nflex, 1 ) \ + X ( mjtBool, flexedge_rigid, nflexedge, 1 ) \ + X ( mjtBool, flex_centered, nflex, 1 ) \ + X ( mjtBool, flex_flatskin, nflex, 1 ) \ + X ( int, flex_bvhadr, nflex, 1 ) \ + X ( int, flex_bvhnum, nflex, 1 ) \ + X ( int, flexedge_J_rownnz, nflexedge, 1 ) \ + X ( int, flexedge_J_rowadr, nflexedge, 1 ) \ + X ( int, flexedge_J_colind, nJfe, 1 ) \ + X ( int, flexvert_J_rownnz, nflexvert, 2 ) \ + X ( int, flexvert_J_rowadr, nflexvert, 2 ) \ + X ( int, flexvert_J_colind, nJfv, 2 ) \ + X ( float, flex_rgba, nflex, 4 ) \ + X ( float, flex_texcoord, nflextexcoord, 2 ) + +#define MJMODEL_POINTERS_MESH \ X ( int, mesh_vertadr, nmesh, 1 ) \ X ( int, mesh_vertnum, nmesh, 1 ) \ + X ( int, mesh_faceadr, nmesh, 1 ) \ + X ( int, mesh_facenum, nmesh, 1 ) \ + X ( int, mesh_bvhadr, nmesh, 1 ) \ + X ( int, mesh_bvhnum, nmesh, 1 ) \ + X ( int, mesh_octadr, nmesh, 1 ) \ + X ( int, mesh_octnum, nmesh, 1 ) \ X ( int, mesh_normaladr, nmesh, 1 ) \ X ( int, mesh_normalnum, nmesh, 1 ) \ - XMJV( int, mesh_texcoordadr, nmesh, 1 ) \ + X ( int, mesh_texcoordadr, nmesh, 1 ) \ X ( int, mesh_texcoordnum, nmesh, 1 ) \ - X ( int, mesh_faceadr, nmesh, 1 ) \ - X ( int, mesh_facenum, nmesh, 1 ) \ - XMJV( int, mesh_bvhadr, nmesh, 1 ) \ - XMJV( int, mesh_bvhnum, nmesh, 1 ) \ - XMJV( int, mesh_graphadr, nmesh, 1 ) \ - X ( mjtNum, mesh_scale, nmesh, 3 ) \ - X ( mjtNum, mesh_pos, nmesh, 3 ) \ - X ( mjtNum, mesh_quat, nmesh, 4 ) \ + X ( int, mesh_graphadr, nmesh, 1 ) \ XNV ( float, mesh_vert, nmeshvert, 3 ) \ XNV ( float, mesh_normal, nmeshnormal, 3 ) \ XNV ( float, mesh_texcoord, nmeshtexcoord, 2 ) \ @@ -396,61 +537,75 @@ XNV ( int, mesh_facenormal, nmeshface, 3 ) \ XNV ( int, mesh_facetexcoord, nmeshface, 3 ) \ XNV ( int, mesh_graph, nmeshgraph, 1 ) \ - XMJV( int, mesh_pathadr, nmesh, 1 ) \ - X ( int, mesh_polynum, nmesh, 1 ) \ - X ( int, mesh_polyadr, nmesh, 1 ) \ - X ( mjtNum, mesh_polynormal, nmeshpoly, 3 ) \ - X ( int, mesh_polyvertadr, nmeshpoly, 1 ) \ - X ( int, mesh_polyvertnum, nmeshpoly, 1 ) \ - X ( int, mesh_polyvert, nmeshpolyvert, 1 ) \ - X ( int, mesh_polymapadr, nmeshvert, 1 ) \ - X ( int, mesh_polymapnum, nmeshvert, 1 ) \ - X ( int, mesh_polymap, nmeshpolymap, 1 ) \ - XMJV( int, skin_matid, nskin, 1 ) \ - XMJV( int, skin_group, nskin, 1 ) \ - XMJV( float, skin_rgba, nskin, 4 ) \ - XMJV( float, skin_inflate, nskin, 1 ) \ - XMJV( int, skin_vertadr, nskin, 1 ) \ - XMJV( int, skin_vertnum, nskin, 1 ) \ - XMJV( int, skin_texcoordadr, nskin, 1 ) \ - XMJV( int, skin_faceadr, nskin, 1 ) \ - XMJV( int, skin_facenum, nskin, 1 ) \ - XMJV( int, skin_boneadr, nskin, 1 ) \ - XMJV( int, skin_bonenum, nskin, 1 ) \ - XMJV( float, skin_vert, nskinvert, 3 ) \ + X ( mjtNum, mesh_scale, nmesh, 3 ) \ + X ( mjtNum, mesh_pos, nmesh, 3 ) \ + X ( mjtNum, mesh_quat, nmesh, 4 ) \ + X ( int, mesh_pathadr, nmesh, 1 ) \ + XNV ( int, mesh_polynum, nmesh, 1 ) \ + XNV ( int, mesh_polyadr, nmesh, 1 ) \ + XNV ( mjtNum, mesh_polynormal, nmeshpoly, 3 ) \ + XNV ( int, mesh_polyvertadr, nmeshpoly, 1 ) \ + XNV ( int, mesh_polyvertnum, nmeshpoly, 1 ) \ + XNV ( int, mesh_polyvert, nmeshpolyvert, 1 ) \ + XNV ( int, mesh_polymapadr, nmeshvert, 1 ) \ + XNV ( int, mesh_polymapnum, nmeshvert, 1 ) \ + XNV ( int, mesh_polymap, nmeshpolymap, 1 ) + +#define MJMODEL_POINTERS_SKIN \ + X ( int, skin_matid, nskin, 1 ) \ + X ( int, skin_group, nskin, 1 ) \ + X ( float, skin_rgba, nskin, 4 ) \ + X ( float, skin_inflate, nskin, 1 ) \ + X ( int, skin_vertadr, nskin, 1 ) \ + X ( int, skin_vertnum, nskin, 1 ) \ + X ( int, skin_texcoordadr, nskin, 1 ) \ + X ( int, skin_faceadr, nskin, 1 ) \ + X ( int, skin_facenum, nskin, 1 ) \ + X ( int, skin_boneadr, nskin, 1 ) \ + X ( int, skin_bonenum, nskin, 1 ) \ + X ( float, skin_vert, nskinvert, 3 ) \ X ( float, skin_texcoord, nskintexvert, 2 ) \ - XMJV( int, skin_face, nskinface, 3 ) \ - XMJV( int, skin_bonevertadr, nskinbone, 1 ) \ - XMJV( int, skin_bonevertnum, nskinbone, 1 ) \ - XMJV( float, skin_bonebindpos, nskinbone, 3 ) \ - XMJV( float, skin_bonebindquat, nskinbone, 4 ) \ - XMJV( int, skin_bonebodyid, nskinbone, 1 ) \ - XMJV( int, skin_bonevertid, nskinbonevert, 1 ) \ - XMJV( float, skin_bonevertweight, nskinbonevert, 1 ) \ - XMJV( int, skin_pathadr, nskin, 1 ) \ + X ( int, skin_face, nskinface, 3 ) \ + X ( int, skin_bonevertadr, nskinbone, 1 ) \ + X ( int, skin_bonevertnum, nskinbone, 1 ) \ + X ( float, skin_bonebindpos, nskinbone, 3 ) \ + X ( float, skin_bonebindquat, nskinbone, 4 ) \ + X ( int, skin_bonebodyid, nskinbone, 1 ) \ + X ( int, skin_bonevertid, nskinbonevert, 1 ) \ + X ( float, skin_bonevertweight, nskinbonevert, 1 ) \ + X ( int, skin_pathadr, nskin, 1 ) + +#define MJMODEL_POINTERS_HFIELD \ X ( mjtNum, hfield_size, nhfield, 4 ) \ X ( int, hfield_nrow, nhfield, 1 ) \ X ( int, hfield_ncol, nhfield, 1 ) \ X ( int, hfield_adr, nhfield, 1 ) \ XNV ( float, hfield_data, nhfielddata, 1 ) \ - XMJV( int, hfield_pathadr, nhfield, 1 ) \ + X ( int, hfield_pathadr, nhfield, 1 ) + +#define MJMODEL_POINTERS_TEXTURE \ X ( int, tex_type, ntex, 1 ) \ + X ( int, tex_colorspace, ntex, 1 ) \ X ( int, tex_height, ntex, 1 ) \ X ( int, tex_width, ntex, 1 ) \ X ( int, tex_nchannel, ntex, 1 ) \ - X ( int, tex_adr, ntex, 1 ) \ + X ( mjtSize, tex_adr, ntex, 1 ) \ XNV ( mjtByte, tex_data, ntexdata, 1 ) \ - XMJV( int, tex_pathadr, ntex, 1 ) \ - XMJV( int, mat_texid, nmat, mjNTEXROLE ) \ - XMJV( mjtByte, mat_texuniform, nmat, 1 ) \ - XMJV( float, mat_texrepeat, nmat, 2 ) \ - XMJV( float, mat_emission, nmat, 1 ) \ - XMJV( float, mat_specular, nmat, 1 ) \ - XMJV( float, mat_shininess, nmat, 1 ) \ - XMJV( float, mat_reflectance, nmat, 1 ) \ - XMJV( float, mat_metallic, nmat, 1 ) \ - XMJV( float, mat_roughness, nmat, 1 ) \ - XMJV( float, mat_rgba, nmat, 4 ) \ + X ( int, tex_pathadr, ntex, 1 ) + +#define MJMODEL_POINTERS_MATERIAL \ + X ( int, mat_texid, nmat, mjNTEXROLE ) \ + X ( mjtBool, mat_texuniform, nmat, 1 ) \ + X ( float, mat_texrepeat, nmat, 2 ) \ + X ( float, mat_emission, nmat, 1 ) \ + X ( float, mat_specular, nmat, 1 ) \ + X ( float, mat_shininess, nmat, 1 ) \ + X ( float, mat_reflectance, nmat, 1 ) \ + X ( float, mat_metallic, nmat, 1 ) \ + X ( float, mat_roughness, nmat, 1 ) \ + X ( float, mat_rgba, nmat, 4 ) + +#define MJMODEL_POINTERS_PAIR \ X ( int, pair_dim, npair, 1 ) \ X ( int, pair_geom1, npair, 1 ) \ X ( int, pair_geom2, npair, 1 ) \ @@ -460,80 +615,141 @@ X ( mjtNum, pair_solimp, npair, mjNIMP ) \ X ( mjtNum, pair_margin, npair, 1 ) \ X ( mjtNum, pair_gap, npair, 1 ) \ - X ( mjtNum, pair_friction, npair, 5 ) \ - X ( int, exclude_signature, nexclude, 1 ) \ - XMJV( int, eq_type, neq, 1 ) \ - XMJV( int, eq_obj1id, neq, 1 ) \ - XMJV( int, eq_obj2id, neq, 1 ) \ - XMJV( int, eq_objtype, neq, 1 ) \ - X ( mjtByte, eq_active0, neq, 1 ) \ + X ( mjtNum, pair_friction, npair, 5 ) + +#define MJMODEL_POINTERS_EXCLUDE \ + X ( int, exclude_signature, nexclude, 1 ) + +#define MJMODEL_POINTERS_EQUALITY \ + X ( int, eq_type, neq, 1 ) \ + X ( int, eq_obj1id, neq, 1 ) \ + X ( int, eq_obj2id, neq, 1 ) \ + X ( int, eq_objtype, neq, 1 ) \ + X ( mjtBool, eq_active0, neq, 1 ) \ X ( mjtNum, eq_solref, neq, mjNREF ) \ X ( mjtNum, eq_solimp, neq, mjNIMP ) \ - XMJV( mjtNum, eq_data, neq, mjNEQDATA ) \ + X ( mjtNum, eq_data, neq, mjNEQDATA ) + +#define MJMODEL_POINTERS_TENDON \ X ( int, tendon_adr, ntendon, 1 ) \ - XMJV( int, tendon_num, ntendon, 1 ) \ - XMJV( int, tendon_matid, ntendon, 1 ) \ - XMJV( int, tendon_group, ntendon, 1 ) \ - XMJV( mjtByte, tendon_limited, ntendon, 1 ) \ - XMJV( mjtByte, tendon_actfrclimited, ntendon, 1 ) \ - XMJV( mjtNum, tendon_width, ntendon, 1 ) \ + X ( int, tendon_num, ntendon, 1 ) \ + X ( int, tendon_matid, ntendon, 1 ) \ + X ( int, tendon_actuatorid, ntendon, 1 ) \ + X ( int, tendon_group, ntendon, 1 ) \ + X ( int, tendon_treenum, ntendon, 1 ) \ + X ( int, tendon_treeid, ntendon, 2 ) \ + X ( int, ten_J_rownnz, ntendon, 1 ) \ + X ( int, ten_J_rowadr, ntendon, 1 ) \ + X ( int, ten_J_colind, nJten, 1 ) \ + X ( mjtBool, tendon_limited, ntendon, 1 ) \ + X ( mjtBool, tendon_actfrclimited, ntendon, 1 ) \ + X ( mjtNum, tendon_width, ntendon, 1 ) \ X ( mjtNum, tendon_solref_lim, ntendon, mjNREF ) \ X ( mjtNum, tendon_solimp_lim, ntendon, mjNIMP ) \ X ( mjtNum, tendon_solref_fri, ntendon, mjNREF ) \ X ( mjtNum, tendon_solimp_fri, ntendon, mjNIMP ) \ - XMJV( mjtNum, tendon_range, ntendon, 2 ) \ - XMJV( mjtNum, tendon_actfrcrange, ntendon, 2 ) \ + X ( mjtNum, tendon_range, ntendon, 2 ) \ + X ( mjtNum, tendon_actfrcrange, ntendon, 2 ) \ X ( mjtNum, tendon_margin, ntendon, 1 ) \ - XMJV( mjtNum, tendon_stiffness, ntendon, 1 ) \ - XMJV( mjtNum, tendon_damping, ntendon, 1 ) \ + X ( mjtNum, tendon_stiffness, ntendon, 1 ) \ + X ( mjtNum, tendon_stiffnesspoly, ntendon, mjNPOLY ) \ + X ( mjtNum, tendon_damping, ntendon, 1 ) \ + X ( mjtNum, tendon_dampingpoly, ntendon, mjNPOLY ) \ X ( mjtNum, tendon_armature, ntendon, 1 ) \ - XMJV( mjtNum, tendon_frictionloss, ntendon, 1 ) \ - XMJV( mjtNum, tendon_lengthspring, ntendon, 2 ) \ + X ( mjtNum, tendon_frictionloss, ntendon, 1 ) \ + X ( mjtNum, tendon_lengthspring, ntendon, 2 ) \ X ( mjtNum, tendon_length0, ntendon, 1 ) \ X ( mjtNum, tendon_invweight0, ntendon, 1 ) \ X ( mjtNum, tendon_user, ntendon, MJ_M(nuser_tendon) ) \ - XMJV( float, tendon_rgba, ntendon, 4 ) \ - X ( int, wrap_type, nwrap, 1 ) \ - X ( int, wrap_objid, nwrap, 1 ) \ - X ( mjtNum, wrap_prm, nwrap, 1 ) \ - XMJV( int, actuator_trntype, nu, 1 ) \ - XMJV( int, actuator_dyntype, nu, 1 ) \ + X ( float, tendon_rgba, ntendon, 4 ) + +#define MJMODEL_POINTERS_ACTUATOR \ + X ( int, actuator_trntype, nu, 1 ) \ + X ( int, actuator_dyntype, nu, 1 ) \ X ( int, actuator_gaintype, nu, 1 ) \ X ( int, actuator_biastype, nu, 1 ) \ - XMJV( int, actuator_trnid, nu, 2 ) \ - XMJV( int, actuator_actadr, nu, 1 ) \ - XMJV( int, actuator_actnum, nu, 1 ) \ - XMJV( int, actuator_group, nu, 1 ) \ - XMJV( mjtByte, actuator_ctrllimited, nu, 1 ) \ - X ( mjtByte, actuator_forcelimited, nu, 1 ) \ - XMJV( mjtByte, actuator_actlimited, nu, 1 ) \ + X ( int, actuator_trnid, nu, 2 ) \ + X ( mjtNum, actuator_damping, nu, 1 ) \ + X ( mjtNum, actuator_dampingpoly, nu, mjNPOLY ) \ + X ( mjtNum, actuator_armature, nu, 1 ) \ + X ( int, actuator_actadr, nu, 1 ) \ + X ( int, actuator_actnum, nu, 1 ) \ + X ( int, actuator_group, nu, 1 ) \ + X ( int, actuator_history, nu, 2 ) \ + X ( int, actuator_historyadr, nu, 1 ) \ + X ( mjtNum, actuator_delay, nu, 1 ) \ + X ( mjtBool, actuator_ctrllimited, nu, 1 ) \ + X ( mjtBool, actuator_forcelimited, nu, 1 ) \ + X ( mjtBool, actuator_actlimited, nu, 1 ) \ X ( mjtNum, actuator_dynprm, nu, mjNDYN ) \ X ( mjtNum, actuator_gainprm, nu, mjNGAIN ) \ X ( mjtNum, actuator_biasprm, nu, mjNBIAS ) \ - X ( mjtByte, actuator_actearly, nu, 1 ) \ - XMJV( mjtNum, actuator_ctrlrange, nu, 2 ) \ + X ( mjtBool, actuator_actearly, nu, 1 ) \ + X ( mjtNum, actuator_ctrlrange, nu, 2 ) \ X ( mjtNum, actuator_forcerange, nu, 2 ) \ - XMJV( mjtNum, actuator_actrange, nu, 2 ) \ + X ( mjtNum, actuator_actrange, nu, 2 ) \ X ( mjtNum, actuator_gear, nu, 6 ) \ - XMJV( mjtNum, actuator_cranklength, nu, 1 ) \ + X ( mjtNum, actuator_cranklength, nu, 1 ) \ X ( mjtNum, actuator_acc0, nu, 1 ) \ X ( mjtNum, actuator_length0, nu, 1 ) \ X ( mjtNum, actuator_lengthrange, nu, 2 ) \ X ( mjtNum, actuator_user, nu, MJ_M(nuser_actuator) ) \ - X ( int, actuator_plugin, nu, 1 ) \ - XMJV( int, sensor_type, nsensor, 1 ) \ + X ( int, actuator_plugin, nu, 1 ) + +#define MJMODEL_POINTERS_SENSOR \ + X ( int, sensor_type, nsensor, 1 ) \ X ( int, sensor_datatype, nsensor, 1 ) \ X ( int, sensor_needstage, nsensor, 1 ) \ X ( int, sensor_objtype, nsensor, 1 ) \ - XMJV( int, sensor_objid, nsensor, 1 ) \ + X ( int, sensor_objid, nsensor, 1 ) \ X ( int, sensor_reftype, nsensor, 1 ) \ X ( int, sensor_refid, nsensor, 1 ) \ + X ( int, sensor_intprm, nsensor, mjNSENS ) \ X ( int, sensor_dim, nsensor, 1 ) \ - XMJV( int, sensor_adr, nsensor, 1 ) \ + X ( int, sensor_adr, nsensor, 1 ) \ X ( mjtNum, sensor_cutoff, nsensor, 1 ) \ X ( mjtNum, sensor_noise, nsensor, 1 ) \ + X ( int, sensor_history, nsensor, 2 ) \ + X ( int, sensor_historyadr, nsensor, 1 ) \ + X ( mjtNum, sensor_delay, nsensor, 1 ) \ + X ( mjtNum, sensor_interval, nsensor, 2 ) \ X ( mjtNum, sensor_user, nsensor, MJ_M(nuser_sensor) ) \ - X ( int, sensor_plugin, nsensor, 1 ) \ + X ( int, sensor_plugin, nsensor, 1 ) + +#define MJMODEL_POINTERS \ + X ( mjtNum, qpos0, nq, 1 ) \ + X ( mjtNum, qpos_spring, nq, 1 ) \ + MJMODEL_POINTERS_BODY \ + X ( int, bvh_depth, nbvh, 1 ) \ + X ( int, bvh_child, nbvh, 2 ) \ + X ( int, bvh_nodeid, nbvh, 1 ) \ + X ( mjtNum, bvh_aabb, nbvhstatic, 6 ) \ + X ( int, oct_depth, noct, 1 ) \ + X ( int, oct_child, noct, 8 ) \ + X ( mjtNum, oct_aabb, noct, 6 ) \ + X ( mjtNum, oct_coeff, noct, 8 ) \ + MJMODEL_POINTERS_JOINT \ + MJMODEL_POINTERS_DOF \ + MJMODEL_POINTERS_TREE \ + MJMODEL_POINTERS_GEOM \ + MJMODEL_POINTERS_SITE \ + MJMODEL_POINTERS_CAMERA \ + MJMODEL_POINTERS_LIGHT \ + MJMODEL_POINTERS_FLEX \ + MJMODEL_POINTERS_MESH \ + MJMODEL_POINTERS_SKIN \ + MJMODEL_POINTERS_HFIELD \ + MJMODEL_POINTERS_TEXTURE \ + MJMODEL_POINTERS_MATERIAL \ + MJMODEL_POINTERS_PAIR \ + MJMODEL_POINTERS_EXCLUDE \ + MJMODEL_POINTERS_EQUALITY \ + MJMODEL_POINTERS_TENDON \ + X ( int, wrap_type, nwrap, 1 ) \ + X ( int, wrap_objid, nwrap, 1 ) \ + X ( mjtNum, wrap_prm, nwrap, 1 ) \ + MJMODEL_POINTERS_ACTUATOR \ + MJMODEL_POINTERS_SENSOR \ X ( int, plugin, nplugin, 1 ) \ X ( int, plugin_stateadr, nplugin, 1 ) \ X ( int, plugin_statenum, nplugin, 1 ) \ @@ -557,12 +773,12 @@ X ( mjtNum, key_mpos, nkey, MJ_M(nmocap)*3 ) \ X ( mjtNum, key_mquat, nkey, MJ_M(nmocap)*4 ) \ X ( mjtNum, key_ctrl, nkey, MJ_M(nu) ) \ - XMJV( int, name_bodyadr, nbody, 1 ) \ - XMJV( int, name_jntadr, njnt, 1 ) \ - XMJV( int, name_geomadr, ngeom, 1 ) \ - XMJV( int, name_siteadr, nsite, 1 ) \ - XMJV( int, name_camadr, ncam, 1 ) \ - XMJV( int, name_lightadr, nlight, 1 ) \ + X ( int, name_bodyadr, nbody, 1 ) \ + X ( int, name_jntadr, njnt, 1 ) \ + X ( int, name_geomadr, ngeom, 1 ) \ + X ( int, name_siteadr, nsite, 1 ) \ + X ( int, name_camadr, ncam, 1 ) \ + X ( int, name_lightadr, nlight, 1 ) \ X ( int, name_flexadr, nflex, 1 ) \ X ( int, name_meshadr, nmesh, 1 ) \ X ( int, name_skinadr, nskin, 1 ) \ @@ -571,92 +787,104 @@ X ( int, name_matadr, nmat, 1 ) \ X ( int, name_pairadr, npair, 1 ) \ X ( int, name_excludeadr, nexclude, 1 ) \ - XMJV( int, name_eqadr, neq, 1 ) \ - XMJV( int, name_tendonadr, ntendon, 1 ) \ - XMJV( int, name_actuatoradr, nu, 1 ) \ + X ( int, name_eqadr, neq, 1 ) \ + X ( int, name_tendonadr, ntendon, 1 ) \ + X ( int, name_actuatoradr, nu, 1 ) \ X ( int, name_sensoradr, nsensor, 1 ) \ X ( int, name_numericadr, nnumeric, 1 ) \ X ( int, name_textadr, ntext, 1 ) \ X ( int, name_tupleadr, ntuple, 1 ) \ X ( int, name_keyadr, nkey, 1 ) \ X ( int, name_pluginadr, nplugin, 1 ) \ - XMJV( char, names, nnames, 1 ) \ + X ( char, names, nnames, 1 ) \ X ( int, names_map, nnames_map, 1 ) \ - XMJV( char, paths, npaths, 1 ) \ + X ( char, paths, npaths, 1 ) \ + X ( int, B_rownnz, nbody, 1 ) \ + X ( int, B_rowadr, nbody, 1 ) \ + X ( int, B_colind, nB, 1 ) \ + X ( int, M_rownnz, nv, 1 ) \ + X ( int, M_rowadr, nv, 1 ) \ + X ( int, M_colind, nC, 1 ) \ + X ( int, mapM2M, nC, 1 ) \ + X ( int, D_rownnz, nv, 1 ) \ + X ( int, D_rowadr, nv, 1 ) \ + X ( int, D_diag, nv, 1 ) \ + X ( int, D_colind, nD, 1 ) \ + X ( int, mapM2D, nD, 1 ) \ + X ( int, mapD2M, nC, 1 ) //-------------------------------- mjData ---------------------------------------------------------- -// define symbols needed in MJDATA_POINTERS (corresponding to number of columns) -#define MJDATA_POINTERS_PREAMBLE( m ) \ - int nv = m->nv; - - // pointer fields of mjData -// XMJV means that the field is required to construct mjvScene -// (by default we define XMJV to be the same as X) +// XNV means that the field is not required to construct mjvScene +// (by default we define XNV to be the same as X) #define MJDATA_POINTERS \ X ( mjtNum, qpos, nq, 1 ) \ X ( mjtNum, qvel, nv, 1 ) \ - XMJV( mjtNum, act, na, 1 ) \ + X ( mjtNum, act, na, 1 ) \ + X ( mjtNum, history, nhistory, 1 ) \ X ( mjtNum, qacc_warmstart, nv, 1 ) \ X ( mjtNum, plugin_state, npluginstate, 1 ) \ - XMJV( mjtNum, ctrl, nu, 1 ) \ + X ( mjtNum, ctrl, nu, 1 ) \ X ( mjtNum, qfrc_applied, nv, 1 ) \ - XMJV( mjtNum, xfrc_applied, nbody, 6 ) \ - XMJV( mjtByte, eq_active, neq, 1 ) \ + X ( mjtNum, xfrc_applied, nbody, 6 ) \ + X ( mjtBool, eq_active, neq, 1 ) \ X ( mjtNum, mocap_pos, nmocap, 3 ) \ X ( mjtNum, mocap_quat, nmocap, 4 ) \ X ( mjtNum, qacc, nv, 1 ) \ X ( mjtNum, act_dot, na, 1 ) \ X ( mjtNum, userdata, nuserdata, 1 ) \ - XMJV( mjtNum, sensordata, nsensordata, 1 ) \ + X ( mjtNum, sensordata, nsensordata, 1 ) \ + X ( int, tree_asleep, ntree, 1 ) \ X ( int, plugin, nplugin, 1 ) \ X ( uintptr_t, plugin_data, nplugin, 1 ) \ - XMJV( mjtNum, xpos, nbody, 3 ) \ - XMJV( mjtNum, xquat, nbody, 4 ) \ - XMJV( mjtNum, xmat, nbody, 9 ) \ - XMJV( mjtNum, xipos, nbody, 3 ) \ - XMJV( mjtNum, ximat, nbody, 9 ) \ - XMJV( mjtNum, xanchor, njnt, 3 ) \ - XMJV( mjtNum, xaxis, njnt, 3 ) \ - XMJV( mjtNum, geom_xpos, ngeom, 3 ) \ - XMJV( mjtNum, geom_xmat, ngeom, 9 ) \ - XMJV( mjtNum, site_xpos, nsite, 3 ) \ - XMJV( mjtNum, site_xmat, nsite, 9 ) \ - XMJV( mjtNum, cam_xpos, ncam, 3 ) \ - XMJV( mjtNum, cam_xmat, ncam, 9 ) \ - XMJV( mjtNum, light_xpos, nlight, 3 ) \ - XMJV( mjtNum, light_xdir, nlight, 3 ) \ - XMJV( mjtNum, subtree_com, nbody, 3 ) \ + X ( mjtNum, xpos, nbody, 3 ) \ + X ( mjtNum, xquat, nbody, 4 ) \ + X ( mjtNum, xmat, nbody, 9 ) \ + X ( mjtNum, xipos, nbody, 3 ) \ + X ( mjtNum, ximat, nbody, 9 ) \ + X ( mjtNum, xanchor, njnt, 3 ) \ + X ( mjtNum, xaxis, njnt, 3 ) \ + X ( mjtNum, geom_xpos, ngeom, 3 ) \ + X ( mjtNum, geom_xmat, ngeom, 9 ) \ + X ( mjtNum, site_xpos, nsite, 3 ) \ + X ( mjtNum, site_xmat, nsite, 9 ) \ + X ( mjtNum, cam_xpos, ncam, 3 ) \ + X ( mjtNum, cam_xmat, ncam, 9 ) \ + X ( mjtNum, light_xpos, nlight, 3 ) \ + X ( mjtNum, light_xdir, nlight, 3 ) \ + X ( mjtNum, subtree_com, nbody, 3 ) \ X ( mjtNum, cdof, nv, 6 ) \ X ( mjtNum, cinert, nbody, 10 ) \ - XMJV( mjtNum, flexvert_xpos, nflexvert, 3 ) \ + X ( mjtNum, flexvert_xpos, nflexvert, 3 ) \ X ( mjtNum, flexelem_aabb, nflexelem, 6 ) \ - X ( int, flexedge_J_rownnz, nflexedge, 1 ) \ - X ( int, flexedge_J_rowadr, nflexedge, 1 ) \ - X ( int, flexedge_J_colind, nflexedge, MJ_M(nv) ) \ - X ( mjtNum, flexedge_J, nflexedge, MJ_M(nv) ) \ + X ( mjtNum, flexedge_J, nJfe, 1 ) \ X ( mjtNum, flexedge_length, nflexedge, 1 ) \ - XMJV( int, ten_wrapadr, ntendon, 1 ) \ - XMJV( int, ten_wrapnum, ntendon, 1 ) \ - X ( int, ten_J_rownnz, ntendon, 1 ) \ - X ( int, ten_J_rowadr, ntendon, 1 ) \ - X ( int, ten_J_colind, ntendon, MJ_M(nv) ) \ - XMJV( mjtNum, ten_length, ntendon, 1 ) \ - X ( mjtNum, ten_J, ntendon, MJ_M(nv) ) \ - XMJV( int, wrap_obj, nwrap, 2 ) \ - XMJV( mjtNum, wrap_xpos, nwrap, 6 ) \ + X ( mjtNum, flexvert_J, nJfv, 2 ) \ + X ( mjtNum, flexvert_length, nflexvert, 2 ) \ + X ( mjtNum, bvh_aabb_dyn, nbvhdynamic, 6 ) \ + X ( int, ten_wrapadr, ntendon, 1 ) \ + X ( int, ten_wrapnum, ntendon, 1 ) \ + X ( mjtNum, ten_J, nJten, 1 ) \ + X ( mjtNum, ten_length, ntendon, 1 ) \ + X ( int, wrap_obj, nwrap, 2 ) \ + X ( mjtNum, wrap_xpos, nwrap, 6 ) \ X ( mjtNum, actuator_length, nu, 1 ) \ X ( int, moment_rownnz, nu, 1 ) \ X ( int, moment_rowadr, nu, 1 ) \ X ( int, moment_colind, nJmom, 1 ) \ X ( mjtNum, actuator_moment, nJmom, 1 ) \ - X ( mjtNum, crb, nbody, 10 ) \ - X ( mjtNum, qM, nM, 1 ) \ - X ( mjtNum, qLD, nM, 1 ) \ + XNV ( mjtNum, crb, nbody, 10 ) \ + XNV ( mjtNum, qM, nM, 1 ) \ + XNV ( mjtNum, M, nC, 1 ) \ + XNV ( mjtNum, qLD, nC, 1 ) \ X ( mjtNum, qLDiagInv, nv, 1 ) \ - XMJV( mjtNum, bvh_aabb_dyn, nbvhdynamic, 6 ) \ - XMJV( mjtByte, bvh_active, nbvh, 1 ) \ + X ( mjtBool, bvh_active, nbvh, 1 ) \ + X ( int, tree_awake, ntree, 1 ) \ + X ( int, body_awake, nbody, 1 ) \ + X ( int, body_awake_ind, nbody, 1 ) \ + X ( int, parent_awake_ind, nbody, 1 ) \ + X ( int, dof_awake_ind, nv, 1 ) \ X ( mjtNum, flexedge_velocity, nflexedge, 1 ) \ X ( mjtNum, ten_velocity, ntendon, 1 ) \ X ( mjtNum, actuator_velocity, nu, 1 ) \ @@ -670,27 +898,10 @@ X ( mjtNum, qfrc_passive, nv, 1 ) \ X ( mjtNum, subtree_linvel, nbody, 3 ) \ X ( mjtNum, subtree_angmom, nbody, 3 ) \ - X ( mjtNum, qH, nM, 1 ) \ + XNV ( mjtNum, qH, nC, 1 ) \ X ( mjtNum, qHDiagInv, nv, 1 ) \ - X ( int, B_rownnz, nbody, 1 ) \ - X ( int, B_rowadr, nbody, 1 ) \ - X ( int, B_colind, nB, 1 ) \ - X ( int, M_rownnz, nv, 1 ) \ - X ( int, M_rowadr, nv, 1 ) \ - X ( int, M_colind, nM, 1 ) \ - X ( int, mapM2M, nM, 1 ) \ - X ( int, C_rownnz, nv, 1 ) \ - X ( int, C_rowadr, nv, 1 ) \ - X ( int, C_colind, nC, 1 ) \ - X ( int, mapM2C, nC, 1 ) \ - X ( int, D_rownnz, nv, 1 ) \ - X ( int, D_rowadr, nv, 1 ) \ - X ( int, D_diag, nv, 1 ) \ - X ( int, D_colind, nD, 1 ) \ - X ( int, mapM2D, nD, 1 ) \ - X ( int, mapD2M, nM, 1 ) \ - X ( mjtNum, qDeriv, nD, 1 ) \ - X ( mjtNum, qLU, nD, 1 ) \ + XNV ( mjtNum, qDeriv, nD, 1 ) \ + XNV ( mjtNum, qLU, nD, 1 ) \ X ( mjtNum, actuator_force, nu, 1 ) \ X ( mjtNum, qfrc_actuator, nv, 1 ) \ X ( mjtNum, qfrc_smooth, nv, 1 ) \ @@ -711,51 +922,70 @@ X( mjContact, contact, MJ_D(ncon), 1 ) // array fields of mjData that are used in the primal problem -#define MJDATA_ARENA_POINTERS_SOLVER \ - X( int, efc_type, MJ_D(nefc), 1 ) \ - X( int, efc_id, MJ_D(nefc), 1 ) \ - X( int, efc_J_rownnz, MJ_D(nefc), 1 ) \ - X( int, efc_J_rowadr, MJ_D(nefc), 1 ) \ - X( int, efc_J_rowsuper, MJ_D(nefc), 1 ) \ - X( int, efc_J_colind, MJ_D(nJ), 1 ) \ - X( int, efc_JT_rownnz, MJ_M(nv), 1 ) \ - X( int, efc_JT_rowadr, MJ_M(nv), 1 ) \ - X( int, efc_JT_rowsuper, MJ_M(nv), 1 ) \ - X( int, efc_JT_colind, MJ_D(nJ), 1 ) \ - X( mjtNum, efc_J, MJ_D(nJ), 1 ) \ - X( mjtNum, efc_JT, MJ_D(nJ), 1 ) \ - X( mjtNum, efc_pos, MJ_D(nefc), 1 ) \ - X( mjtNum, efc_margin, MJ_D(nefc), 1 ) \ - X( mjtNum, efc_frictionloss, MJ_D(nefc), 1 ) \ - X( mjtNum, efc_diagApprox, MJ_D(nefc), 1 ) \ - X( mjtNum, efc_KBIP, MJ_D(nefc), 4 ) \ - X( mjtNum, efc_D, MJ_D(nefc), 1 ) \ - X( mjtNum, efc_R, MJ_D(nefc), 1 ) \ - X( int, tendon_efcadr, MJ_M(ntendon), 1 ) \ - X( mjtNum, efc_vel, MJ_D(nefc), 1 ) \ - X( mjtNum, efc_aref, MJ_D(nefc), 1 ) \ - X( mjtNum, efc_b, MJ_D(nefc), 1 ) \ - X( mjtNum, efc_force, MJ_D(nefc), 1 ) \ - X( int, efc_state, MJ_D(nefc), 1 ) +#define MJDATA_ARENA_POINTERS_SOLVER \ + X ( int, efc_type, MJ_D(nefc), 1 ) \ + X ( int, efc_id, MJ_D(nefc), 1 ) \ + XNV( int, efc_J_rownnz, MJ_D(nefc), 1 ) \ + XNV( int, efc_J_rowadr, MJ_D(nefc), 1 ) \ + XNV( int, efc_J_rowsuper, MJ_D(nefc), 1 ) \ + XNV( int, efc_J_colind, MJ_D(nJ), 1 ) \ + XNV( mjtNum, efc_J, MJ_D(nJ), 1 ) \ + X ( mjtNum, efc_pos, MJ_D(nefc), 1 ) \ + X ( mjtNum, efc_margin, MJ_D(nefc), 1 ) \ + X ( mjtNum, efc_frictionloss, MJ_D(nefc), 1 ) \ + X ( mjtNum, efc_diagA, MJ_D(nefc), 1 ) \ + X ( mjtNum, efc_KBIP, MJ_D(nefc), 4 ) \ + X ( mjtNum, efc_D, MJ_D(nefc), 1 ) \ + X ( mjtNum, efc_R, MJ_D(nefc), 1 ) \ + X ( int, tendon_efcadr, MJ_M(ntendon), 1 ) \ + X ( mjtNum, efc_vel, MJ_D(nefc), 1 ) \ + X ( mjtNum, efc_aref, MJ_D(nefc), 1 ) \ + X ( mjtNum, efc_b, MJ_D(nefc), 1 ) \ + X ( int, efc_state, MJ_D(nefc), 1 ) \ + X ( mjtNum, efc_force, MJ_D(nefc), 1 ) // array fields of mjData that are used in the dual problem -#define MJDATA_ARENA_POINTERS_DUAL \ - X( int, efc_AR_rownnz, MJ_D(nefc), 1 ) \ - X( int, efc_AR_rowadr, MJ_D(nefc), 1 ) \ - X( int, efc_AR_colind, MJ_D(nA), 1 ) \ - X( mjtNum, efc_AR, MJ_D(nA), 1 ) +#define MJDATA_ARENA_POINTERS_DUAL \ + XNV( int, efc_Y_rownnz, MJ_D(nefc), 1 ) \ + XNV( int, efc_Y_rowadr, MJ_D(nefc), 1 ) \ + XNV( int, efc_Y_colind, MJ_D(nY), 1 ) \ + XNV( mjtNum, efc_Y, MJ_D(nY), 1 ) \ + XNV( int, efc_AR_rownnz, MJ_D(nefc), 1 ) \ + XNV( int, efc_AR_rowadr, MJ_D(nefc), 1 ) \ + XNV( int, efc_AR_colind, MJ_D(nA), 1 ) \ + XNV( mjtNum, efc_AR, MJ_D(nA), 1 ) // array fields of mjData that are used for constraint islands -#define MJDATA_ARENA_POINTERS_ISLAND \ - X( int, dof_island, MJ_M(nv), 1 ) \ - X( int, island_dofnum, MJ_D(nisland), 1 ) \ - X( int, island_dofadr, MJ_D(nisland), 1 ) \ - X( int, island_dofind, MJ_M(nv), 1 ) \ - X( int, dof_islandind, MJ_M(nv), 1 ) \ - X( int, efc_island, MJ_D(nefc), 1 ) \ - X( int, island_efcnum, MJ_D(nisland), 1 ) \ - X( int, island_efcadr, MJ_D(nisland), 1 ) \ - X( int, island_efcind, MJ_D(nefc), 1 ) +#define MJDATA_ARENA_POINTERS_ISLAND \ + X ( int, tree_island, MJ_M(ntree), 1 ) \ + X ( int, island_ntree, MJ_D(nisland), 1 ) \ + X ( int, island_itreeadr, MJ_D(nisland), 1 ) \ + X ( int, map_itree2tree, MJ_M(ntree), 1 ) \ + X ( int, dof_island, MJ_M(nv), 1 ) \ + X ( int, island_nv, MJ_D(nisland), 1 ) \ + X ( int, island_idofadr, MJ_D(nisland), 1 ) \ + X ( int, island_dofadr, MJ_D(nisland), 1 ) \ + X ( int, map_dof2idof, MJ_M(nv), 1 ) \ + X ( int, map_idof2dof, MJ_M(nv), 1 ) \ + X ( mjtNum, ifrc_smooth, MJ_D(nidof), 1 ) \ + X ( mjtNum, iacc_smooth, MJ_D(nidof), 1 ) \ + X ( mjtNum, iacc, MJ_D(nidof), 1 ) \ + X ( int, efc_island, MJ_D(nefc), 1 ) \ + X ( int, island_ne, MJ_D(nisland), 1 ) \ + X ( int, island_nf, MJ_D(nisland), 1 ) \ + X ( int, island_nefc, MJ_D(nisland), 1 ) \ + X ( int, island_iefcadr, MJ_D(nisland), 1 ) \ + X ( int, map_efc2iefc, MJ_D(nefc), 1 ) \ + X ( int, map_iefc2efc, MJ_D(nefc), 1 ) \ + X ( int, iefc_type, MJ_D(nefc), 1 ) \ + X ( int, iefc_id, MJ_D(nefc), 1 ) \ + X ( mjtNum, iefc_frictionloss, MJ_D(nefc), 1 ) \ + X ( mjtNum, iefc_D, MJ_D(nefc), 1 ) \ + X ( mjtNum, iefc_R, MJ_D(nefc), 1 ) \ + X ( mjtNum, iefc_aref, MJ_D(nefc), 1 ) \ + X ( int, iefc_state, MJ_D(nefc), 1 ) \ + X ( mjtNum, iefc_force, MJ_D(nefc), 1 ) \ + X ( mjtNum, ifrc_constraint, MJ_D(nidof), 1 ) // array fields of mjData that live in d->arena #define MJDATA_ARENA_POINTERS \ @@ -773,6 +1003,7 @@ X( size_t, pstack ) \ X( size_t, pbase ) \ X( size_t, parena ) \ + X( uintptr_t, threadpool ) \ X( size_t, maxuse_stack ) \ X( size_t, maxuse_arena ) \ X( int, maxuse_con ) \ @@ -783,29 +1014,31 @@ X( int, nl ) \ X( int, nefc ) \ X( int, nJ ) \ + X( int, nY ) \ X( int, nA ) \ X( int, nisland ) \ - X( mjtNum, time ) \ - X( uintptr_t, threadpool ) + X( int, nidof ) \ + X( int, ntree_awake ) \ + X( int, nbody_awake ) \ + X( int, nparent_awake ) \ + X( int, nv_awake ) \ + X( mjtBool, flg_energypos ) \ + X( mjtBool, flg_energyvel ) \ + X( mjtBool, flg_subtreevel ) \ + X( mjtBool, flg_rnepost ) \ + X( mjtNum, time ) // vector fields of mjData #define MJDATA_VECTOR \ - X( size_t, maxuse_threadstack, mjMAXTHREAD, 1 ) \ - X( mjWarningStat, warning, mjNWARNING, 1 ) \ - X( mjTimerStat, timer, mjNTIMER, 1 ) \ X( mjSolverStat, solver, mjNISLAND, mjNSOLVER ) \ X( int, solver_niter, mjNISLAND, 1 ) \ X( int, solver_nnz, mjNISLAND, 1 ) \ X( mjtNum, solver_fwdinv, 2, 1 ) \ + X( mjWarningStat, warning, mjNWARNING, 1 ) \ + X( mjTimerStat, timer, mjNTIMER, 1 ) \ X( mjtNum, energy, 2, 1 ) - -// alias XMJV to be the same as X -// to obtain only X macros for fields that are relevant for mjvScene creation, -// redefine X to expand to nothing, and XMJV to do what's required -#define XMJV X - // alias XNV to be the same as X // to obtain only X macros for fields that are relevant for mjvScene creation, // redefine XNV to expand to nothing diff --git a/vendor/include/mujoco/mujoco.h b/vendor/include/mujoco/mujoco.h index 1fb936a..693bee1 100644 --- a/vendor/include/mujoco/mujoco.h +++ b/vendor/include/mujoco/mujoco.h @@ -16,7 +16,7 @@ #define MUJOCO_MUJOCO_H_ // header version; should match the library version as returned by mj_version() -#define mjVERSION_HEADER 340 +#define mjVERSION_HEADER 3010000 // needed to define size_t, fabs and log10 #include @@ -31,22 +31,24 @@ #include #include #include -#include -#include +#include #include #include +#include // this is a C-API #ifdef __cplusplus extern "C" { #endif -// user error and memory handlers -MJAPI extern void (*mju_user_error)(const char*); -MJAPI extern void (*mju_user_warning)(const char*); +// user memory handlers MJAPI extern void* (*mju_user_malloc)(size_t); MJAPI extern void (*mju_user_free)(void*); +// legacy error/warning handlers (deprecated: prefer mju_setLogHandler) +MJAPI extern void (*mju_user_error)(const char*); +MJAPI extern void (*mju_user_warning)(const char*); + // callbacks extending computation pipeline MJAPI extern mjfGeneric mjcb_passive; @@ -71,6 +73,7 @@ MJAPI extern const char* mjLABELSTRING[mjNLABEL]; MJAPI extern const char* mjFRAMESTRING[mjNFRAME]; MJAPI extern const char* mjVISSTRING[mjNVISFLAG][3]; MJAPI extern const char* mjRNDSTRING[mjNRNDFLAG][3]; +MJAPI extern const char* mjTOPICSTRING[mjNTOPIC]; //---------------------------------- Virtual file system ------------------------------------------- @@ -78,15 +81,28 @@ MJAPI extern const char* mjRNDSTRING[mjNRNDFLAG][3]; // Initialize an empty VFS, mj_deleteVFS must be called to deallocate the VFS. MJAPI void mj_defaultVFS(mjVFS* vfs); -// Add file to VFS, return 0: success, 2: repeated name, -1: failed to load. +// Mount a ResourceProvider to handle file operations under the given path; return 0: success, +// 2: repeated name, -1: invalid resource provider. +MJAPI int mj_mountVFS(mjVFS* vfs, const char* filepath, const mjpResourceProvider* provider); + +// Unmount a previously mounted ResourceProvider; return 0: success, -1: not found in VFS. +MJAPI int mj_unmountVFS(mjVFS* vfs, const char* filename); + +// Add file to VFS; return 0: success, 2: repeated name, -1: failed to load. MJAPI int mj_addFileVFS(mjVFS* vfs, const char* directory, const char* filename); -// Add file to VFS from buffer, return 0: success, 2: repeated name, -1: failed to load. +// Add file to VFS from buffer; return 0: success, 2: repeated name, -1: failed to load. MJAPI int mj_addBufferVFS(mjVFS* vfs, const char* name, const void* buffer, int nbuffer); -// Delete file from VFS, return 0: success, -1: not found in VFS. +// Delete file from VFS; return 0: success, -1: not found in VFS. MJAPI int mj_deleteFileVFS(mjVFS* vfs, const char* filename); +// Check if buffer exists in VFS; return 1: exists, 0: not found. +MJAPI int mj_containsBufferVFS(mjVFS* vfs, const char* name); + +// Check if file exists in VFS; return 1: exists, 0: not found. +MJAPI int mj_containsFileVFS(mjVFS* vfs, const char* directory, const char* filename); + // Delete all files from VFS and deallocates VFS internal memory. MJAPI void mj_deleteVFS(mjVFS* vfs); @@ -98,7 +114,7 @@ MJAPI size_t mj_getCacheSize(const mjCache* cache); // Get the capacity of the asset cache in bytes. MJAPI size_t mj_getCacheCapacity(const mjCache* cache); -// Set the capacity of the asset cache in bytes (0 to disable); returns the new capacity. +// Set the capacity of the asset cache in bytes (0 to disable); return the new capacity. MJAPI size_t mj_setCacheCapacity(mjCache* cache, size_t size); // Get the internal asset cache used by the compiler. @@ -109,7 +125,7 @@ MJAPI void mj_clearCache(mjCache* cache); //---------------------------------- Parse and compile --------------------------------------------- -// Parse XML file in MJCF or URDF format, compile it, return low-level model. +// 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. // If error is not NULL, it must have size error_sz. // Nullable: vfs, error @@ -128,14 +144,21 @@ MJAPI mjSpec* mj_parseXMLString(const char* xml, const mjVFS* vfs, char* error, MJAPI mjSpec* mj_parse(const char* filename, const char* content_type, const mjVFS* vfs, char* error, int error_sz); +// Encode spec/model to a file using a registered encoder. +// Returns the number of bytes written on success, -1 on failure. +// Nullable: m, vfs, error +MJAPI int mj_encode(const mjSpec* s, const mjModel* m, const char* filename, + const char* content_type, const mjVFS* vfs, char* error, + int error_sz); + // Compile spec to model. // Nullable: vfs MJAPI mjModel* mj_compile(mjSpec* s, const mjVFS* vfs); -// Copy real-valued arrays from model to spec, returns 1 on success. +// Copy real-valued arrays from model to spec; return 1 on success. MJAPI int mj_copyBack(mjSpec* s, const mjModel* m); -// Recompile spec to model, preserving the state, return 0 on success. +// Recompile spec to model, preserving the state; return 0 on success. // Nullable: vfs MJAPI int mj_recompile(mjSpec* s, const mjVFS* vfs, mjModel* m, mjData* d); @@ -147,12 +170,12 @@ MJAPI int mj_saveLastXML(const char* filename, const mjModel* m, char* error, in // Free last XML model if loaded. Called internally at each load. MJAPI void mj_freeLastXML(void); -// Save spec to XML string, return 0 on success, -1 on failure. -// If length of the output buffer is too small, returns the required size. +// Save spec to XML string; return 0 on success, -1 on failure. +// If length of the output buffer is too small; return the required size. // Nullable: error MJAPI int mj_saveXMLString(const mjSpec* s, char* xml, int xml_sz, char* error, int error_sz); -// Save spec to XML file, return 0 on success, -1 otherwise. +// Save spec to XML file; return 0 on success, -1 otherwise. // Nullable: error MJAPI int mj_saveXML(const mjSpec* s, const char* filename, char* error, int error_sz); @@ -212,6 +235,9 @@ MJAPI void mj_saveModel(const mjModel* m, const char* filename, void* buffer, in // Nullable: vfs MJAPI mjModel* mj_loadModel(const char* filename, const mjVFS* vfs); +// Load model from memory buffer. +MJAPI mjModel* mj_loadModelBuffer(const void* buffer, int buffer_sz); + // Free memory allocation in model. MJAPI void mj_deleteModel(mjModel* m); @@ -282,10 +308,10 @@ MJAPI mjSpec* mj_copySpec(const mjSpec* s); // Free memory allocation in mjSpec. MJAPI void mj_deleteSpec(mjSpec* s); -// Activate plugin. Returns 0 on success. +// Activate plugin; return 0 on success. MJAPI int mjs_activatePlugin(mjSpec* s, const char* name); -// Turn deep copy on or off attach. Returns 0 on success. +// Turn deep copy on or off attach; return 0 on success. MJAPI int mjs_setDeepCopy(mjSpec* s, int deepcopy); @@ -443,6 +469,11 @@ MJAPI void mj_rne(const mjModel* m, mjData* d, int flg_acc, mjtNum* result); // RNE with complete data: compute cacc, cfrc_ext, cfrc_int. MJAPI void mj_rnePostConstraint(const mjModel* m, mjData* d); +// Return the maximum number of contacts that can be generated between two geoms. +// If has_margin is -1, then the margin is pulled from the model, otherwise if has_margin > 0 +// indicates that the geoms have a positive margin. +MJAPI int mj_maxContact(const mjModel* m, int g1, int g2, int has_margin); + // Run collision detection. MJAPI void mj_collision(const mjModel* m, mjData* d); @@ -468,20 +499,43 @@ MJAPI void mj_constraintUpdate(const mjModel* m, mjData* d, const mjtNum* jar, //---------------------------------- Support ------------------------------------------------------- // Return size of state signature. -MJAPI int mj_stateSize(const mjModel* m, unsigned int sig); +MJAPI int mj_stateSize(const mjModel* m, int sig); // Get state. -MJAPI void mj_getState(const mjModel* m, const mjData* d, mjtNum* state, unsigned int sig); +MJAPI void mj_getState(const mjModel* m, const mjData* d, mjtNum* state, int sig); // Extract a subset of components from a state previously obtained via mj_getState. -MJAPI void mj_extractState(const mjModel* m, const mjtNum* src, unsigned int srcsig, - mjtNum* dst, unsigned int dstsig); +MJAPI void mj_extractState(const mjModel* m, const mjtNum* src, int srcsig, + mjtNum* dst, int dstsig); // Set state. -MJAPI void mj_setState(const mjModel* m, mjData* d, const mjtNum* state, unsigned int sig); +MJAPI void mj_setState(const mjModel* m, mjData* d, const mjtNum* state, int sig); // Copy state from src to dst. -MJAPI void mj_copyState(const mjModel* m, const mjData* src, mjData* dst, unsigned int sig); +MJAPI void mj_copyState(const mjModel* m, const mjData* src, mjData* dst, int sig); + +// Read ctrl value for actuator at given time. +// Returns d->ctrl[id] if no history, otherwise reads from history buffer. +// interp: 0=zero-order-hold, 1=linear, 2=cubic spline. +MJAPI mjtNum mj_readCtrl(const mjModel* m, const mjData* d, int id, mjtNum time, int interp); + +// Read sensor value from history buffer at given time. +// Returns pointer to sensordata (no history) or history buffer (exact match), +// or NULL if interpolation performed (writes to result). +// interp: 0=zero-order-hold, 1=linear, 2=cubic spline. +MJAPI const mjtNum* mj_readSensor(const mjModel* m, const mjData* d, int id, mjtNum time, + mjtNum* result, int interp); + +// Initialize history buffer for actuator; if times is NULL, uses existing buffer timestamps. +// Nullable: times +MJAPI void mj_initCtrlHistory(const mjModel* m, mjData* d, int id, + const mjtNum* times, const mjtNum* values); + +// Initialize history buffer for sensor; if times is NULL, uses existing buffer timestamps. +// phase sets the user slot (last computation time for interval sensors). +// Nullable: times +MJAPI void mj_initSensorHistory(const mjModel* m, mjData* d, int id, + const mjtNum* times, const mjtNum* values, mjtNum phase); // Copy current state to the k-th model keyframe. MJAPI void mj_setKeyframe(mjModel* m, const mjData* d, int k); @@ -541,14 +595,14 @@ MJAPI void mj_jacDot(const mjModel* m, const mjData* d, mjtNum* jacp, mjtNum* ja // Compute subtree angular momentum matrix. MJAPI void mj_angmomMat(const mjModel* m, mjData* d, mjtNum* mat, int body); -// Get id of object with the specified mjtObj type and name, returns -1 if id not found. +// Get id of object with the specified mjtObj type and name; return -1 if id not found. MJAPI int mj_name2id(const mjModel* m, int type, const char* name); -// Get name of object with the specified mjtObj type and id, returns NULL if name not found. +// Get name of object with the specified mjtObj type and id; return NULL if name not found. MJAPI const char* mj_id2name(const mjModel* m, int type, int id); -// Convert sparse inertia matrix M into full (i.e. dense) matrix. -MJAPI void mj_fullM(const mjModel* m, mjtNum* dst, const mjtNum* M); +// Convert sparse inertia matrix into full (i.e. dense) matrix. +MJAPI void mj_fullM(const mjModel* m, const mjData* d, mjtNum* dst); // Multiply vector by inertia matrix. MJAPI void mj_mulM(const mjModel* m, const mjData* d, mjtNum* res, const mjtNum* vec); @@ -574,10 +628,10 @@ MJAPI void mj_objectVelocity(const mjModel* m, const mjData* d, MJAPI void mj_objectAcceleration(const mjModel* m, const mjData* d, int objtype, int objid, mjtNum res[6], int flg_local); -// Returns smallest signed distance between two geoms and optionally segment from geom1 to geom2. +// Return smallest signed distance between two geoms and optionally segment from geom1 to geom2. // Nullable: fromto -MJAPI mjtNum mj_geomDistance(const mjModel* m, const mjData* d, int geom1, int geom2, - mjtNum distmax, mjtNum fromto[6]); +MJAPI mjtNum mj_geomDistance(const mjModel* m, mjData* d, int geom1, int geom2, mjtNum distmax, + mjtNum fromto[6]); // Extract 6D force:torque given contact id, in the contact frame. MJAPI void mj_contactForce(const mjModel* m, const mjData* d, int id, mjtNum result[6]); @@ -623,41 +677,47 @@ MJAPI const char* mj_versionString(void); //---------------------------------- Ray casting --------------------------------------------------- -// Intersect multiple rays emanating from a single point. -// Similar semantics to mj_ray, but vec is an array of (nray x 3) directions. -// Nullable: geomgroup -MJAPI void mj_multiRay(const mjModel* m, mjData* d, const mjtNum pnt[3], const mjtNum vec[3], - const mjtByte* geomgroup, mjtByte flg_static, int bodyexclude, - int* geomid, mjtNum* dist, int nray, mjtNum cutoff); - // Intersect ray (pnt+x*vec, x>=0) with visible geoms, except geoms in bodyexclude. -// Return distance (x) to nearest surface, or -1 if no intersection and output geomid. +// Return distance (x) to nearest surface, or -1 if no intersection. // geomgroup, flg_static are as in mjvOption; geomgroup==NULL skips group exclusion. -// Nullable: geomgroup, geomid +// Nullable: geomgroup, geomid, normal MJAPI mjtNum mj_ray(const mjModel* m, const mjData* d, const mjtNum pnt[3], const mjtNum vec[3], - const mjtByte* geomgroup, mjtByte flg_static, int bodyexclude, - int geomid[1]); - -// Intersect ray with hfield, return nearest distance or -1 if no intersection. + const mjtByte* geomgroup, mjtBool flg_static, int bodyexclude, + int geomid[1], mjtNum normal[3]); + +// Intersect multiple rays emanating from a single point, compute normals if given. +// Similar semantics to mj_ray, but vec, normal and dist are arrays. +// Geoms further than cutoff are ignored. +// Nullable: geomgroup, geomid, normal +MJAPI void mj_multiRay(const mjModel* m, mjData* d, const mjtNum pnt[3], const mjtNum* vec, + const mjtByte* geomgroup, mjtBool flg_static, int bodyexclude, + int* geomid, mjtNum* dist, mjtNum* normal, int nray, mjtNum cutoff); + +// Intersect ray with hfield; return nearest distance or -1 if no intersection. +// Nullable: normal MJAPI mjtNum mj_rayHfield(const mjModel* m, const mjData* d, int geomid, - const mjtNum pnt[3], const mjtNum vec[3]); + const mjtNum pnt[3], const mjtNum vec[3], mjtNum normal[3]); -// Intersect ray with mesh, return nearest distance or -1 if no intersection. +// Intersect ray with mesh; return nearest distance or -1 if no intersection. +// Nullable: normal MJAPI mjtNum mj_rayMesh(const mjModel* m, const mjData* d, int geomid, - const mjtNum pnt[3], const mjtNum vec[3]); + const mjtNum pnt[3], const mjtNum vec[3], mjtNum normal[3]); -// Intersect ray with pure geom, return nearest distance or -1 if no intersection. +// Intersect ray with pure geom; return nearest distance or -1 if no intersection. +// Nullable: normal MJAPI mjtNum mju_rayGeom(const mjtNum pos[3], const mjtNum mat[9], const mjtNum size[3], - const mjtNum pnt[3], const mjtNum vec[3], int geomtype); - -// Intersect ray with flex, return nearest distance or -1 if no intersection, -// and also output nearest vertex id. -// Nullable: vertid -MJAPI mjtNum mju_rayFlex(const mjModel* m, const mjData* d, int flex_layer, mjtByte flg_vert, - mjtByte flg_edge, mjtByte flg_face, mjtByte flg_skin, int flexid, - const mjtNum pnt[3], const mjtNum vec[3], int vertid[1]); - -// Intersect ray with skin, return nearest distance or -1 if no intersection, + const mjtNum pnt[3], const mjtNum vec[3], int geomtype, + mjtNum normal[3]); + +// Intersect ray with flex; return nearest distance or -1 if no intersection, +// and also output nearest vertex id and surface normal. +// Nullable: vertid, normal +MJAPI mjtNum mj_rayFlex(const mjModel* m, const mjData* d, int flex_layer, + mjtBool flg_vert, mjtBool flg_edge, mjtBool flg_face, + mjtBool flg_skin, int flexid, const mjtNum pnt[3], + const mjtNum vec[3], int vertid[1], mjtNum normal[3]); + +// Intersect ray with skin; return nearest distance or -1 if no intersection, // and also output nearest vertex id. // Nullable: vertid MJAPI mjtNum mju_raySkin(int nface, int nvert, const int* face, const float* vert, @@ -722,7 +782,7 @@ MJAPI void mjv_applyPerturbForce(const mjModel* m, mjData* d, const mjvPerturb* // Return the average of two OpenGL cameras. MJAPI mjvGLCamera mjv_averageCamera(const mjvGLCamera* cam1, const mjvGLCamera* cam2); -// Select geom, flex or skin with mouse, return bodyid; -1: none selected. +// Select geom, flex or skin with mouse; return bodyid; -1: none selected. // Nullable: geomid, flexid, skinid MJAPI int mjv_select(const mjModel* m, const mjData* d, const mjvOption* vopt, mjtNum aspectratio, mjtNum relx, mjtNum rely, @@ -903,7 +963,7 @@ MJAPI void mjui_resize(mjUI* ui, const mjrContext* con); MJAPI void mjui_update(int section, int item, const mjUI* ui, const mjuiState* state, const mjrContext* con); -// Handle UI event, return pointer to changed item, NULL if no change. +// Handle UI event; return pointer to changed item, NULL if no change. MJAPI mjuiItem* mjui_event(mjUI* ui, mjuiState* state, const mjrContext* con); // Copy UI image to current buffer. @@ -915,24 +975,28 @@ MJAPI void mjui_render(mjUI* ui, const mjuiState* state, const mjrContext* con); // Main error function; does not return to caller. MJAPI void mju_error(const char* msg, ...) mjPRINTFLIKE(1, 2); -// Deprecated: use mju_error. -MJAPI void mju_error_i(const char* msg, int i); - -// Deprecated: use mju_error. -MJAPI void mju_error_s(const char* msg, const char* text); - // Main warning function; returns to caller. MJAPI void mju_warning(const char* msg, ...) mjPRINTFLIKE(1, 2); -// Deprecated: use mju_warning. -MJAPI void mju_warning_i(const char* msg, int i); - -// Deprecated: use mju_warning. -MJAPI void mju_warning_s(const char* msg, const char* text); - // Clear user error and memory handlers. MJAPI void mju_clearHandlers(void); +// Set the active log handler; return the previous handler. +// If handler is NULL, restore the default handler. +MJAPI mjfLogHandler mju_setLogHandler(mjfLogHandler handler); + +// Get default handler configuration. +MJAPI mjLogConfig mju_getLogConfig(void); + +// Set default handler configuration. +MJAPI void mju_setLogConfig(mjLogConfig config); + +// Log an info message with optional topic filtering. +MJAPI void mju_info(int topic, const char* msg, ...) mjPRINTFLIKE(2, 3); + +// Dispatch a structured log message to the active handler. +MJAPI void mju_message(const mjLogMessage* msg); + // Allocate memory; byte-align on 64; pad size to multiple of 64. MJAPI void* mju_malloc(size_t size); @@ -948,9 +1012,17 @@ MJAPI void mju_writeLog(const char* type, const char* msg); // Get compiler error message from spec. MJAPI const char* mjs_getError(mjSpec* s); -// Return 1 if compiler error is a warning. +// Get compiler timing diagnostics from spec, returns pointer to array of size mjNCTIMER. +MJAPI const double* mjs_getTimer(mjSpec* s); + +// Return 1 if compiler error is a warning. Deprecated: use mjs_numWarnings(s) > 0. MJAPI int mjs_isWarning(mjSpec* s); +// Get number of warnings accumulated in the spec. +MJAPI int mjs_numWarnings(const mjSpec* spec); + +// Get the i-th warning message (returns nullptr if index out of bounds). +MJAPI const char* mjs_getWarning(const mjSpec* spec, int index); //---------------------------------- Standard math ------------------------------------------------- @@ -1019,7 +1091,7 @@ MJAPI void mju_addToScl3(mjtNum res[3], const mjtNum vec[3], mjtNum scl); // Set res = vec1 + vec2*scl. MJAPI void mju_addScl3(mjtNum res[3], const mjtNum vec1[3], const mjtNum vec2[3], mjtNum scl); -// Normalize vector, return length before normalization. +// Normalize vector; return length before normalization. MJAPI mjtNum mju_normalize3(mjtNum vec[3]); // Return vector length (without normalizing the vector). @@ -1049,7 +1121,7 @@ MJAPI void mju_unit4(mjtNum res[4]); // Set res = vec. MJAPI void mju_copy4(mjtNum res[4], const mjtNum data[4]); -// Normalize vector, return length before normalization. +// Normalize vector; return length before normalization. MJAPI mjtNum mju_normalize4(mjtNum vec[4]); // Set res = 0. @@ -1088,7 +1160,7 @@ MJAPI void mju_addToScl(mjtNum* res, const mjtNum* vec, mjtNum scl, int n); // Set res = vec1 + vec2*scl. MJAPI void mju_addScl(mjtNum* res, const mjtNum* vec1, const mjtNum* vec2, mjtNum scl, int n); -// Normalize vector, return length before normalization. +// Normalize vector; return length before normalization. MJAPI mjtNum mju_normalize(mjtNum* res, int n); // Return vector length (without normalizing vector). @@ -1103,7 +1175,7 @@ MJAPI void mju_mulMatVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int // Multiply transposed matrix and vector: res = mat' * vec. MJAPI void mju_mulMatTVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int nr, int nc); -// Multiply square matrix with vectors on both sides: returns vec1' * mat * vec2. +// Multiply square matrix with vectors on both sides: return vec1' * mat * vec2. MJAPI mjtNum mju_mulVecMatVec(const mjtNum* vec1, const mjtNum* mat, const mjtNum* vec2, int n); // Transpose matrix: res = mat'. @@ -1141,7 +1213,7 @@ MJAPI void mju_transformSpatial(mjtNum res[6], const mjtNum vec[6], int flg_forc //---------------------------------- Sparse math --------------------------------------------------- // Convert matrix from dense to sparse. -// nnz is size of res and colind, return 1 if too small, 0 otherwise. +// nnz is size of res and colind; return 1 if too small, 0 otherwise. MJAPI int mju_dense2sparse(mjtNum* res, const mjtNum* mat, int nr, int nc, int* rownnz, int* rowadr, int* colind, int nnz); @@ -1149,6 +1221,10 @@ MJAPI int mju_dense2sparse(mjtNum* res, const mjtNum* mat, int nr, int nc, MJAPI void mju_sparse2dense(mjtNum* res, const mjtNum* mat, int nr, int nc, const int* rownnz, const int* rowadr, const int* colind); +// Convert lower-triangular symmetric CSR matrix to full dense matrix. +MJAPI void mju_sym2dense(mjtNum* res, const mjtNum* mat, int n, + const int* rownnz, const int* rowadr, const int* colind); + //---------------------------------- Quaternions --------------------------------------------------- @@ -1189,7 +1265,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]); // Extract 3D rotation from an arbitrary 3x3 matrix by refining the input quaternion. -// Returns the number of iterations required to converge +// Return the number of iterations required to converge. MJAPI int mju_mat2Rot(mjtNum quat[4], const mjtNum mat[9]); // Convert sequence of Euler angles (radians) to quaternion. @@ -1225,7 +1301,7 @@ MJAPI void mju_cholSolve(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int MJAPI int mju_cholUpdate(mjtNum* mat, mjtNum* x, int n, int flg_plus); // Band-dense Cholesky decomposition. -// Returns minimum value in the factorized diagonal, or 0 if rank-deficient. +// Return minimum value in the factorized diagonal, or 0 if rank-deficient. // mat has (ntotal-ndense) x nband + ndense x ntotal elements. // The first (ntotal-ndense) x nband store the band part, left of diagonal, inclusive. // The second ndense x ntotal store the band part as entire dense rows. @@ -1239,14 +1315,14 @@ MJAPI void mju_cholSolveBand(mjtNum* res, const mjtNum* mat, const mjtNum* vec, // Convert banded matrix to dense matrix, fill upper triangle if flg_sym>0. MJAPI void mju_band2Dense(mjtNum* res, const mjtNum* mat, int ntotal, int nband, int ndense, - mjtByte flg_sym); + mjtBool flg_sym); // Convert dense matrix to banded matrix. MJAPI void mju_dense2Band(mjtNum* res, const mjtNum* mat, int ntotal, int nband, int ndense); // Multiply band-diagonal matrix with nvec vectors, include upper triangle if flg_sym>0. MJAPI void mju_bandMulMatVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec, - int ntotal, int nband, int ndense, int nvec, mjtByte flg_sym); + int ntotal, int nband, int ndense, int nvec, mjtBool flg_sym); // Address of diagonal element i in band-dense matrix representation. MJAPI int mju_bandDiag(int i, int ntotal, int nband, int ndense); @@ -1254,7 +1330,7 @@ MJAPI int mju_bandDiag(int i, int ntotal, int nband, int ndense); // Eigenvalue decomposition of symmetric 3x3 matrix, mat = eigvec * diag(eigval) * eigvec'. MJAPI int mju_eig3(mjtNum eigval[3], mjtNum eigvec[9], mjtNum quat[4], const mjtNum mat[9]); -// minimize 0.5*x'*H*x + x'*g s.t. lower <= x <= upper, return rank or -1 if failed +// minimize 0.5*x'*H*x + x'*g s.t. lower <= x <= upper; return rank or -1 if failed // inputs: // n - problem dimension // H - SPD matrix n*n @@ -1305,7 +1381,7 @@ MJAPI void mju_encodePyramid(mjtNum* pyramid, const mjtNum* force, const mjtNum* // Convert pyramid representation to contact force. MJAPI void mju_decodePyramid(mjtNum* force, const mjtNum* pyramid, const mjtNum* mu, int dim); -// Integrate spring-damper analytically, return pos(dt). +// Integrate spring-damper analytically; return pos(dt). MJAPI mjtNum mju_springDamper(mjtNum pos0, mjtNum vel0, mjtNum Kp, mjtNum Kv, mjtNum dt); // Return min(a,b) with single evaluation of a and b. @@ -1372,7 +1448,7 @@ MJAPI char* mju_strncpy(char *dst, const char *src, int n); MJAPI mjtNum mju_sigmoid(mjtNum x); -//---------------------------------- Signed Distance Function -------------------------------------- +//---------------------------------- Signed Distance Functions ------------------------------------- // get sdf from geom id MJAPI const mjpPlugin* mjc_getSDF(const mjModel* m, int id); @@ -1396,7 +1472,7 @@ MJAPI void mjc_gradient(const mjModel* m, const mjData* d, const mjSDF* s, mjtNu // D: (nsensordata x 2*nv+na) // C: (nsensordata x nu) // Nullable: A, B, C, D -MJAPI void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_centered, +MJAPI void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtBool flg_centered, mjtNum* A, mjtNum* B, mjtNum* C, mjtNum* D); // Finite differenced Jacobians of (force, sensors) = mj_inverse(state, acceleration) @@ -1415,7 +1491,7 @@ MJAPI void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg // optionally computes mass matrix Jacobian DmDq // flg_actuation specifies whether to subtract qfrc_actuator from qfrc_inverse // Nullable: DfDq, DfDv, DfDa, DsDq, DsDv, DsDa, DmDq -MJAPI void mjd_inverseFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_actuation, +MJAPI void mjd_inverseFD(const mjModel* m, mjData* d, mjtNum eps, mjtBool flg_actuation, mjtNum *DfDq, mjtNum *DfDv, mjtNum *DfDa, mjtNum *DsDq, mjtNum *DsDv, mjtNum *DsDa, mjtNum *DmDq); @@ -1456,8 +1532,8 @@ MJAPI const mjpPlugin* mjp_getPluginAtSlot(int slot); MJAPI void mjp_defaultResourceProvider(mjpResourceProvider* provider); // Globally register a resource provider in a thread-safe manner. The provider must have a prefix -// that is not a sub-prefix or super-prefix of any current registered providers. This function -// returns a slot number > 0 on success. +// that is not a sub-prefix or super-prefix of any current registered providers. +// Return a slot number >= 0 on success, -1 on failure. MJAPI int mjp_registerResourceProvider(const mjpResourceProvider* provider); // Return the number of globally registered resource providers. @@ -1483,41 +1559,69 @@ MJAPI void mjp_defaultDecoder(mjpDecoder* decoder); // If no match, return NULL. MJAPI const mjpDecoder* mjp_findDecoder(const mjResource* resource, const char* content_type); -//---------------------------------- Threads ------------------------------------------------------- +// Globally register an encoder. This function is thread-safe. +// If an identical mjpEncoder is already registered, this function does nothing. +// If a non-identical mjpEncoder with the same name is already registered, an mju_error is raised. +MJAPI void mjp_registerEncoder(const mjpEncoder* encoder); + +// Set default resource encoder definition. +MJAPI void mjp_defaultEncoder(mjpEncoder* encoder); + +// Return the encoder that matches against the content type or filename extension. +// If no match, return NULL. +MJAPI const mjpEncoder* mjp_findEncoder(const char* filename, const char* content_type); + -// Create a thread pool with the specified number of threads running. -MJAPI mjThreadPool* mju_threadPoolCreate(size_t number_of_threads); -// Adds a thread pool to mjData and configures it for multi-threaded use. -MJAPI void mju_bindThreadPool(mjData* d, void* thread_pool); +//---------------------------------- Resources ----------------------------------------------------- -// Enqueue a task in a thread pool. -MJAPI void mju_threadPoolEnqueue(mjThreadPool* thread_pool, mjTask* task); +// Open a resource; if the name doesn't have a prefix matching a registered resource provider, +// then the OS filesystem is used. +// Nullable: dir, vfs, error +MJAPI mjResource* mju_openResource(const char* dir, const char* name, + const mjVFS* vfs, char* error, size_t nerror); -// Destroy a thread pool. -MJAPI void mju_threadPoolDestroy(mjThreadPool* thread_pool); +// Close a resource; no-op if resource is NULL. +MJAPI void mju_closeResource(mjResource* resource); -// Initialize an mjTask. -MJAPI void mju_defaultTask(mjTask* task); +// Set buffer to bytes read from the resource and return number of bytes in buffer; +// return negative value if error. +MJAPI int mju_readResource(mjResource* resource, const void** buffer); -// Wait for a task to complete. -MJAPI void mju_taskJoin(mjTask* task); +// For a resource with a name partitioned as {dir}{filename}, get the dir and ndir pointers. +MJAPI void mju_getResourceDir(mjResource* resource, const char** dir, int* ndir); + +// Compare resource timestamp to provided timestamp. +// Return 0 if timestamps match, >0 if resource is newer, <0 if resource is older. +MJAPI int mju_isModifiedResource(const mjResource* resource, const char* timestamp); + +// Find the decoder for a resource and return the decoded spec. +// The caller takes ownership of the spec and is responsible for cleaning it up. +// Nullable: vfs +MJAPI mjSpec* mju_decodeResource(mjResource* resource, const char* content_type, + const mjVFS* vfs); + + +//---------------------------------- Threads ------------------------------------------------------- + +// Create a thread pool with nthread worker threads. +MJAPI void mju_threadpool(mjData* d, int nthread); //---------------------------------- Attachment ---------------------------------------------------- -// Attach child to a parent, return the attached element if success or NULL otherwise. +// Attach child to a parent; return the attached element if success or NULL otherwise. MJAPI mjsElement* mjs_attach(mjsElement* parent, const mjsElement* child, const char* prefix, const char* suffix); //---------------------------------- Tree elements ------------------------------------------------- -// Add child body to body, return child. +// Add child body to body; return child. // Nullable: def MJAPI mjsBody* mjs_addBody(mjsBody* body, const mjsDefault* def); -// Add site to body, return site spec. +// Add site to body; return site spec. // Nullable: def MJAPI mjsSite* mjs_addSite(mjsBody* body, const mjsDefault* def); @@ -1543,7 +1647,7 @@ MJAPI mjsLight* mjs_addLight(mjsBody* body, const mjsDefault* def); // Add frame to body. MJAPI mjsFrame* mjs_addFrame(mjsBody* body, mjsFrame* parentframe); -// Remove object corresponding to the given element, return 0 on success. +// Remove object corresponding to the given element; return 0 on success. MJAPI int mjs_delete(mjSpec* spec, mjsElement* element); @@ -1559,6 +1663,15 @@ MJAPI mjsSensor* mjs_addSensor(mjSpec* s); // Add flex. MJAPI mjsFlex* mjs_addFlex(mjSpec* s); +// Add flexcomp: create flex with auto-generated bodies/joints, return flex spec. +// Nullable: type, dof, count, cellcount, spacing, scale, pos, quat, origin, file, vfs +MJAPI mjsFlex* mjs_makeFlex(mjsBody* body, const char* name, const char* type, int dim, + const char* dof, const int count[3], const int cellcount[3], + const double spacing[3], const double scale[3], double radius, + double mass, double inertiabox, int equality, int rigid, int flatskin, + int elastic2d, const double pos[3], const double quat[4], + const double origin[3], const char* file, const mjVFS* vfs); + // Add contact pair. // Nullable: def MJAPI mjsPair* mjs_addPair(mjSpec* s, const mjsDefault* def); @@ -1608,35 +1721,42 @@ MJAPI mjsDefault* mjs_addDefault(mjSpec* s, const char* classname, const mjsDefa //---------------------------------- Set actuator parameters --------------------------------------- -// Set actuator to motor, return error if any. +// Set actuator to motor; return error if any. MJAPI const char* mjs_setToMotor(mjsActuator* actuator); -// Set actuator to position, return error if any. +// Set actuator to position; return error if any. MJAPI const char* mjs_setToPosition(mjsActuator* actuator, double kp, double kv[1], double dampratio[1], double timeconst[1], double inheritrange); -// Set actuator to integrated velocity, return error if any. +// Set actuator to integrated velocity; return error if any. MJAPI const char* mjs_setToIntVelocity(mjsActuator* actuator, double kp, double kv[1], double dampratio[1], double timeconst[1], double inheritrange); -// Set actuator to velocity servo, return error if any. +// Set actuator to velocity servo; return error if any. MJAPI const char* mjs_setToVelocity(mjsActuator* actuator, double kv); -// Set actuator to activate damper, return error if any. +// Set actuator to activate damper; return error if any. MJAPI const char* mjs_setToDamper(mjsActuator* actuator, double kv); -// Set actuator to hydraulic or pneumatic cylinder, return error if any. +// Set actuator to hydraulic or pneumatic cylinder; return error if any. MJAPI const char* mjs_setToCylinder(mjsActuator* actuator, double timeconst, double bias, double area, double diameter); -// Set actuator to muscle, return error if any.a +// Set actuator to muscle; return error if any.a MJAPI const char* mjs_setToMuscle(mjsActuator* actuator, double timeconst[2], double tausmooth, double range[2], double force, double scale, double lmin, double lmax, double vmax, double fpmax, double fvmax); -// Set actuator to active adhesion, return error if any. +// Set actuator to active adhesion; return error if any. MJAPI const char* mjs_setToAdhesion(mjsActuator* actuator, double gain); +// Set actuator to DC motor; return error if any. +// Nullable: motorconst, nominal, saturation, inductance, cogging, controller, thermal, lugre +MJAPI const char* mjs_setToDCMotor(mjsActuator* actuator, double motorconst[2], double resistance, + double nominal[3], double saturation[3], double inductance[2], + double cogging[3], double controller[6], double thermal[6], + double lugre[5], int input_mode); + //---------------------------------- Assets -------------------------------------------------------- @@ -1663,69 +1783,76 @@ MJAPI int mjs_makeMesh(mjsMesh* mesh, mjtMeshBuiltin builtin, double* params, in //---------------------------------- Find and get utilities ---------------------------------------- // Get spec from body. -MJAPI mjSpec* mjs_getSpec(mjsElement* element); +MJAPI mjSpec* mjs_getSpec(const mjsElement* element); + +// get spec that originally defined an element +// contrary to mjs_getSpec, this does not change after attachment +MJAPI mjSpec* mjs_getOriginSpec(const mjsElement* element); + +// Get compiler associated with element's origin spec. +MJAPI mjsCompiler* mjs_getCompiler(const mjsElement* element); // Find spec (model asset) by name. -MJAPI mjSpec* mjs_findSpec(mjSpec* spec, const char* name); +MJAPI mjSpec* mjs_findSpec(const mjSpec* spec, const char* name); // Find body in spec by name. -MJAPI mjsBody* mjs_findBody(mjSpec* s, const char* name); +MJAPI mjsBody* mjs_findBody(const mjSpec* s, const char* name); // Find element in spec by name. -MJAPI mjsElement* mjs_findElement(mjSpec* s, mjtObj type, const char* name); +MJAPI mjsElement* mjs_findElement(const mjSpec* s, mjtObj type, const char* name); // Find child body by name. -MJAPI mjsBody* mjs_findChild(mjsBody* body, const char* name); +MJAPI mjsBody* mjs_findChild(const mjsBody* body, const char* name); // Get parent body. -MJAPI mjsBody* mjs_getParent(mjsElement* element); +MJAPI mjsBody* mjs_getParent(const mjsElement* element); // Get parent frame. -MJAPI mjsFrame* mjs_getFrame(mjsElement* element); +MJAPI mjsFrame* mjs_getFrame(const mjsElement* element); // Find frame by name. -MJAPI mjsFrame* mjs_findFrame(mjSpec* s, const char* name); +MJAPI mjsFrame* mjs_findFrame(const mjSpec* s, const char* name); // Get default corresponding to an element. -MJAPI mjsDefault* mjs_getDefault(mjsElement* element); +MJAPI mjsDefault* mjs_getDefault(const mjsElement* element); // Find default in model by class name. -MJAPI mjsDefault* mjs_findDefault(mjSpec* s, const char* classname); +MJAPI mjsDefault* mjs_findDefault(const mjSpec* s, const char* classname); // Get global default from model. -MJAPI mjsDefault* mjs_getSpecDefault(mjSpec* s); +MJAPI mjsDefault* mjs_getSpecDefault(const mjSpec* s); // Get element id. -MJAPI int mjs_getId(mjsElement* element); +MJAPI int mjs_getId(const mjsElement* element); // Return body's first child of given type. If recurse is nonzero, also search the body's subtree. -MJAPI mjsElement* mjs_firstChild(mjsBody* body, mjtObj type, int recurse); +MJAPI mjsElement* mjs_firstChild(const mjsBody* body, mjtObj type, int recurse); // Return body's next child of the same type; return NULL if child is last. // If recurse is nonzero, also search the body's subtree. -MJAPI mjsElement* mjs_nextChild(mjsBody* body, mjsElement* child, int recurse); +MJAPI mjsElement* mjs_nextChild(const mjsBody* body, const mjsElement* child, int recurse); // Return spec's first element of selected type. -MJAPI mjsElement* mjs_firstElement(mjSpec* s, mjtObj type); +MJAPI mjsElement* mjs_firstElement(const mjSpec* s, mjtObj type); // Return spec's next element; return NULL if element is last. -MJAPI mjsElement* mjs_nextElement(mjSpec* s, mjsElement* element); +MJAPI mjsElement* mjs_nextElement(const mjSpec* s, const mjsElement* element); // Get wrapped element in tendon path. -MJAPI mjsElement* mjs_getWrapTarget(mjsWrap* wrap); +MJAPI mjsElement* mjs_getWrapTarget(const mjsWrap* wrap); // Get wrapped element side site in tendon path if it has one, nullptr otherwise. -MJAPI mjsSite* mjs_getWrapSideSite(mjsWrap* wrap); +MJAPI mjsSite* mjs_getWrapSideSite(const mjsWrap* wrap); // Get divisor of mjsWrap wrapping a puller. -MJAPI double mjs_getWrapDivisor(mjsWrap* wrap); +MJAPI double mjs_getWrapDivisor(const mjsWrap* wrap); // Get coefficient of mjsWrap wrapping a joint. -MJAPI double mjs_getWrapCoef(mjsWrap* wrap); +MJAPI double mjs_getWrapCoef(const mjsWrap* wrap); //---------------------------------- Attribute setters --------------------------------------------- -// Set element's name, return 0 on success. +// Set element's name; return 0 on success. MJAPI int mjs_setName(mjsElement* element, const char* name); // Copy buffer. @@ -1738,7 +1865,7 @@ MJAPI void mjs_setString(mjString* dest, const char* text); MJAPI void mjs_setStringVec(mjStringVec* dest, const char* text); // Set entry in string vector. -MJAPI mjtByte mjs_setInStringVec(mjStringVec* dest, int i, const char* text); +MJAPI mjtBool mjs_setInStringVec(mjStringVec* dest, int i, const char* text); // Append text entry to string vector. MJAPI void mjs_appendString(mjStringVec* dest, const char* text); @@ -1789,10 +1916,10 @@ MJAPI const void* mjs_getPluginAttributes(const mjsPlugin* plugin); // Set element's default. MJAPI void mjs_setDefault(mjsElement* element, const mjsDefault* def); -// Set element's enclosing frame, return 0 on success. +// Set element's enclosing frame; return 0 on success. MJAPI int mjs_setFrame(mjsElement* dest, mjsFrame* frame); -// Resolve alternative orientations to quat, return error if any. +// Resolve alternative orientations to quat; return error if any. MJAPI const char* mjs_resolveOrientation(double quat[4], mjtByte degree, const char* sequence, const mjsOrientation* orientation);