rfx.envs
Provides unified interfaces for simulation and real robot control, following the standard Gym API.Box
A box in R^n, representing continuous observation/action spaces.Constructor
Lower bounds for each dimension.
Upper bounds for each dimension.
Shape of the space.
Data type of the space.
Methods
sample
Random sample within bounds.
contains
Value to check.
True if x is within bounds and has correct shape.
clip
Value to clip.
Clipped value within bounds.
BaseEnv
Abstract base class for robot environments. All environments should implement this interface for compatibility with training utilities.Properties
The observation space.
The action space.
Methods
reset
Initial observation.
step
Action to take.
Tuple of (observation, reward, done, info).
close
render
Go2Env
Gym-like interface for the Unitree Go2 quadruped robot. Can run in simulation mode or on real hardware.Spaces
Observation Space (48 dimensions):- Joint positions (12): Current joint angles
- Joint velocities (12): Current joint velocities
- Base angular velocity (3): IMU angular velocity
- Projected gravity (3): Gravity vector in body frame
- Commands (3): Velocity commands (vx, vy, yaw_rate)
- Last actions (12): Previous action
- Clock (3): Phase variables for gait timing
- Joint position targets, normalized to [-1, 1]
- Scaled by action_scale to get actual joint deltas
Constructor
If True, use simulation backend; if False, connect to real robot.
Configuration for simulation (only used if sim=True).
IP address of real robot (only used if sim=False).
Control timestep in seconds (default: 0.02s = 50Hz).
Scaling factor for actions.
Methods
set_commands
Forward velocity command.
Lateral velocity command.
Yaw rate command.
Class Attributes
Lower joint limits for all 12 joints (radians).
Upper joint limits for all 12 joints (radians).
Default standing pose joint positions.
VecEnv
Vectorized environment for parallel rollouts. Runs multiple environments in parallel for faster data collection.Constructor
Function that creates a single environment.
Number of parallel environments.
Methods
reset
Stacked observations of shape
(num_envs, obs_dim).step
Actions for all environments, shape
(num_envs, action_dim).Tuple of (observations, rewards, dones, infos).
close
make_vec_env
Utility function to create a (vectorized) environment.Function Signature
Environment class to instantiate.
Number of parallel environments.
Arguments passed to environment constructor.
VecEnv if num_envs > 1, otherwise single environment.
