robosuite.models package#

Subpackages#

Submodules#

robosuite.models.base module#

class robosuite.models.base.MujocoModel#

Bases: object

Base class for all simulation models used in mujoco.

Standardizes core API for accessing models’ relevant geoms, names, etc.

property actuators#

Returns: list: Actuator names for this model

property bodies#

Returns: list: Body names for this model

property bottom_offset#

Returns vector from model root body to model bottom. Useful for, e.g. placing models on a surface. Must be defined by subclass.

Returns:

(dx, dy, dz) offset vector

Return type:

np.array

property contact_geoms#

List of names corresponding to the geoms used to determine contact with this model.

Returns:

relevant contact geoms for this model

Return type:

list

correct_naming(names)#

Corrects all strings in @names by adding the naming prefix to it and returns the name-corrected values

Parameters:

names (str, list, or dict) – Name(s) to be corrected

Raises:

TypeError – [Invalid input type]

exclude_from_prefixing(inp)#

A function that should take in an arbitrary input and return either True or False, determining whether the corresponding name to @inp should have naming_prefix added to it. Must be defined by subclass.

Parameters:

inp (any) – Arbitrary input, depending on subclass. Can be str, ET.Element, etc.

Returns:

True if we should exclude the associated name(s) with @inp from being prefixed with naming_prefix

Return type:

bool

property horizontal_radius#

Returns maximum distance from model root body to any radial point of the model.

Helps us put models programmatically without them flying away due to a huge initial contact force. Must be defined by subclass.

Returns:

radius

Return type:

float

property important_geoms#

Geoms corresponding to important components of this model. String keywords should be mapped to lists of geoms.

Returns:

Important set of geoms, where each set of geoms are grouped as a list and are organized by keyword string entries into a dict

Return type:

dict of list

property important_sensors#

Dict of important sensors enabled for this model.

Returns:

Important sensors for this model, where each specific sensor name is mapped from keyword string

entries in the dict

Return type:

dict

property important_sites#

used to aid visualization during sim).

Returns:

Important site geoms, where each specific geom name is mapped from keyword string entries

in the dict

Return type:

dict

Type:

