Implementation:ARISE Initiative Robosuite RobotModel
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, MJCF_Modeling |
| Last Updated | 2026-02-15 07:00 GMT |
Overview
RobotModel is the base class for all robot models in robosuite, providing base/mount management, joint attribute configuration, position/orientation setting, and an auto-registration metaclass system for robot discovery.
Description
The RobotModel class extends MujocoXMLModel and uses the RobotModelMeta metaclass to automatically register all concrete robot subclasses (excluding RobotModel and ManipulatorModel themselves) into a global REGISTERED_ROBOTS dictionary. This enables robot instantiation by name via the module-level create_robot() function, which looks up the registry and forwards constructor arguments.
On initialization, the class sets default joint attributes including frictionloss (0.1), damping (0.1), and armature (scaled inversely by joint index: 5.0/(i+1)) for all joints, only applying these if no value is already specified in the XML (force=False). The set_joint_attribute() method allows setting any joint attribute across all joints, with an option to force-override existing values.
The class supports multiple base types through add_base(), which dispatches to specialized methods depending on the base type: MountModel (fixed mount), MobileBaseModel (wheeled base), LegBaseModel (legged base), or NullBaseModel (no base). Each base type has a distinct merging strategy. Mount models are simply merged into the root body with an offset. Mobile bases restructure the XML hierarchy by creating an intermediate "manipulator_mount" body and moving the arm into the mobile base's support body. Leg bases similarly reparent the arm under the leg base's support structure. The bottom_offset and horizontal_radius properties account for the attached base model's geometry.
The naming_prefix follows the pattern "robot{idn}_", and the contact_geom_rgba uses the standard ROBOT_COLLISION_COLOR. Subclasses must implement abstract properties: default_base, default_controller_config, init_qpos, base_xpos_offset, top_offset, and _horizontal_radius.
Usage
Use RobotModel as the base class for any new robot type. In practice, most robots extend ManipulatorModel (which extends RobotModel) for arm-based robots. Use create_robot() to instantiate robots by name without importing specific classes. Use set_base_xpos() and set_base_ori() to position and orient the robot in the arena.
Code Reference
Source Location
- Repository: ARISE_Initiative_Robosuite
- File: robosuite/models/robots/robot_model.py
Signature
class RobotModelMeta(type):
"""Metaclass for registering robot arms"""
def __new__(meta, name, bases, class_dict)
class RobotModel(MujocoXMLModel, metaclass=RobotModelMeta):
def __init__(self, fname: str, idn=0)
def register_robot(target_class)
def create_robot(robot_name, *args, **kwargs)
Import
from robosuite.models.robots.robot_model import RobotModel, create_robot, REGISTERED_ROBOTS
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| fname | str | Yes | Path to the robot's MJCF XML file |
| idn | int or str | No | Unique identification number or string. Default: 0 |
Outputs
| Name | Type | Description |
|---|---|---|
| naming_prefix | str | "robot{idn}_" prefix for all elements |
| dof | int | Number of degrees of freedom (count of joints) |
| bottom_offset | np.array | Vector from root body to model bottom (accounts for base) |
| horizontal_radius | float | Maximum radial distance (accounts for base) |
| cameras | list of str | Camera names in the robot's worldbody |
| models | list | Sub-models owned by this robot (base model if attached) |
| contact_geom_rgba | list | ROBOT_COLLISION_COLOR RGBA values |
| all_joints | list | All joints including base joints |
| all_actuators | list | All actuators including base actuators |
Key Methods
| Method | Description |
|---|---|
| set_base_xpos(pos) | Places the robot at (x, y, z) position, accounting for bottom_offset |
| set_base_ori(rot) | Rotates the robot by (r, p, y) euler angles |
| set_joint_attribute(attrib, values, force) | Sets a named attribute for all joints |
| add_base(base) | Attaches a base model (MountModel, MobileBaseModel, LegBaseModel, or NullBaseModel) |
| set_mujoco_model(mujoco_model) | Sets or creates the MjModel instance for the robot |
Usage Examples
from robosuite.models.robots.robot_model import create_robot, REGISTERED_ROBOTS
import numpy as np
# List all registered robots
print("Available robots:", list(REGISTERED_ROBOTS.keys()))
# Create a robot by name
robot = create_robot("Panda", idn=0)
# Position the robot in the arena
robot.set_base_xpos(np.array([0.0, 0.0, 0.0]))
robot.set_base_ori(np.array([0.0, 0.0, 0.0]))
# Set joint damping values
robot.set_joint_attribute(
attrib="damping",
values=np.ones(robot.dof) * 0.5,
force=True,
)
# Add a mount base
from robosuite.models.bases import RethinkMount
mount = RethinkMount()
robot.add_base(mount)
# Access robot properties
print("DOF:", robot.dof)
print("Naming prefix:", robot.naming_prefix)
print("Bottom offset:", robot.bottom_offset)
print("All joints:", robot.all_joints)
print("All actuators:", robot.all_actuators)