pathfinder-for-autonomous-navigation / psim

Six DOF flight simulator and related GNC implementations.
MIT License
4 stars 6 forks source link

Seeded Random Number Generation in PSim #277

Closed kylekrol closed 3 years ago

kylekrol commented 3 years ago

Closes #252.

Seeded Random Number Generation in PSim

Per the title, seeded random number generation is now available in PSim. The random number generator is owned by the simulation class and is therefore seeded in each individual instantiation of a simulation - very helpful if we want to run multiple sims in parallel at some point. Each model class then has access to the random number generator via the _randoms member variable shared across all models.

You can generate random numbers using the standard lin utilities:

#include <lin/generators/randoms.hpp>

... {
  // To make lin objects:
  auto gaussians = lin::gaussians<...>(_randoms,...);
  auto randoms = lin::rands<...>(_randoms,...);
  // Just a single scalar
  auto gaussian = _randoms.gaussian();
  auto random = _randoms.rand();
}

I reran simulation locally to verify the change wasn't breaking. You can also see the random number generator in action in #278.

kylekrol commented 3 years ago

Currently block on this quick PR: https://github.com/pathfinder-for-autonomous-navigation/lin/pull/17