Implementation:ARISE Initiative Robosuite Controller Factory
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Control |
| Last Updated | 2026-02-15 07:00 GMT |
Overview
Concrete tool for streamlining controller instantiation through factory functions provided by robosuite.
Description
The controller_factory module provides a set of factory functions that simplify the creation of controller instances for different robot parts. Rather than requiring users to import and configure individual controller classes directly, the factory functions accept a controller type name (string) and a parameter dictionary, then return the appropriate fully-configured controller instance. This follows the Factory design pattern to decouple controller selection from instantiation logic.
The module contains a top-level dispatcher function controller_factory() that routes creation requests based on the robot part name (e.g., "right", "left", "right_gripper", "base", "torso", "head", "legs") to specialized factory functions: arm_controller_factory(), gripper_controller_factory(), mobile_base_controller_factory(), torso_controller_factory(), head_controller_factory(), and legs_controller_factory(). Each factory function handles interpolator setup (linear interpolation via LinearInterpolator when configured) and controller-specific parameter wiring.
Additionally, the module includes the load_part_controller_config() utility function for loading controller configurations from JSON files, supporting both custom file paths and built-in default configurations for standard controller types.
Usage
Use the controller factory functions whenever you need to create a controller instance in robosuite. The factory is the recommended entry point for controller creation, as it handles all setup including interpolator configuration and parameter forwarding. The controller_factory() dispatcher is called internally by the robot classes during initialization.
Code Reference
Source Location
- Repository: ARISE_Initiative_Robosuite
- File: robosuite/controllers/parts/controller_factory.py
- Lines: 1-232
Signature
def load_part_controller_config(custom_fpath=None, default_controller=None) -> dict: ...
def arm_controller_factory(name: str, params: dict) -> Controller: ...
def controller_factory(part_name: str, controller_type: str, controller_params: dict) -> Controller: ...
def gripper_controller_factory(name: str, params: dict) -> GripperController: ...
def mobile_base_controller_factory(name: str, params: dict) -> MobileBaseController: ...
def torso_controller_factory(name: str, params: dict) -> Controller: ...
def head_controller_factory(name: str, params: dict) -> Controller: ...
def legs_controller_factory(name: str, params: dict) -> Controller: ...
Import
from robosuite.controllers.parts.controller_factory import controller_factory
from robosuite.controllers.parts.controller_factory import arm_controller_factory
from robosuite.controllers.parts.controller_factory import load_part_controller_config
I/O Contract
Inputs
controller_factory
| Name | Type | Required | Description |
|---|---|---|---|
| part_name | str | Yes | Robot part identifier: "right", "left", "right_gripper", "left_gripper", "base", "torso", "head", or "legs"
|
| controller_type | str | Yes | Controller type name, e.g. "OSC_POSE", "JOINT_POSITION", "IK_POSE", "GRIP", "JOINT_VELOCITY", "JOINT_TORQUE"
|
| controller_params | dict | Yes | Dictionary of parameters to pass to the controller constructor (includes sim, joint_indexes, actuator_range, etc.)
|
arm_controller_factory
| Name | Type | Required | Description |
|---|---|---|---|
| name | str | Yes | One of: "OSC_POSE", "OSC_POSITION", "IK_POSE", "JOINT_VELOCITY", "JOINT_POSITION", "JOINT_TORQUE"
|
| params | dict | Yes | Controller parameters. Must include "interpolation" (str or None), "ndim" (int), "sim", "policy_freq", and "ramp_ratio" for interpolator setup
|
load_part_controller_config
| Name | Type | Required | Description |
|---|---|---|---|
| custom_fpath | str | No | Absolute path to a custom controller JSON config file |
| default_controller | str | No | Name of a default controller to load (e.g. "JOINT_POSITION"). Overrides custom_fpath
|
Outputs
| Name | Type | Description |
|---|---|---|
| controller | Controller (or subclass) | A fully-initialized controller instance ready for use |
| config (from load_part_controller_config) | dict | Loaded controller configuration dictionary from JSON |
Usage Examples
# Using the top-level dispatcher to create an arm controller
from robosuite.controllers.parts.controller_factory import controller_factory
import numpy as np
params = {
"sim": sim,
"ref_name": "gripper0_grip_site",
"joint_indexes": {
"joints": [0, 1, 2, 3, 4, 5, 6],
"qpos": [0, 1, 2, 3, 4, 5, 6],
"qvel": [0, 1, 2, 3, 4, 5, 6],
},
"actuator_range": (np.array([-87]*7), np.array([87]*7)),
"policy_freq": 20,
"ndim": 7,
"interpolation": "linear",
"ramp_ratio": 0.2,
}
# Create an OSC controller for the right arm
osc_controller = controller_factory("right", "OSC_POSE", params)
# Create a gripper controller
gripper_params = {
"sim": sim,
"joint_indexes": {
"joints": [7, 8],
"actuators": [7, 8],
"qpos": [7, 8],
"qvel": [7, 8],
},
"actuator_range": (np.array([-1, -1]), np.array([1, 1])),
}
grip_controller = controller_factory("right_gripper", "GRIP", gripper_params)
# Load a default controller configuration from file
from robosuite.controllers.parts.controller_factory import load_part_controller_config
config = load_part_controller_config(default_controller="OSC_POSE")
Related Pages
- Principle:ARISE_Initiative_Robosuite_Controller_Factory_Pattern
- Environment:ARISE_Initiative_Robosuite_MuJoCo_Python
- Implementation:ARISE_Initiative_Robosuite_Controller_Base
- Implementation:ARISE_Initiative_Robosuite_OperationalSpaceController
- Implementation:ARISE_Initiative_Robosuite_IKController
- Implementation:ARISE_Initiative_Robosuite_JointPositionController
- Implementation:ARISE_Initiative_Robosuite_JointVelocityController
- Implementation:ARISE_Initiative_Robosuite_JointTorqueController
- Implementation:ARISE_Initiative_Robosuite_SimpleGripController
- Implementation:ARISE_Initiative_Robosuite_MobileBaseVelocityController