Skip to main content
The rfx.robot module provides the core interface for all robots, whether real or simulated.

Robot Protocol

The entire robot interface. Real or simulated robots implement the same API.

Properties

num_envs
int
Number of parallel environments (1 for real robots)
state_dim
int
Actual state dimensionality (before padding)
action_dim
int
Actual action dimensionality (before padding)
max_state_dim
int
Padded state dim for multi-embodiment training
max_action_dim
int
Padded action dim for multi-embodiment training
device
str
Device for tensors (“cuda” or “cpu”)

Methods

observe()

Get current observation as a dictionary of tensors.
returns
dict[str, torch.Tensor]
Dictionary containing:
  • state: (num_envs, max_state_dim) - joint positions/velocities
  • images: (num_envs, num_cams, H, W, 3) - RGB images (optional)
  • language: (num_envs, seq_len) - tokenized instruction (optional)
robot = rfx.Robot.from_config("so101.yaml")
obs = robot.observe()
print(obs["state"].shape)  # (1, 64)

act(action)

Execute an action on the robot.
action
torch.Tensor
required
Action tensor with shape (num_envs, max_action_dim) or (num_envs, horizon, max_action_dim)
import torch
action = torch.zeros(1, 64)  # Zero action
robot.act(action)

reset(env_ids=None)

Reset environments and return initial observation.
env_ids
torch.Tensor | None
(N,) tensor of environment indices to reset. If None, resets all environments.
returns
dict[str, torch.Tensor]
Initial observation dictionary (same format as observe())
obs = robot.reset()  # Reset all environments
obs = robot.reset(torch.tensor([0, 2]))  # Reset specific environments

RobotBase

Abstract base class for Robot implementations. Provides common functionality and enforces the interface.

Constructor

RobotBase(
    state_dim: int,
    action_dim: int,
    num_envs: int = 1,
    max_state_dim: int = 64,
    max_action_dim: int = 64,
    device: str = "cpu"
)
state_dim
int
required
Actual state dimensionality (e.g., 6 for SO-101)
action_dim
int
required
Actual action dimensionality (e.g., 6 for SO-101)
num_envs
int
default:"1"
Number of parallel environments
max_state_dim
int
default:"64"
Padded state dimension for multi-embodiment training
max_action_dim
int
default:"64"
Padded action dimension for multi-embodiment training
device
str
default:"cpu"
Device for tensors (“cuda” or “cpu”)

Class Methods

from_config(config_path, **kwargs)

Create a robot from a YAML config file.
config_path
str
required
Path to YAML configuration file
**kwargs
dict
Additional keyword arguments to override config values
robot = RobotBase.from_config("so101.yaml", device="cuda")

RobotConfig

Configuration dataclass for a robot.
name
str
default:"robot"
Human-readable name (e.g., “SO-101”)
urdf_path
str | None
default:"None"
Path to URDF file (for simulation)
state_dim
int
default:"12"
Actual DOF for state
action_dim
int
default:"6"
Actual DOF for actions
max_state_dim
int
default:"64"
Pad state to this for multi-robot training
max_action_dim
int
default:"64"
Pad action to this for multi-robot training
cameras
list[CameraConfig]
default:"[]"
List of camera configurations
joints
list[JointConfig]
default:"[]"
List of joint configurations
control_freq_hz
int
default:"50"
Control loop frequency in Hz
hardware
dict[str, Any]
default:"{}"
Hardware-specific settings (port, IP address, etc.)

Class Methods

from_dict(d)

Create from a dictionary.
config = RobotConfig.from_dict({
    "name": "SO-101",
    "state_dim": 12,
    "action_dim": 6
})

from_yaml(path)

Load from a YAML file.
config = RobotConfig.from_yaml("configs/so101.yaml")

Instance Methods

to_dict()

Convert to a dictionary.
config_dict = config.to_dict()

Pre-defined Configs

Pre-configured robot configurations for common platforms:
  • SO101_CONFIG - SO-101 arm (6 DOF)
  • GO2_CONFIG - Unitree Go2 quadruped (12 DOF)
  • G1_CONFIG - Unitree G1 humanoid (29 DOF)
  • INNATE_CONFIG - Innate manipulation arm (6 DOF)
from rfx.robot import SO101_CONFIG, GO2_CONFIG

print(SO101_CONFIG.state_dim)  # 12
print(GO2_CONFIG.action_dim)   # 12

CameraConfig

Configuration for a camera sensor.
name
str
default:"camera"
Camera identifier
width
int
default:"640"
Image width in pixels
height
int
default:"480"
Image height in pixels
fps
int
default:"30"
Frames per second
device_id
int | str
default:"0"
Camera device ID or path

JointConfig

Configuration for a single joint.
name
str
required
Joint name
index
int
required
Joint index in the robot’s DOF array
position_min
float
default:"-3.14159"
Minimum position limit (radians)
position_max
float
default:"3.14159"
Maximum position limit (radians)
velocity_max
float
default:"10.0"
Maximum velocity (rad/s)
effort_max
float
default:"100.0"
Maximum effort/torque (Nm)

load_config()

Load a robot configuration from a YAML file or dictionary.
load_config(config_path: str | Path | dict[str, Any]) -> dict[str, Any]
config_path
str | Path | dict[str, Any]
required
Path to YAML config file, or a dictionary
returns
dict[str, Any]
Configuration dictionary
from rfx.robot import load_config

config = load_config("so101.yaml")
config = load_config({"state_dim": 12, "action_dim": 6})

Example Usage

import rfx
from rfx.robot import RobotConfig, load_config

# Method 1: Use pre-defined config
from rfx.robot.lerobot import so101
robot = so101()

# Method 2: Load from YAML
config = load_config("so101.yaml")
robot = RobotBase.from_config(config)

# Method 3: Create programmatically
config = RobotConfig(
    name="CustomRobot",
    state_dim=12,
    action_dim=6,
    control_freq_hz=50
)

# Run a simple control loop
obs = robot.observe()
action = policy(obs)  # Your policy here
robot.act(action)

Build docs developers (and LLMs) love