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 JointTorqueController

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

Overview

Concrete tool for direct joint torque control of a robot arm provided by robosuite.

Description

The JointTorqueController class implements the simplest form of robot control in robosuite: direct torque passthrough. Since the MuJoCo actuators are already torque actuators, this controller essentially scales, clips, and forwards desired torque commands to the joints, adding gravity compensation when enabled. It extends the abstract Controller base class.

The controller accepts torque commands as input actions, scales them through the configurable input/output range mapping, and clips the result to the specified torque limits (which default to the actuator limits if not explicitly provided). Gravity compensation torques from MuJoCo's bias forces are optionally added to the final output. An interpolator can be used to smooth transitions between successive torque setpoints, though only linear interpolation is currently supported.

Unlike the position or velocity controllers, the torque controller does not use impedance gains (kp/kd) since it operates at the torque level directly. The reset_goal() method sets the goal torque to all zeros (pre-compensation), which means the robot will simply maintain its pose against gravity when compensation is enabled.

Usage

Use the JointTorqueController when you need the most direct and low-level control over the robot's joints. It is appropriate for learning-based approaches that output raw torque commands, or for implementing custom control laws outside of the robosuite controller framework. Instantiate via the controller factory with the name "JOINT_TORQUE".

Code Reference

Source Location

Signature

class JointTorqueController(Controller):
    def __init__(
        self,
        sim,
        joint_indexes,
        actuator_range,
        ref_name=None,
        input_max=1,
        input_min=-1,
        output_max=0.05,
        output_min=-0.05,
        policy_freq=20,
        lite_physics=True,
        torque_limits=None,
        interpolator=None,
        **kwargs,
    ): ...

    def set_goal(self, torques): ...
    def run_controller(self) -> np.array: ...
    def reset_goal(self): ...

    @property
    def name(self) -> str: ...  # Returns "JOINT_TORQUE"

Import

from robosuite.controllers.parts.generic.joint_tor import JointTorqueController

I/O Contract

Inputs

Name Type Required Description
sim MjSim Yes MuJoCo simulator instance for reading robot state
joint_indexes dict Yes Dictionary with keys 'joints', 'qpos', 'qvel' containing index lists
actuator_range 2-tuple of array Yes (low, high) actuator torque limits
ref_name str No End effector reference site name (optional)
input_max float or list No Maximum input action clipping value (default: 1)
input_min float or list No Minimum input action clipping value (default: -1)
output_max float or list No Maximum scaled output torque (default: 0.05)
output_min float or list No Minimum scaled output torque (default: -0.05)
policy_freq int No Policy action frequency in Hz (default: 20)
lite_physics bool No Whether to optimize MuJoCo forward calls (default: True)
torque_limits 2-list or None No Explicit torque limits. If None, defaults to actuator limits
interpolator Interpolator No Interpolator for smooth torque transitions between actions

Outputs

Name Type Description
torques np.array Final joint torques including optional gravity compensation
current_torque np.array Pre-compensation torque command (the interpolated or direct goal torque)
goal_torque np.array Desired torque setpoint after scaling and clipping
name str Controller identifier: "JOINT_TORQUE"

Usage Examples

# Typical usage via the controller factory
from robosuite.controllers.parts.controller_factory import arm_controller_factory
import numpy as np

controller_params = {
    "sim": sim,
    "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": None,
    "ramp_ratio": 0.2,
}

controller = arm_controller_factory("JOINT_TORQUE", controller_params)

# Command specific torques to each joint
action = np.array([0.1, -0.1, 0.05, 0.0, 0.0, 0.0, 0.0])
controller.set_goal(action)

# Get the final torques (with gravity compensation)
torques = controller.run_controller()

Related Pages

Page Connections

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