MjModel

Struct MjModel 

Source
pub struct MjModel(/* private fields */);
Expand description

A Rust-safe wrapper around mjModel. Automatically clean after itself on destruction.

Implementations§

Source§

impl MjModel

Source

pub fn from_xml<T: AsRef<Path>>(path: T) -> Result<Self, Error>

Loads the model from an XML file. To load from a virtual file system, use MjModel::from_xml_vfs.

Source

pub fn from_xml_vfs<T: AsRef<Path>>(path: T, vfs: &MjVfs) -> Result<Self, Error>

Loads the model from an XML file, located in a virtual file system (vfs).

Source

pub fn from_xml_string(data: &str) -> Result<Self, Error>

Loads the model from an XML string.

Source

pub fn from_buffer(data: &[u8]) -> Result<Self, Error>

Loads the model from MJB raw data.

Source

pub fn save_last_xml(&self, filename: &str) -> Result<()>

Saves the last XML loaded.

Source

pub fn make_data<'m>(&'m self) -> MjData<'m>

Creates a new MjData instances linked to this model.

Source

pub fn actuator(&self, name: &str) -> Option<MjActuatorModelInfo>

Obtains a MjActuatorModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjActuatorModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn sensor(&self, name: &str) -> Option<MjSensorModelInfo>

Obtains a MjSensorModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjSensorModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn tendon(&self, name: &str) -> Option<MjTendonModelInfo>

Obtains a MjTendonModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjTendonModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn joint(&self, name: &str) -> Option<MjJointModelInfo>

Obtains a MjJointModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjJointModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn geom(&self, name: &str) -> Option<MjGeomModelInfo>

Obtains a MjGeomModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjGeomModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn body(&self, name: &str) -> Option<MjBodyModelInfo>

Obtains a MjBodyModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjBodyModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn camera(&self, name: &str) -> Option<MjCameraModelInfo>

Obtains a MjCameraModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjCameraModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn key(&self, name: &str) -> Option<MjKeyModelInfo>

Obtains a MjKeyModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjKeyModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn tuple(&self, name: &str) -> Option<MjTupleModelInfo>

Obtains a MjTupleModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjTupleModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn texture(&self, name: &str) -> Option<MjTextureModelInfo>

Obtains a MjTextureModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjTextureModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn site(&self, name: &str) -> Option<MjSiteModelInfo>

Obtains a MjSiteModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjSiteModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn pair(&self, name: &str) -> Option<MjPairModelInfo>

Obtains a MjPairModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjPairModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn numeric(&self, name: &str) -> Option<MjNumericModelInfo>

Obtains a MjNumericModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjNumericModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn material(&self, name: &str) -> Option<MjMaterialModelInfo>

Obtains a MjMaterialModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjMaterialModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn light(&self, name: &str) -> Option<MjLightModelInfo>

Obtains a MjLightModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjLightModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn equality(&self, name: &str) -> Option<MjEqualityModelInfo>

Obtains a MjEqualityModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjEqualityModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn hfield(&self, name: &str) -> Option<MjHfieldModelInfo>

Obtains a MjHfieldModelInfo struct containing information about the name, id, and indices required for obtaining references to the correct locations in MjModel. The actual view can be obtained via MjHfieldModelInfo::view.

§Panics

A panic will occur if name contains \0 characters.

Source

pub fn name2id(&self, type_: MjtObj, name: &str) -> i32

👎Deprecated

Deprecated alias for MjModel::name_to_id.

Source

pub fn name_to_id(&self, type_: MjtObj, name: &str) -> i32

Translates name to the correct id. Wrapper around mj_name2id.

§Panics

When the name contains ‘\0’ characters, a panic occurs.

Source

pub fn clone(&self) -> Option<MjModel>

Clones the model.

Source

pub fn save(&self, filename: Option<&str>, buffer: Option<&mut [u8]>)

Save model to binary MJB file or memory buffer; buffer has precedence when given.

§Panics

When the filename contains ‘\0’ characters, a panic occurs.

Source

pub fn size(&self) -> c_int

Return size of buffer needed to hold model.

Source

pub fn print_formatted( &self, filename: &str, float_format: &str, ) -> Result<(), NulError>

Print mjModel to text file, specifying format. float_format must be a valid printf-style format string for a single float value.

Source

pub fn print(&self, filename: &str) -> Result<(), NulError>

Print model to text file.

Source

pub fn state_size(&self, spec: c_uint) -> c_int

Return size of state specification. The bits of the integer spec correspond to element fields of MjtState.

Source

pub fn is_pyramidal(&self) -> bool

Determine type of friction cone.

Source

pub fn is_sparse(&self) -> bool

Determine type of constraint Jacobian.

Source

pub fn is_dual(&self) -> bool

Determine type of solver (PGS is dual, CG and Newton are primal).

Source

pub fn id_to_name(&self, type_: MjtObj, id: c_int) -> Option<&str>

Get name of object with the specified MjtObj type and id, returns NULL if name not found. Wraps mj_id2name.

Source

pub fn get_totalmass(&self) -> MjtNum

Sum all body masses.

Source

pub fn set_totalmass(&mut self, newmass: MjtNum)

Scale body masses and inertias to achieve specified total mass.

Source

pub fn ffi(&self) -> &mjModel

Returns a reference to the wrapped FFI struct.

Source

pub unsafe fn ffi_mut(&mut self) -> &mut mjModel

Returns a mutable reference to the wrapped FFI struct.

Source§

impl MjModel

Public attribute methods.

Source

pub fn signature(&self) -> u64

Compilation signature.

Source

pub fn opt(&self) -> &MjOption

An immutable reference to physics options.

Source

pub fn opt_mut(&mut self) -> &mut MjOption

A mutable reference to physics options.

Source

pub fn vis(&self) -> &MjVisual

An immutable reference to visualization options.

Source

pub fn vis_mut(&mut self) -> &mut MjVisual

A mutable reference to visualization options.

Source

pub fn stat(&self) -> &MjStatistic

An immmutable reference to model statistics.

Source

pub fn stat_mut(&mut self) -> &mut MjStatistic

A mutable reference to model statistics.

Trait Implementations§

Source§

impl Debug for MjModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for MjModel

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for MjModel

Source§

impl Sync for MjModel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.