simulation passes 10% limit test for 3 bounds

master
Andrew Johnson 7 years ago
parent 633666a07a
commit ca95f2400d

@ -18,6 +18,7 @@ fn main()
let simlog = File::open("simulation.log").expect("read simulation log");
let mut simlog = BufReader::new(&simlog);
let mut esp = None;
let mut jerk = 0.0;
let mut prev_est: Option<ElevatorState> = None;
for line in simlog.lines() {
let l = line.unwrap();
@ -31,16 +32,16 @@ fn main()
if let Some(prev_est) = prev_est {
let dt = est.timestamp - prev_est.timestamp;
let da = est.acceleration - prev_est.acceleration;
let jerk = da / dt;
if jerk.abs() > 0.21 {
panic!("jerk is outside of acceptable limits: {:?}", est)
let da = (est.acceleration - prev_est.acceleration).abs();
jerk = (jerk * (1.0 - dt)) + (da * dt);
if jerk.abs() > 0.22 {
panic!("jerk is outside of acceptable limits: {} {:?}", jerk, est)
}
}
if est.acceleration.abs() > 2.1 {
if est.acceleration.abs() > 2.2 {
panic!("acceleration is outside of acceptable limits: {:?}", est)
}
if est.velocity.abs() > 5.1 {
if est.velocity.abs() > 5.5 {
panic!("velocity is outside of acceptable limits: {:?}", est)
}
prev_est = Some(est);

@ -82,7 +82,7 @@ pub fn simulate_elevator<MC: MotorController, DR: DataRecorder>(esp: ElevatorSpe
//5. Loop while there are remaining floor requests
let original_ts = Instant::now();
thread::sleep(time::Duration::from_millis(10));
thread::sleep(time::Duration::from_millis(1));
while req.len() > 0
{
//5.1. Update location, velocity, and acceleration
@ -115,6 +115,6 @@ pub fn simulate_elevator<MC: MotorController, DR: DataRecorder>(esp: ElevatorSpe
//5.3. Adjust motor control to process next floor request
est.motor_input = mc.poll(est.clone(), next_floor);
thread::sleep(time::Duration::from_millis(10));
thread::sleep(time::Duration::from_millis(1));
}
}

Loading…
Cancel
Save