From 177f639f7b149edd0afe9c6a8e062eb85a42385a Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Sun, 3 Feb 2019 22:35:14 -0800 Subject: [PATCH] make sure bikes can actually start moving --- sim/src/kinematics.rs | 4 +++- tests/src/physics.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sim/src/kinematics.rs b/sim/src/kinematics.rs index f0cc685c64..13bba607ab 100644 --- a/sim/src/kinematics.rs +++ b/sim/src/kinematics.rs @@ -78,7 +78,9 @@ impl Vehicle { vehicle_type: VehicleType::Bike, debug: false, // http://eprints.uwe.ac.uk/20767/ says mean 0.231 - max_accel: Acceleration::meters_per_second_squared(rng.gen_range(0.2, 0.3)), + // TODO But it's too slow, bikes can't accelerate past a non-zeroish speed in 0.1s. + // Workaround properly... perhaps with a continuous time approach. + max_accel: Acceleration::meters_per_second_squared(rng.gen_range(1.1, 1.3)), // Much easier deaccel. Partly to avoid accel_to_stop_in_dist bugs with bikes running // stop signs. max_deaccel: Acceleration::meters_per_second_squared(rng.gen_range(-1.3, -1.2)), diff --git a/tests/src/physics.rs b/tests/src/physics.rs index 09f64818b2..4ad8d04407 100644 --- a/tests/src/physics.rs +++ b/tests/src/physics.rs @@ -1,5 +1,5 @@ use crate::runner::TestRunner; -use geom::{Distance, Speed, EPSILON_DIST}; +use geom::{Acceleration, Distance, Speed, EPSILON_DIST}; use sim::kinematics::{results_of_accel_for_one_tick, Vehicle}; use sim::{Tick, TIMESTEP}; @@ -59,6 +59,13 @@ pub fn run(t: &mut TestRunner) { Some(Tick::testonly_from_raw(35 + 1200 + 36000)) ); }); + + t.run_fast("min_accel_doesnt_round_to_zero", |_| { + // Copied from kinematics.rs, for bikes. + let min_accel = Acceleration::meters_per_second_squared(1.1); + let speed = min_accel * TIMESTEP; + assert!(!speed.is_zero(TIMESTEP)); + }); } // TODO Make sure speed never exceeds the vehicle's cap