Dict of sites corresponding to the important site geoms (e.g.

property joints#

Returns: list: Joint names for this model

property name#

Name for this model. Should be unique.

Returns:

Unique name for this model.

Return type:

str

property naming_prefix#

Generates a standardized prefix to prevent naming collisions

Returns:

Prefix unique to this model.

Return type:

str

property root_body#

Root body name for this model. This should correspond to the top-level body element in the equivalent mujoco xml tree for this object.

property sensors#

Returns: list: Sensor names for this model

set_sites_visibility(sim, visible)#

Set all site visual states for this model.

Parameters:
  • sim (MjSim) – Current active mujoco simulation instance

  • visible (bool) – If True, will visualize model sites. Else, will hide the sites.

property sites#

Returns: list: Site names for this model

property top_offset#

Returns vector from model root body to model top. Useful for, e.g. placing models on a surface. Must be defined by subclass.

Returns:

(dx, dy, dz) offset vector

Return type:

np.array

property visual_geoms#

List of names corresponding to the geoms used for visual rendering of this model.

Returns:

relevant visual geoms for this model

Return type:

list

class robosuite.models.base.MujocoXML(fname)#

Bases: object

Base class of Mujoco xml file Wraps around ElementTree and provides additional functionality for merging different models. Specially, we keep track of <worldbody/>, <actuator/> and <asset/>

When initialized, loads a mujoco xml from file.

Parameters:

fname (str) – path to the MJCF xml file.

create_default_element(name)#

Creates a <@name/> tag under root if there is none.

Parameters:

name (str) – Name to generate default element

Returns:

Node that was created

Return type:

ET.Element

get_element_names(root, element_type)#

Searches recursively through the @root and returns a list of names of the specified @element_type

Parameters:
  • root (ET.Element) – Root of the xml element tree to start recursively searching through (e.g.: self.worldbody)

  • element_type (str) – Name of element to return names of. (e.g.: “site”, “geom”, etc.)

Returns:

names that correspond to the specified @element_type

Return type:

list

get_model(mode='mujoco')#

Generates a MjModel instance from the current xml tree.

Parameters:

mode (str) – Mode with which to interpret xml tree

Returns:

generated model from xml

Return type:

MjModel

Raises:

ValueError – [Invalid mode]

get_xml()#

Reads a string of the MJCF XML file.

Returns:

XML tree read in from file

Return type:

str

merge(others, merge_body='default')#

Default merge method.

Parameters:
  • others (MujocoXML or list of MujocoXML) – other xmls to merge into this one raises XML error if @others is not a MujocoXML instance. merges <worldbody/>, <actuator/> and <asset/> of @others into @self

  • merge_body (None or str) – If set, will merge child bodies of @others. Default is “default”, which corresponds to the root worldbody for this XML. Otherwise, should be an existing body name that exists in this XML. None results in no merging of @other’s bodies in its worldbody.

Raises:

XMLError – [Invalid XML instance]

merge_assets(other)#

Merges @other’s assets in a custom logic.

Parameters:

other (MujocoXML or MujocoObject) – other xml file whose assets will be merged into this one

property name#

Returns name of this MujocoXML

Returns:

Name of this MujocoXML

Return type:

str

resolve_asset_dependency()#

Converts every file dependency into absolute path so when we merge we don’t break things.

save_model(fname, pretty=False)#

Saves the xml to file.

Parameters:
  • fname (str) – output file location

  • pretty (bool) – If True, (attempts!! to) pretty print the output

class robosuite.models.base.MujocoXMLModel(fname, idn=0)#

Bases: MujocoXML, MujocoModel

Base class for all MujocoModels that are based on a raw XML file.

Parameters:
  • fname (str) – Path to relevant xml file from which to create this robot instance

  • idn (int or str) – Number or some other unique identification string for this model instance

property actuators#

Returns: list: Actuator names for this model

property base_offset#

Provides position offset of root body.

Returns:

(x,y,z) pos value of root_body body element. If no pos in element, returns all zeros.

Return type:

3-array

property bodies#

Returns: list: Body names for this model

property bottom_offset#

Returns vector from model root body to model bottom. Useful for, e.g. placing models on a surface. By default, this corresponds to the root_body’s base offset.

Returns:

(dx, dy, dz) offset vector

Return type:

np.array

property contact_geom_rgba#

RGBA color to assign to all contact geoms for this model

Returns:

(r,g,b,a) values from 0 to 1 for this model’s set of contact geoms

Return type:

4-array

property contact_geoms#

List of names corresponding to the geoms used to determine contact with this model.

Returns:

relevant contact geoms for this model

Return type:

list

exclude_from_prefixing(inp)#

By default, don’t exclude any from being prefixed

property horizontal_radius#

Returns maximum distance from model root body to any radial point of the model.

Helps us put models programmatically without them flying away due to a huge initial contact force. Must be defined by subclass.

Returns:

radius

Return type:

float

property important_geoms#

Geoms corresponding to important components of this model. String keywords should be mapped to lists of geoms.

Returns:

Important set of geoms, where each set of geoms are grouped as a list and are organized by keyword string entries into a dict

Return type:

dict of list

property important_sensors#

Dict of important sensors enabled for this model.

Returns:

Important sensors for this model, where each specific sensor name is mapped from keyword string

entries in the dict

Return type:

dict

property important_sites#

used to aid visualization during sim).

Returns:

Important site geoms, where each specific geom name is mapped from keyword string entries

in the dict

Return type:

dict

Type:

Dict of sites corresponding to the important site geoms (e.g.

property joints#

Returns: list: Joint names for this model

property name#

Returns name of this MujocoXML

Returns:

Name of this MujocoXML

Return type:

str

property naming_prefix#

Generates a standardized prefix to prevent naming collisions

Returns:

Prefix unique to this model.

Return type:

str

property root_body#

Root body name for this model. This should correspond to the top-level body element in the equivalent mujoco xml tree for this object.

property sensors#

Returns: list: Sensor names for this model

property sites#

Returns: list: Site names for this model

property top_offset#

Returns vector from model root body to model top. Useful for, e.g. placing models on a surface. Must be defined by subclass.

Returns:

(dx, dy, dz) offset vector

Return type:

np.array

property visual_geoms#

List of names corresponding to the geoms used for visual rendering of this model.

Returns:

relevant visual geoms for this model

Return type:

list

robosuite.models.world module#

class robosuite.models.world.MujocoWorldBase#

Bases: MujocoXML

Base class to inherit all mujoco worlds from.

Module contents#