use crate::helper::{Dimention, FrictionDimention};
pub fn mju_muscleGain(
len: f64,
vel: f64,
lengthrange: [f64; 2],
acc0: f64,
prm: [f64; 9],
) -> f64 {
unsafe {
crate::bindgen::mju_muscleGain(
len,
vel,
&lengthrange,
acc0,
&prm,
)
}
}
pub fn mju_muscleBias(
len: f64,
lengthrange: [f64; 2],
acc0: f64,
prm: [f64; 9],
) -> f64 {
unsafe {
crate::bindgen::mju_muscleBias(len, &lengthrange, acc0, &prm)
}
}
pub fn mju_muscleDynamics(ctrl: f64, act: f64, prm: [f64; 3]) -> f64 {
unsafe { crate::bindgen::mju_muscleDynamics(ctrl, act, &prm) }
}
pub fn mju_encodePyramid<const MU_DIM: usize>(
force: [f64; 3],
mu: [f64; MU_DIM],
) -> [f64; 3]
where
Dimention<MU_DIM>: FrictionDimention,
{
let mut pyramid = [0.0; 3];
unsafe {
crate::bindgen::mju_encodePyramid(
pyramid.as_mut_ptr(),
force.as_ptr(),
mu.as_ptr(),
MU_DIM as i32,
);
}
pyramid
}
pub fn mju_decodePyramid<const MU_DIM: usize>(
pyramid: [f64; 3],
mu: [f64; MU_DIM],
) -> [f64; 3]
where
Dimention<MU_DIM>: FrictionDimention,
{
let mut force = [0.0; 3];
unsafe {
crate::bindgen::mju_decodePyramid(
force.as_mut_ptr(),
pyramid.as_ptr(),
mu.as_ptr(),
MU_DIM as i32,
);
}
force
}
pub fn mju_springDamper(pos0: f64, vel0: f64, Kp: f64, Kv: f64, dt: f64) -> f64 {
unsafe { crate::bindgen::mju_springDamper(pos0, vel0, Kp, Kv, dt) }
}
pub fn mju_writeNumBytes(nbytes: usize) -> String {
let c_ptr = unsafe { crate::bindgen::mju_writeNumBytes(nbytes) };
#[cfg(debug_assertions)] {
assert!(!c_ptr.is_null(), "`mju_writeNumBytes` unexpectedly returned a null pointer");
}
unsafe { std::ffi::CStr::from_ptr(c_ptr).to_str().unwrap().to_owned() }
}
pub fn mju_warningText(warning: crate::bindgen::mjtWarning, info: usize) -> String {
let c_ptr = unsafe { crate::bindgen::mju_warningText(warning.0 as i32, info) };
#[cfg(debug_assertions)] {
assert!(!c_ptr.is_null(), "`mju_warningText` unexpectedly returned a null pointer");
}
unsafe { std::ffi::CStr::from_ptr(c_ptr).to_str().unwrap().to_owned() }
}
pub fn mju_isBad(x: f64) -> bool {
unsafe { crate::bindgen::mju_isBad(x) != 0 }
}
pub fn mju_Halton(index: usize, base: usize) -> f64 {
unsafe { crate::bindgen::mju_Halton(index as i32, base as i32) }
}
pub fn mju_sigmoid(x: f64) -> f64 {
unsafe { crate::bindgen::mju_sigmoid(x) }
}