Reinforcement Learning for Robotics Part 4: Domain Randomization | DigiKey @digikey
Reinforcement Learning for Robotics Part 4: Domain Randomization | DigiKey  @digikey
Uploaded August 2026 | Updated November 2026, 12 hours ago
In this series, we explore using reinforcement learning algorithms (RL) to have a robot learn to balance on its own. We will deploy the trained agent to a real ESP32-based robot platform, tackle the sim-to-real gap using post-processing and domain randomization, and eventually build a full remote-controlled balance bot. The same techniques used here are what researchers use to train state-of-the-art walking robots. So, while we are starting with a simpler project, know that these skills will transfer to modern robotics.

Click here to register for Shawn’s webinar on this topic: event.on24.com/wcc/r/5384134/958EFFE494BF1C6A2AD94F9B093DC01B?partnerref=vid

To follow along with the series, you will need the following hardware:
M5Stack BALA2 Fire robot kit: digikey.com/short/7h2fb5hd

All project files, including the FreeCAD model, MuJoCo XML descriptor, and Docker environment, are available in the following GitHub repository:
github.com/ShawnHymel/reinforcement-learning-for-robotics

In the previous episode, we deployed our trained agent to the real robot and had to patch the sim-to-real gap with firmware fixes like pitch offsets, motor boosts, and low-pass filters. It worked, but it required manual tuning and undermined the whole point of training a robust agent. This episode takes the more principled approach: domain randomization.

You can read a full write-up of everything we cover in this video here:
digikey.com/en/maker/tutorials/2026/reinforcement-learning-for-robotics-part-4-domain-randomization

Domain randomization (DR) is the most popular technique for bridging the sim-to-real gap in robotics. Rather than trying to perfectly model the robot, we deliberately introduce randomness into the simulation during training (e.g. noisy sensor readings, variable motor torque, random pushes, friction variation, etc.) so the agent learns a policy that generalizes to the real world without firmware workarounds.

We walk through the updated Gymnasium environment, which adds a new DomainRandomConfig dataclass to control all the randomization parameters. From there, we extend our curriculum learning approach to 7 training phases, slowly introducing domain randomization after the agent has mastered the basic balancing task. We cover what to randomize, why, and how to layer it in gradually without destabilizing training. Once training is complete, we deploy the new actor network to the robot (this time without all the firmware fixes) and see a noticeably more robust result.

Coursera Deep Learning specialization: coursera.org/specializations/deep-learning
Coursera Reinforcement Learning specialization: coursera.org/specializations/reinforcement-learning
Introduction to Reinforcement Learning textbook by Sutton and Barto: incompleteideas.net/book/the-book-2nd.html
Reinforcement Learning math blog post series: shawnhymel.com/3316/what-is-reinforcement-learning
Introduction to Reinforcement Learning video: youtube.com/watch?v=3av8vozEczU

Learn more:
Maker.io - digikey.com/en/maker
Digi-Key’s Blog – TheCircuit digikey.com/en/blog
Connect with Digi-Key on Facebook facebook.com/digikey.electronics
And follow us on X https://x.com/digikey

0:00 Intro
0:54 Domain randomization overview
3:00 Adding domain randomization to the gymnasium environment
9:34 Retrain agent with domain randomization enabled
19:52 Deploy agent to robot using Arduino
21:52 Conclusion
Reinforcement Learning for Robotics Part 4: Domain Randomization | DigiKeyReinforcement Learning for Robotics Part 1: Import a Robot CAD Model into MuJoCo | DigiKeyPlowing Ahead [Maker Update] | Maker.ioMaker Faire Bay Area 2026 [Maker Update] | Maker.ioThe DNA of Logic - #thebytesizedengineer | DigiKeyUsing Home Assistant to get more data from your smart meter - #thebytesizedengineer | ShortMade to Fade [Maker Update] | Maker.ioCostume Electronics - #BeckyStern #ShortIntro to Embedded Rust Part 3: USB Serial Logging and Debugging | DigiKeyIntro to Embedded Rust Part 12: Async Programming with Embassy | DigiKeyEasy Audio Playback - #BeckyStern #shorts | DigiKey9 CT clamps with stackable PCBs  - #thebytesizedengineer | Short
DigiKey |

Reinforcement Learning for Robotics Part 4: Domain Randomization | DigiKey

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER