... | ... | @@ -18,49 +18,9 @@ The plan is to follow the instructions given in the instructions for Lesson 2 [1 |
|
|
|
|
|
### Exercise 1
|
|
|
|
|
|
### Exercise 2
|
|
|
![Measured sound level as a function of sound level from a mac pc](https://gitlab.au.dk/rene2014/lego/raw/ffd008e7c3df32eb42b20f306dc2ff655fd9a17b/Week5/Measurements/SoundLevelMeasurements.png)
|
|
|
|
|
|
### Exercise 3
|
|
|
|
|
|
### Exercise 4
|
|
|
|
|
|
### Exercise 5
|
|
|
|
|
|
![Clap characteristics]
|
|
|
(https://gitlab.au.dk/rene2014/lego/raw/master/Week5/Measurements/ClapMeasurements.png)
|
|
|
|
|
|
### Exercise 6
|
|
|
|
|
|
```java
|
|
|
static float Kp = 5.0f,
|
|
|
Ki = 0f,
|
|
|
Kd = 0.5f;
|
|
|
|
|
|
static int dt = 10;
|
|
|
|
|
|
...
|
|
|
|
|
|
DifferentialPilot pilot = new DifferentialPilot(56f, 113f, Motor.B, Motor.C);
|
|
|
pilot.forward();
|
|
|
pilot.setTravelSpeed(100);
|
|
|
|
|
|
while(!Button.ESCAPE.isDown())
|
|
|
{
|
|
|
leftNoise = leftSound.readRawValue()-30; //kalibrering :-)
|
|
|
rightNoise = rightSound.readRawValue();
|
|
|
|
|
|
int error = leftNoise - rightNoise;
|
|
|
integral = integral + error*dt;
|
|
|
int derivative = (error - last_error)/dt;
|
|
|
float turn = Kp*error + Ki*integral + Kd*derivative;
|
|
|
last_error = error;
|
|
|
|
|
|
pilot.steer((int)turn);
|
|
|
|
|
|
Thread.sleep(dt);
|
|
|
}
|
|
|
```
|
|
|
![Clap characteristics](https://gitlab.au.dk/rene2014/lego/raw/master/Week5/Measurements/ClapMeasurements.png)
|
|
|
|
|
|
## Conclusion
|
|
|
|
... | ... | |