BricksRL: A Platform for Democratizing Robotics and Reinforcement Learning Research and Education with LEGO

Sebastian Dittert, Vincent Moens, Gianni De Fabritiis

TL;DR

BricksRL is an open-source platform that bridges the gap between low-cost LEGO hardware and high-performance Reinforcement Learning (RL) via the TorchRL library. It enables researchers and educators to train real-world robots—from quadrupeds to robotic arms—on a standard laptop in under two hours, significantly lowering the barrier to entry for embodied AI.

What Problem Does This Paper Address?

Robotics research is notoriously expensive and inaccessible. Industrial-grade robotic arms or quadruped platforms can cost anywhere from $10,000 to over $200,000. While DIY 3D-printed robots have lowered costs, they still require specialized workshops and lack the modularity needed for rapid prototyping.

Furthermore, the software "glue" required to connect real-world hardware to modern RL frameworks is often brittle and has a steep learning curve (e.g., mastering ROS). This creates a "bottleneck of entry" that excludes many students, educators, and hobbyists from contributing to cutting-edge RL research. BricksRL tackles this by utilizing the ubiquitous, modular, and affordable LEGO Technic ecosystem as a standardized hardware benchmark.

Methods

The core of BricksRL is a synergy between two powerful software stacks:

  1. Pybricks: A MicroPython-based firmware that runs directly on LEGO hubs, providing low-latency control of motors and sensors.
  2. TorchRL: A modern PyTorch-based library for RL that handles the heavy lifting of agent training, replay buffers, and GPU acceleration.
BricksRL System Architecture

The Communication Bridge: The system uses a bidirectional Bluetooth Low Energy (BLE) connection. The host computer (running TorchRL) sends actions as byte streams to the robot's stdin, while the robot streams sensor data back via stdout.

The Environment Wrapper: BricksRL provides a "Gym-like" interface. By inheriting from TorchRL’s EnvBase, the authors created a standardized way to define observations (motor angles, IMU data, ultrasonic distance) and actions. This allows users to swap out state-of-the-art algorithms like SAC (Soft Actor-Critic), TD3, or DroQ with minimal code changes.

Robot Configurations and Datasets

To encourage further research without requiring physical hardware, the authors have released a collection of offline RL datasets based on three primary robot builds:

LEGO Robot Configurations: (a) 2Wheeler, (b) Walker, (c) RoboArm
  • Robot Configurations: The 2Wheeler (mobile base), Walker (quadruped), and RoboArm (static manipulator).
  • Data Types: Each configuration includes both "Expert" data (collected from trained SAC agents) and "Random" data (collected from stochastic policies).
  • Scope: Over 100 experiments worth of transitions are available on Hugging Face, designed for benchmarking offline RL algorithms like CQL and IQL.

Key Insights and Ideas

  • The "Frame Skip" Advantage: One might assume the system's low communication frequency (~11Hz via BLE) would be a dealbreaker. However, the authors found that for tasks like walking, a lower frequency (2Hz) actually led to faster and more stable convergence. This effectively acts as "frame skipping," simplifying the decision-making process for the agent.
  • Sim2Real is Feasible on Plastic: Despite the inherent "play" or backlash in LEGO gears and the lack of millimeter precision, policies trained in basic simulations transferred successfully to real-world hardware.
  • Beyond the Box: The platform is extensible. The authors demonstrated this by integrating a standard USB webcam into the loop, using OpenCV to track a red ball and providing pixel-based rewards for the RoboArm—proving the system isn't limited to the LEGO sensor suite.

Key Results

The paper demonstrates that "inexpensive" does not mean "incapable":

  • Rapid Training: Most tasks were solved in remarkably short windows. The "Spinning" task for the 2Wheeler was mastered in ~10 minutes, while the complex "Walker" task (learning a forward gait) took approximately 70 minutes on a standard laptop.
  • High Success Rates: The RoboArm achieved an 88% success rate in real-world reaching tasks when trained online.
  • Offline Performance: While online training was generally more robust, the authors showed that offline algorithms (like CQL) could successfully learn reaching behaviors from the provided datasets, though they noted a tendency for these models to overfit to specific expert trajectories.

Limitations and Future Work

The authors are transparent about the platform's constraints:

  • Hardware Precision: LEGO components have significant backlash and are not designed for high-precision industrial tasks.
  • Communication Bottlenecks: The current stdin/stdout over BLE approach caps the frequency at around 11Hz, which may be too slow for highly dynamic, high-speed maneuvers.
  • Future Directions: The team plans to explore multi-agent settings (multiple LEGO hubs interacting), transformer-based imitation learning, and even more complex builds to push the limits of what modular plastic can do.

By providing building plans, environment templates, and open-source code, BricksRL effectively turns a toy into a legitimate scientific instrument for the next generation of roboticists.

Summary updated

BibTeX
@inproceedings{dittert2024bricksrl,
  author = {Sebastian Dittert and Vincent Moens and Gianni De Fabritiis},
  title = {{BricksRL: A Platform for Democratizing Robotics and Reinforcement Learning Research and Education with LEGO}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=8iytZCnXIu},
}
Figure