A rust library for simulating sensor measurement behavior. You can initialize or update a sensulator with a central "ideal" value, and the sensulator will subsequently provide noisy sensor measurements centered around that value.
See main.rs
``` use sensulator::Sensulator;
/// Latitude of Berkeley, California const HOMELAT:f32 = 37.8716; /// Absolute error of a typical GPS sensor (degrees) const GPSHORIZABSERROR:f32 = 2e-6; /// Relative error of a typical GPS sensor (degrees) const GPSHORIZREL_ERROR:f32 = 4.5e-5;
let mut fakegpslat = Sensulator::new(HOMELAT, GPSHORIZABSERROR, GPSHORIZRELERROR); loop { // update the sensor reading and display (requires a mutable sensulator reference) println!("new lat: {}", fakegpslat.measure()); // simply display the last measured value (may use an immutable reference) println!("old lat: {}", fakegps_lat.peek()); } ```
A brief quickcheck is run as part of cargo test
; however, if you want to run more
extensive tests, you can use something like:
export QUICKCHECK_TESTS=1000000; cargo test -- --nocapture