... | @@ -51,6 +51,22 @@ So in order for this application to work properly, the car had to start of the l |
... | @@ -51,6 +51,22 @@ So in order for this application to work properly, the car had to start of the l |
|
### Exercise 4, Line Follower that stops in a goal zone
|
|
### Exercise 4, Line Follower that stops in a goal zone
|
|
|
|
|
|
### Exercise 5, PID Line Follower
|
|
### Exercise 5, PID Line Follower
|
|
|
|
The program for this exercise implements a standard PID controller in the following way
|
|
|
|
|
|
|
|
```java
|
|
|
|
// Calculate parameters
|
|
|
|
error = calculateError();
|
|
|
|
integral = integral + error;
|
|
|
|
derivative = (error - lastError) / dt;
|
|
|
|
|
|
|
|
// Apply the PID regulation
|
|
|
|
controlledValue = (kp * error) + (ki * integral) + (kd * derivative);
|
|
|
|
|
|
|
|
controlSignal(controlledValue);
|
|
|
|
|
|
|
|
lastError = error;
|
|
|
|
|
|
|
|
Delay.msDelay(dt);
|
|
|
|
|
|
### Exercise 6, Color Sensor
|
|
### Exercise 6, Color Sensor
|
|
|
|
|
... | | ... | |