BayesSim: adaptive domain randomization via probabilistic inference for robotics simulators

Fabio Ramos, Rafael Carvalhaes Possas, Dieter Fox

Introduction

The "reality gap"—the discrepancy between simulated environments and the physical world—remains a primary hurdle in robotics. While training agents in simulation is safer and more cost-effective, policies often fail when deployed on real hardware due to oversimplified physics or incorrect parameters like friction and mass. Domain Randomization (DR) attempts to bridge this gap by varying simulation parameters during training, but manually selecting these distributions is often a tedious process of trial and error.

Problem Statement

Traditional DR relies on broad, uniform distributions that may either be too narrow to capture real-world variance or too wide for the agent to learn effectively. BayesSim introduces a principled, automated framework to identify the optimal distribution of simulation parameters based on limited real-world observations.

Methodology

BayesSim treats the simulator as a black-box generative model, making it compatible with non-differentiable engines like MuJoCo or PyBullet. The framework utilizes Likelihood-Free Inference (LFI) to estimate the posterior distribution of parameters $\theta$ given real-world trajectories $x^r$.

Technical Components

  1. Mixture Density Random Fourier Network (MDRFN): To approximate complex, multi-modal distributions, BayesSim employs a mixture of Gaussians. The network parameters are derived using Random Fourier Features (RFF), which enhances stability and reduces sensitivity to initialization compared to standard deep networks.
  2. Quasi-Monte Carlo (QMC) Sampling: The use of Halton sequences ensures better convergence rates and lower approximation errors than standard Monte Carlo methods.
  3. Summary Statistics: High-dimensional trajectory data is compressed into sufficient statistics (means, variances, and correlations) to streamline the inference process.

Experimental Evaluation

The framework was tested on several benchmarks, including OpenAI Gym (CartPole, Pendulum) and MuJoCo (Fetch Push, Fetch Slide). In these experiments, "real-world" data was simulated using "true" hidden parameters to evaluate the model's ability to recover them.

Key Results and Insights

BayesSim demonstrates superior accuracy in posterior estimation. As shown in the comparison of friction coefficient distributions, the BayesSim RFF model produces a posterior that is significantly more peaked around the true value compared to baselines like Rejection ABC.

Figure 2: Comparison of posterior distributions for the friction coefficient. BayesSim RFF shows a tighter fit to the true value compared to Rejection ABC and epsilon-Free methods.

Capturing Multi-modality

A critical insight of this work is the ability to capture correlations between parameters. In many systems, different combinations of parameters (e.g., pole length and mass) can result in identical observed behavior. BayesSim’s mixture model successfully identifies these multiple "explanations" or modes.

Figure 3: Posterior distribution of length vs. masspole showing multiple modes. The model captures several parameter combinations that explain the observed dynamics, with one mode centered near the true value.

Policy Robustness

Policies trained on the BayesSim-derived posterior exhibited significantly higher success rates in tasks like "Fetch Slide." Unlike policies trained on uniform priors, which degrade quickly as conditions change, the adaptive randomization provided by BayesSim ensures robustness to the specific uncertainties of the target environment.

Conclusion and Future Work

BayesSim provides a robust, black-box solution for tuning simulators to match real-world data. While currently reliant on manual feature engineering for trajectory summarization, future iterations could leverage automated feature learning via LSTMs or autoencoders. Scaling this Bayesian approach to hundreds of parameters and validating it on physical hardware with complex sensor noise are the next logical steps for this research.

Summary updated

BibTeX
@inproceedings{ramos2019bayessim,
  author = {Fabio Ramos and Rafael Carvalhaes Possas and Dieter Fox},
  title = {{BayesSim: adaptive domain randomization via probabilistic inference for robotics simulators}},
  booktitle = {Robotics: Science and Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=1nXJeG_0YNK},
}
Figure