Object Model

The MujocoObject class serves as a catch-all base class that is used to capture individual simulation objects to instantiate within a given simulation. This is done in one of two ways via extended classes – the MujocoXMLObject reads in information from a corresponding object XML file, whereas the MujocoGeneratedObject proecedurally generates a custom object using a suite of utility mj modeling functions. In conjunction with the RobotModel, GripperModel, and Arena classes, these classes serve as the basis for forming the higher level ManipulationTask class which is used to ultimately generate the MjSim simulation object.

Base Object Model

class robosuite.models.objects.objects.MujocoObject

Base class for all objects.

We use Mujoco Objects to implement all objects that:

  1. may appear for multiple times in a task

  2. can be swapped between different tasks

Typical methods return copy so the caller can all joints/attributes as wanted

get_bottom_offset()

Returns vector from object center to object bottom. Helps us put objects on a surface. Must be defined by subclass.

Returns

(dx, dy, dz) vector, eg. np.array([0, 0, -2])

Return type

np.array

get_top_offset()

Returns vector from object center to object top. Helps us put other objects on this object. Must be defined by subclass.

Returns

(dx, dy, dz) vector, eg. np.array([0, 0, 2])

Return type

np.array

get_horizontal_radius()

Returns scalar If object a,b has horizontal distance d a.get_horizontal_radius() + b.get_horizontal_radius() < d should mean that a, b has no contact

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

Returns

radius

Return type

float

get_collision(site=False)

Returns a ET.Element It is a <body/> subtree that defines all collision related fields of this object. Return should be a copy. Must be defined by subclass.

Parameters

site (bool) – Add a site (with name @name when applicable) to the returned body

Returns

body

Return type

ET.Element

get_visual(site=False)

Returns a ET.Element It is a <body/> subtree that defines all visualization related fields of this object. Return should be a copy. Must be defined by subclass.

Parameters

site (bool) – Add a site (with name @name when applicable) to the returned body

Returns

body

Return type

ET.Element

static get_site_attrib_template()

Returns attribs of spherical site used to mark body origin

Returns

Dictionary of default site attributes

Return type

dict

XML Object Model

class robosuite.models.objects.objects.MujocoXMLObject(fname, name=None, joints=None)

MujocoObjects that are loaded from xml files

Parameters
  • fname (str) – XML File path

  • name (None or str) – Name of this MujocoXMLObject

  • joints (list of dict) – each dictionary corresponds to a joint that will be created for this object. The dictionary should specify the joint attributes (type, pos, etc.) according to the MuJoCo xml specification.

Generated Object Model

class robosuite.models.objects.objects.MujocoGeneratedObject(name, size=None, rgba=None, density=None, friction=None, solref=None, solimp=None, material=None, joints=None)

Base class for all programmatically generated mujoco object i.e., every MujocoObject that does not have an corresponding xml file

Parameters
  • name (str) – (unique) name to identify this generated object

  • size (n-tuple of float) – relevant size parameters for the object, should be of size 1 - 3

  • rgba (4-tuple of float) – Color

  • density (float) – Density

  • friction (3-tuple of float) – (sliding friction, torsional friction, and rolling friction). A single float can also be specified, in order to set the sliding friction (the other values) will be set to the MuJoCo default. See http://www.mujoco.org/book/modeling.html#geom for details.

  • solref (2-tuple of float) – MuJoCo solver parameters that handle contact. See http://www.mujoco.org/book/XMLreference.html for more details.

  • solimp (3-tuple of float) – MuJoCo solver parameters that handle contact. See http://www.mujoco.org/book/XMLreference.html for more details.

  • material (CustomMaterial or ‘default’ or None) –

    if “default”, add a template material and texture for this object that is used to color the geom(s). Otherwise, input is expected to be a CustomMaterial object

    See http://www.mujoco.org/book/XMLreference.html#asset for specific details on attributes expected for Mujoco texture / material tags, respectively

    Note that specifying a custom texture in this way automatically overrides any rgba values set

  • joints (list of dict) – each dictionary corresponds to a joint that will be created for this object. The dictionary should specify the joint attributes (type, pos, etc.) according to the MuJoCo xml specification.

sanity_check()

Checks if data provided makes sense. Called in __init__() For subclasses to inherit from

static get_collision_attrib_template()

Generates template with collision attributes for a given geom

Returns

Initial template with ‘pos’ and ‘group’ already specified

Return type

dict

static get_visual_attrib_template()

Generates template with visual attributes for a given geom

Returns

Initial template with ‘conaffinity’, ‘contype’, and ‘group’ already specified

Return type

dict

append_material(material)

Adds a new texture / material combination to the assets subtree of this XML Input is expected to be a CustomMaterial object

See http://www.mujoco.org/book/XMLreference.html#asset for specific details on attributes expected for Mujoco texture / material tags, respectively

Note that the “file” attribute for the “texture” tag should be specified relative to the textures directory located in robosuite/models/assets/textures/

Parameters

material (CustomMaterial) – Material to add to this object