From 4624de4e42506f5b2b94005c7f624d60f9f3bb1f Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 19 Nov 2020 19:15:02 -0700 Subject: [PATCH] add nonstub motor controllers for each building and test for simulate_trip --- Chapter05/src/motion_controllers.rs | 2 +- Chapter05/src/motor1.c | 4 ++-- Chapter05/src/motor2.c | 4 ++-- Chapter05/src/motor3.c | 4 ++-- Chapter05/src/physics.rs | 2 +- Chapter05/test1.txt | 3 +++ 6 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 Chapter05/test1.txt diff --git a/Chapter05/src/motion_controllers.rs b/Chapter05/src/motion_controllers.rs index de56892..9b3f910 100644 --- a/Chapter05/src/motion_controllers.rs +++ b/Chapter05/src/motion_controllers.rs @@ -98,7 +98,7 @@ impl MotionController for SmoothMotionController //may happen if time delta underflows 0.0 } else { - 0.0 + target_force } } } diff --git a/Chapter05/src/motor1.c b/Chapter05/src/motor1.c index 8cb9bbe..183b8a0 100644 --- a/Chapter05/src/motor1.c +++ b/Chapter05/src/motor1.c @@ -1,6 +1,6 @@ -int motor1_adjust_motor(double target_force){ +double motor1_adjust_motor(double target_force){ //real driver would do something here //interface with physical components - return 0; + return target_force; } diff --git a/Chapter05/src/motor2.c b/Chapter05/src/motor2.c index fc051fa..fec3fe0 100644 --- a/Chapter05/src/motor2.c +++ b/Chapter05/src/motor2.c @@ -1,6 +1,6 @@ -int motor2_adjust_motor(double target_force){ +double motor2_adjust_motor(double target_force){ //real driver would do something here //interface with physical components - return 0; + return target_force; } diff --git a/Chapter05/src/motor3.c b/Chapter05/src/motor3.c index f77136f..1f2922f 100644 --- a/Chapter05/src/motor3.c +++ b/Chapter05/src/motor3.c @@ -1,6 +1,6 @@ -int motor3_adjust_motor(double target_force){ +double motor3_adjust_motor(double target_force){ //real driver would do something here //interface with physical components - return 0; + return target_force; } diff --git a/Chapter05/src/physics.rs b/Chapter05/src/physics.rs index 7f8e4ef..501210f 100644 --- a/Chapter05/src/physics.rs +++ b/Chapter05/src/physics.rs @@ -15,7 +15,7 @@ pub struct ElevatorState { pub motor_input: f64 } -pub const MAX_JERK: f64 = 0.2; +pub const MAX_JERK: f64 = 20.0; pub const MAX_ACCELERATION: f64 = 2.0; pub const MAX_VELOCITY: f64 = 5.0; diff --git a/Chapter05/test1.txt b/Chapter05/test1.txt new file mode 100644 index 0000000..3328062 --- /dev/null +++ b/Chapter05/test1.txt @@ -0,0 +1,3 @@ +1 +1 +2