From f723aa97694e41c468fdd6a1c90f4f2d7affda50 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 5 Apr 2018 18:54:10 -0600 Subject: [PATCH] bug fixes --- Chapter03/src/physics.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Chapter03/src/physics.rs b/Chapter03/src/physics.rs index 53ca04b..23b34fd 100644 --- a/Chapter03/src/physics.rs +++ b/Chapter03/src/physics.rs @@ -76,12 +76,11 @@ pub fn simulate_elevator(esp: ElevatorSpe .as_fractional_secs(); est.timestamp = now; - est.location = est.location + est.velocity * dt; est.velocity = est.velocity + est.acceleration * dt; est.acceleration = { let F = est.motor_input.calculate_force(); - let m = 1200000.0; + let m = esp.carriage_weight; -9.8 + F/m }; @@ -95,7 +94,7 @@ pub fn simulate_elevator(esp: ElevatorSpe } //5.3. Adjust motor control to process next floor request - mc.poll(est.clone(), next_floor); + est.motor_input = mc.poll(est.clone(), next_floor); //5.4. Print realtime statistics dr.poll(est.clone(), next_floor);