mirror of
https://github.com/andrew-johnson-4/Hands-On-Functional-Programming-in-Rust
synced 2024-11-18 03:25:33 +00:00
bug fixes
This commit is contained in:
parent
03d17f6174
commit
f723aa9769
@ -76,12 +76,11 @@ pub fn simulate_elevator<MC: MotorController, DR: DataRecorder>(esp: ElevatorSpe
|
|||||||
.as_fractional_secs();
|
.as_fractional_secs();
|
||||||
est.timestamp = now;
|
est.timestamp = now;
|
||||||
|
|
||||||
|
|
||||||
est.location = est.location + est.velocity * dt;
|
est.location = est.location + est.velocity * dt;
|
||||||
est.velocity = est.velocity + est.acceleration * dt;
|
est.velocity = est.velocity + est.acceleration * dt;
|
||||||
est.acceleration = {
|
est.acceleration = {
|
||||||
let F = est.motor_input.calculate_force();
|
let F = est.motor_input.calculate_force();
|
||||||
let m = 1200000.0;
|
let m = esp.carriage_weight;
|
||||||
-9.8 + F/m
|
-9.8 + F/m
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,7 +94,7 @@ pub fn simulate_elevator<MC: MotorController, DR: DataRecorder>(esp: ElevatorSpe
|
|||||||
}
|
}
|
||||||
|
|
||||||
//5.3. Adjust motor control to process next floor request
|
//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
|
//5.4. Print realtime statistics
|
||||||
dr.poll(est.clone(), next_floor);
|
dr.poll(est.clone(), next_floor);
|
||||||
|
Loading…
Reference in New Issue
Block a user