diff --git a/Cargo.toml b/Cargo.toml index 4e368d16..12f168a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,10 +27,10 @@ opt-level = 3 # Enable a large amount of optimization in the dev profile for dep codegen-units = 1 # Compile the entire crate as one unit. lto = "thin" # Do a second optimization pass over the entire program, including dependencies. [dependencies] -rand = "0.9.1" +rand = "0.10.0" nalgebra = "0.34.0" -rand_distr = "0.5.1" -rand_chacha = "0.9.0" +rand_distr = "0.6.0" +rand_chacha = "0.10.0" rerun = "0.29" thiserror = "2.0.12" serde = { version = "1.0.219", features = ["derive"] } diff --git a/src/lib.rs b/src/lib.rs index 44586368..3116a805 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,7 @@ //! let inertia_matrix = [0.0347563, 0.0, 0.0, 0.0, 0.0458929, 0.0, 0.0, 0.0, 0.0977]; //! let quadrotor = Quadrotor::new(time_step, mass, gravity, drag_coefficient, inertia_matrix); //! ``` -use rand::SeedableRng; +use rand::{RngExt, SeedableRng}; use rayon::prelude::*; pub mod config; use nalgebra::{ @@ -437,7 +437,7 @@ impl Imu { gyro_noise: Normal::new(0.0, gyro_noise_std)?, accel_bias_drift: Normal::new(0.0, accel_bias_std)?, gyro_bias_drift: Normal::new(0.0, gyro_bias_std)?, - rng: ChaCha8Rng::from_os_rng(), + rng: ChaCha8Rng::from_rng(&mut rand::rng()), }) } /// Updates the IMU biases over time @@ -2712,7 +2712,7 @@ impl Obstacle { /// obstacles: vec![Obstacle::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 0.0), 1.0)], /// obstacles_velocity_bounds: [0.0, 0.0, 0.0], /// obstacles_radius_bounds: [0.0, 0.0], -/// rng: ChaCha8Rng::from_os_rng(), +/// rng: ChaCha8Rng::from_rng(&mut rand::rng()), /// }; /// ``` pub struct Maze { @@ -2756,7 +2756,7 @@ impl Maze { obstacles: Vec::new(), obstacles_velocity_bounds, obstacles_radius_bounds, - rng: ChaCha8Rng::from_os_rng(), + rng: ChaCha8Rng::from_rng(&mut rand::rng()), }; maze.generate_obstacles(num_obstacles); maze @@ -2774,27 +2774,21 @@ impl Maze { self.obstacles = (0..num_obstacles) .map(|_| { let position = Vector3::new( - rand::Rng::random_range( - &mut self.rng, - self.lower_bounds[0]..self.upper_bounds[0], - ), - rand::Rng::random_range( - &mut self.rng, - self.lower_bounds[1]..self.upper_bounds[1], - ), - rand::Rng::random_range( - &mut self.rng, - self.lower_bounds[2]..self.upper_bounds[2], - ), + self.rng + .random_range(self.lower_bounds[0]..self.upper_bounds[0]), + self.rng + .random_range(self.lower_bounds[1]..self.upper_bounds[1]), + self.rng + .random_range(self.lower_bounds[2]..self.upper_bounds[2]), ); let v_bounds = self.obstacles_velocity_bounds; let r_bounds = self.obstacles_radius_bounds; let velocity = Vector3::new( - rand::Rng::random_range(&mut self.rng, -v_bounds[0]..v_bounds[0]), - rand::Rng::random_range(&mut self.rng, -v_bounds[1]..v_bounds[1]), - rand::Rng::random_range(&mut self.rng, -v_bounds[2]..v_bounds[2]), + self.rng.random_range(-v_bounds[0]..v_bounds[0]), + self.rng.random_range(-v_bounds[1]..v_bounds[1]), + self.rng.random_range(-v_bounds[2]..v_bounds[2]), ); - let radius = rand::Rng::random_range(&mut self.rng, r_bounds[0]..r_bounds[1]); + let radius = self.rng.random_range(r_bounds[0]..r_bounds[1]); Obstacle::new(position, velocity, radius) }) .collect();