Enhanced SERL with Vectorized Environment Support and 3D Gaussian Splatting Integration
This repository extends the original SERL (Sample-Efficient Robotic Reinforcement Learning) framework with:
π Vectorized Environment Support: Efficient parallel data collection from multiple environments π¨ 3D Gaussian Splatting: High-fidelity visual rendering for robotic simulation π Improved Performance: Faster training through parallel environment execution π€ Mobile Robot Integration: Support for mobile manipulation tasks
Vectorized SERL provides enhanced libraries, environment wrappers, and examples to train RL policies more efficiently for robotic manipulation tasks using parallel environments and photorealistic 3D Gaussian Splatting rendering.
Table of Contents
- Key Features
- Installation
- Quick Start
- Vectorized Environment Usage
- 3D Gaussian Splatting Integration
- Mobile Robot Environment
- Overview and Code Structure
- Performance Benchmarks
- Examples
- Citation
- Parallel Data Collection: Train with multiple environments simultaneously using
gymnasium.vector.SyncVectorEnv - Scalable Training: Easily scale from 1 to N parallel environments with the
--num_envsflag - Memory Efficient: Optimized batching and observation handling for vectorized environments
- Backward Compatible: Seamlessly works with existing single-environment setups
- Photorealistic Rendering: High-fidelity visual observations using 3D Gaussian Splatting
- Real-time Performance: Efficient GPU-accelerated rendering for training and evaluation
- Flexible Scenes: Support for complex 3D environments with dynamic objects
- Visual Realism: Bridge the sim-to-real gap with photorealistic visual observations
- Mobile Manipulation: Integrated mobile robot environment (
PiperMobileRobot-v0) - Multi-modal Observations: RGB images, depth maps, and robot state information
- Flexible Action Spaces: Support for various robot configurations and action spaces
- Faster Training: Up to NΓfaster data collection with N parallel environments
- Optimized Memory Usage: Efficient batching and observation processing
- GPU Acceleration: Leverages JAX and CUDA for maximum performance
- CUDA-capable GPU (recommended for 3DGS rendering)
- Python 3.10
- CUDA 12.x (for GPU acceleration)
conda create -n vectorized_serl python=3.10
conda activate vectorized_serlpip install -U "jax[cuda12]"# Install SERL launcher
cd serl_launcher
pip install -e .
pip install -r requirements.txt
# Install mobile robot environment
cd ../mobile_robot
pip install -e .
# Install 3DGS dependencies
cd ../submodules/diff-plane-rasterization
pip install -e .
cd ..
git clone https://github.com/facebookresearch/pytorch3d.git
cd ../pytorch3d
pip install -e .# Train actor with single environment (original SERL)
python train_drq.py --actor --num_envs=1 --ip=localhost
# Train learner
python train_drq.py --learner --ip=localhost# Start learner
./run_learner.sh
# Start actor with vectorized environments
./run_actor.sh # Edit script to set desired num_envs
# Run evaluation
./run_eval.sh- Uses
gymnasium.vector.SyncVectorEnvfor reliable parallel execution - Automatic batching of observations and actions
- Compatible with existing SERL agents and replay buffers
- Supports all observation types (RGB, state, depth)
import gymnasium as gym
from gymnasium.vector import SyncVectorEnv
# Create vectorized mobile robot environment
def make_env():
return gym.make('PiperMobileRobot-v0')
# 4 parallel environments
env = SyncVectorEnv([make_env for _ in range(4)])
# Reset all environments
obs, info = env.reset()
print(f"Batch observations shape: {obs['rgb'].shape}") # (4, 128, 128, 3)
# Step all environments simultaneously
actions = env.action_space.sample() # (4, 7)
obs, rewards, dones, truncated, infos = env.step(actions)
print(f"Batch rewards: {rewards}") # Array of 4 rewards- Real-time Rendering: GPU-accelerated 3D Gaussian Splatting for photorealistic visuals
- Dynamic Scenes: Support for moving objects and robot interactions
- Multiple Viewpoints: Configurable camera positions and orientations
- High Performance: Optimized for training with minimal overhead
The 3DGS rendering is automatically enabled in supported environments:
import gym
from mobile_robot import PiperMobileRobotEnv
# Create environment with 3DGS rendering
env = gym.make('PiperMobileRobot-v0', render_mode='rgb_array')
obs, info = env.reset()
# RGB observations now use 3DGS rendering
rgb_image = obs['rgb'] # (128, 128, 3) - photorealistic image- Piper on Desk: Desktop manipulation tasks
- Unitree GO2 + Piper: Mobile manipulation scenarios
- Custom Scenes: Easy integration of new 3DGS scenes
A comprehensive mobile manipulation environment featuring:
- Piper robot arm mounted on mobile base
- 3DGS rendering for photorealistic visuals
- Multi-modal observations: RGB images + robot state
- Flexible action space: 7-DOF manipulation
{
'rgb': Box(0, 255, (128, 128, 3), uint8), # 3DGS rendered image
'state': Box(-inf, inf, (7,), float32) # Robot joint states
}Box(-1.0, 1.0, (7,), float32) # 7-DOF robot controlimport gym
import mobile_robot
env = gym.make('PiperMobileRobot-v0')
obs, info = env.reset()
for _ in range(1000):
action = env.action_space.sample()
obs, reward, done, truncated, info = env.step(action)
if done or truncated:
obs, info = env.reset()Vectorized SERL extends the original SERL architecture with vectorized environment support while maintaining the actor-learner design. The main structure involves:
- Actor Node: Collects data from N parallel environments simultaneously
- Learner Node: Trains the policy using collected data
- Vectorized Environments: Multiple environment instances running in parallel
- 3DGS Renderer: Provides photorealistic visual observations
Enhanced Code Structure
| Code Directory | Description | New Features |
|---|---|---|
| serl_launcher | Main SERL code | β Vectorized environment support |
| serl_launcher.agents | Agent Policies (DRQ, SAC, BC) | β Batched action sampling |
| serl_launcher.wrappers | Gym env wrappers | β Vector environment wrappers |
| mobile_robot | Mobile robot environment | π 3DGS integration |
| mobile_robot.viewer.gs_render | 3DGS rendering system | π GPU-accelerated rendering |
| submodules/diff-plane-rasterization | 3DGS rasterization | π Custom CUDA kernels |
| submodules/pytorch3d | 3D operations | π Geometry utilities |
class CleanVectorizedEnvWrapper:
"""Comprehensive vectorized environment wrapper"""
def __init__(self, env):
self.env = env # SyncVectorEnv
self.num_envs = env.num_envs
# Handles observation transformation and batching
def step(self, actions):
# Process batched actions for all environments
obs, reward, done, truncated, info = self.env.step(actions)
return self.transform_obs(obs), reward, done, truncated, infodef actor(agent, data_store, env, sampling_rng):
"""Enhanced actor with vectorized environment support"""
is_vectorized = hasattr(env, 'num_envs') and env.num_envs > 1
for step in range(FLAGS.max_steps):
if is_vectorized:
# Sample actions for all environments
actions = jnp.array([agent.sample_actions(obs_i) for obs_i in obs])
else:
# Single environment logic
actions = agent.sample_actions(obs)Environment Setup | Steps/Second | Speedup
---------------------------|--------------|--------
Single Environment | ~100 | 1.0x
4 Vectorized Environments | ~400 | 4.0x
8 Vectorized Environments | ~800 | 8.0x
10 Vectorized Environments| ~1000 | 10.0x
Environments | Memory Usage | Queue Size
-------------|--------------|------------
1 | ~2.5 GB | 500
4 | ~6.0 GB | 500
8 | ~9.5 GB | 500
10 | ~12.0 GB | 500
- Development/Testing:
--num_envs=1-2 - Standard Training:
--num_envs=4-8 - Fast Data Collection:
--num_envs=10-16 - Production: Scale based on available GPU memory
# Terminal 1: Start learner
python train_drq.py --learner --ip=localhost
# Terminal 2: Start vectorized actor
python train_drq.py --actor --num_envs=8 --ip=localhost# Create custom vectorized environment
from gymnasium.vector import SyncVectorEnv
import mobile_robot
def make_custom_env():
env = gym.make('PiperMobileRobot-v0')
# Add custom wrappers here
return env
# Create 6 parallel environments
envs = SyncVectorEnv([make_custom_env for _ in range(6)])# Run performance benchmark
python benchmark_vector_envs.py# Evaluate trained policy
python eval_policy.py --checkpoint_path=/path/to/checkpoint --num_envs=4If you use this enhanced vectorized SERL with 3DGS for your research, please cite both the original SERL paper and acknowledge this vectorized implementation:
@misc{luo2024serl,
title={SERL: A Software Suite for Sample-Efficient Robotic Reinforcement Learning},
author={Jianlan Luo and Zheyuan Hu and Charles Xu and You Liang Tan and Jacob Berg and Archit Sharma and Stefan Schaal and Chelsea Finn and Abhishek Gupta and Sergey Levine},
year={2024},
eprint={2401.16013},
archivePrefix={arXiv},
primaryClass={cs.RO}
}@inproceedings{kerbl3Dgaussians,
title={3D Gaussian Splatting for Real-Time Radiance Field Rendering},
author={Kerbl, Bernhard and Kopanas, Georgios and Leimk{\"u}hler, Thomas and Drettakis, George},
journal={ACM Transactions on Graphics},
number={4},
volume={42},
year={2023},
url={https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/}
}This work extends the original SERL framework with:
- Vectorized environment support for parallel data collection
- 3D Gaussian Splatting integration for photorealistic rendering
- Mobile robot environment with enhanced visual fidelity
- Performance optimizations for scaled RL training
We welcome contributions! Please feel free to submit issues and pull requests.
# Install development dependencies
pip install pre-commit black flake8
# Set up pre-commit hooks
pre-commit install
# Run tests
python -m pytest tests/
# Format code
black .- Additional vectorized environment wrappers
- Performance optimizations for large-scale training
- New 3DGS scenes and environments
- Documentation and examples
This project is licensed under the MIT License - see the LICENSE file for details.
-
CUDA Out of Memory with Many Environments
# Reduce number of environments or batch size python train_drq.py --actor --num_envs=4 --batch_size=128 -
3DGS Rendering Issues
# Ensure CUDA and PyTorch are properly installed python -c "import torch; print(torch.cuda.is_available())"
-
Vectorized Environment Errors
# Check environment compatibility python test_vectorized_env.py
For more issues, please check the Issues page.

