Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:ARISE Initiative Robosuite GripperController Base

From Leeroopedia
Knowledge Sources
Domains Robotics, Control
Last Updated 2026-02-15 07:00 GMT

Overview

Concrete tool for defining the abstract base interface for all gripper controllers provided by robosuite.

Description

The GripperController class is the abstract base class for all gripper controllers in the robosuite framework. It mirrors the structure of the arm Controller base class but is specialized for gripper hardware, which typically has different joint semantics (including actuator indexes separate from joint indexes). The class uses Python's abc.ABCMeta metaclass to enforce implementation of the run_controller() method in subclasses.

At initialization, the controller stores references to the MuJoCo simulator, joint/actuator index mappings, and actuator range limits. It manages joint state (position and velocity), provides action scaling through input/output range mapping, and includes utility methods for torque clipping and numeric array conversion. Unlike the arm Controller base class, the GripperController does not track end-effector pose, Jacobians, or mass matrices since gripper control operates purely in joint space. It does, however, track a previous_qpos attribute for detecting gripper state changes.

The update() method refreshes joint position and velocity state from the simulator, with the same new_update flag mechanism as other controllers to prevent redundant computation. Properties for gravity compensation, actuator limits, and control limits are provided for consistency with the arm controller interface.

Usage

Use the GripperController as the parent class when implementing new gripper control strategies in robosuite. It should not be instantiated directly. The primary concrete subclass is SimpleGripController, which implements naive gripping behavior where all fingers move in the same direction.

Code Reference

Source Location

Signature

class GripperController(object, metaclass=abc.ABCMeta):
    def __init__(
        self,
        sim,
        joint_indexes,
        actuator_range,
        part_name=None,
        naming_prefix=None,
    ): ...

    @abc.abstractmethod
    def run_controller(self): ...

    def scale_action(self, action) -> np.array: ...
    def update(self, force=False): ...
    def update_initial_joints(self, initial_joints): ...
    def clip_torques(self, torques) -> np.array: ...
    def reset_goal(self): ...

    @staticmethod
    def nums2array(nums, dim) -> np.array: ...

    @property
    def torque_compensation(self) -> np.array: ...

    @property
    def actuator_limits(self) -> tuple: ...

    @property
    def control_limits(self) -> tuple: ...

    @property
    def name(self) -> str: ...

Import

from robosuite.controllers.parts.gripper.gripper_controller import GripperController

I/O Contract

Inputs

Name Type Required Description
sim MjSim Yes MuJoCo simulator instance for pulling robot state
joint_indexes dict Yes Dictionary with keys 'joints', 'actuators', 'qpos', 'qvel' containing index lists. Note the additional 'actuators' key compared to the arm controller
actuator_range 2-tuple of array Yes (low, high) arrays defining actuator command limits
part_name str No Name of the gripper part (e.g., "right_gripper")
naming_prefix str No Prefix for multi-robot naming

Outputs

Name Type Description
torques np.array Joint torques or actuator commands computed by the subclass controller
joint_pos np.array Current gripper joint positions
joint_vel np.array Current gripper joint velocities
torque_compensation np.array Gravity compensation torques from MuJoCo bias forces
actuator_limits tuple(np.array, np.array) (min, max) actuator command limits
control_limits tuple(np.array, np.array) (min, max) action input limits

Usage Examples

# The GripperController is abstract and cannot be instantiated directly.
# Use the SimpleGripController subclass instead:

from robosuite.controllers.parts.gripper.gripper_controller import GripperController
import numpy as np
import abc

class MyGripperController(GripperController):
    def __init__(self, sim, joint_indexes, actuator_range, **kwargs):
        super().__init__(
            sim=sim,
            joint_indexes=joint_indexes,
            actuator_range=actuator_range,
        )
        self.control_dim = len(joint_indexes["actuators"])
        self.input_max = np.ones(self.control_dim)
        self.input_min = -np.ones(self.control_dim)
        self.output_max = np.ones(self.control_dim)
        self.output_min = -np.ones(self.control_dim)

    def set_goal(self, action):
        self.update()
        self.goal = self.scale_action(action)

    def run_controller(self):
        self.update()
        self.torques = np.zeros(self.control_dim)
        super().run_controller()
        return self.torques

    def reset_goal(self):
        pass

    @property
    def name(self):
        return "MY_GRIPPER"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment