... | ... | @@ -10,7 +10,7 @@ |
|
|
|
|
|
## Goal
|
|
|
|
|
|
The goal of this exercise is to do experiments with Braitenbergs different vehicles.
|
|
|
The goal of this exercise is to do experiments with Braitenbergs different vehicle setups.
|
|
|
|
|
|
## Plan
|
|
|
|
... | ... | @@ -18,18 +18,115 @@ The plan is to follow the instructions for Lesson 6 [1]. |
|
|
|
|
|
## Vehicle 1
|
|
|
|
|
|
### setup
|
|
|
### Setup
|
|
|
|
|
|
The setup for this exercise refer to Braitenbergs vehicle 1 where two large wheels are mounted on the motors and a small wheel mounted in the back of the car in order to stabilize the construction.
|
|
|
A sound sensor is mounted in the front of the car pointing forward. The final construction is seen in the following image.
|
|
|
|
|
|
![Vehicle 1](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson6/Images/Vehicle1.JPG)
|
|
|
|
|
|
### results
|
|
|
Three implementations will be tested
|
|
|
|
|
|
* **Excitatory** setup with motor power going from 0 to 100
|
|
|
* **Inhibitory** setup with motor power going from 0 to 100
|
|
|
* **Negative motor power ** setup with motor power going from -100 to 100
|
|
|
|
|
|
Due the output of the sound sensor span from 0 to 1023 a simple conversion is needed in all cases in order to make the mapping to the motor power with a maximum of 100.
|
|
|
|
|
|
**Excitatory** (0 to 100)
|
|
|
|
|
|
The conversion factor for this case is found by the following equation
|
|
|
|
|
|
*conversion factor = motor power range/sensor range*
|
|
|
|
|
|
Because of the friction in the motor a certain power needs to be applied in order for the wheels to start spinning. By introducing a minimum power into the equation we can ensure that the wheels will spin even at low sounds.
|
|
|
|
|
|
*power = (sound level * conversion factor) + minimum power*
|
|
|
|
|
|
By repeatedly tuning the minimum power we found that a minimum power of 40 was sufficient for this setup. With 40 as minimum power the motor power range is limited to 60 and the equation will therefore be
|
|
|
|
|
|
*conversion factor = 60/1023 = 0.059*
|
|
|
*power = (sound level * 0.059) + 40*
|
|
|
|
|
|
This is implemented as a function which takes the sound level (0-1023) as parameter and returns the motor power (40-100). The implementation of this is seen in the following code snippet
|
|
|
|
|
|
|
|
|
```java
|
|
|
static int calcDirectOutput(int soundLvl)
|
|
|
{
|
|
|
// Excitatory - 40 is offset to ensure that the motors can be activated
|
|
|
return (int)(soundLvl * 0.059f)+40;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
**Inhibitory** (0 to 100)
|
|
|
|
|
|
In order to make an inhibitory system with the given setup the output of the sensor needs to be inverted in the following way
|
|
|
|
|
|
*sensor output = 1023 - sensor output*
|
|
|
|
|
|
The conversion factor for this case is found as previously however with no minimum power applied. Therefore equation becomes
|
|
|
|
|
|
*conversion factor = 100/1023 = 0.098*
|
|
|
*power = (sound level * 0.098)*
|
|
|
|
|
|
The implementation is seen in the following code snippet.
|
|
|
|
|
|
```java
|
|
|
static int calcDirectOutput(int soundLvl)
|
|
|
{
|
|
|
//Inhibitory - 100/1023 = 0.098
|
|
|
int soundLvlInv = 1023 - soundLvl;
|
|
|
return (int)(soundLvl * 0.098f);
|
|
|
}
|
|
|
```
|
|
|
**Negative motor power** (-100 to 100)
|
|
|
|
|
|
For this case when the motors shall be able to spin in both directions according to a linear non-negative output from the sound sensor. This yields that at a sound level of 512 the motors should be at rest with no power applied.
|
|
|
|
|
|
The conversion fractor from previously is used again
|
|
|
|
|
|
*conversion factor = motor power range/sensor range*
|
|
|
|
|
|
The motor power range is now 200 which yields a conversion factor of
|
|
|
|
|
|
*conversion factor = 200/1023 = 0.196*
|
|
|
|
|
|
To introduce negative motor power 100 is substracted from the calculated output
|
|
|
|
|
|
*power = (sound level * 0.196) - 100*
|
|
|
|
|
|
This is implemented as a function which takes the sound level (0-1023) as parameter and returns the motor power (-100-100). The implementation of this is seen in the following code snippet
|
|
|
|
|
|
```java
|
|
|
static int calcOutput(int soundLvl)
|
|
|
{
|
|
|
// Exitatory - 200/1023 = 0.196
|
|
|
float output = soundLvl * 0.196f;
|
|
|
return (int)(output-100);
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### Results
|
|
|
|
|
|
|
|
|
|
|
|
## Vehicle 2
|
|
|
|
|
|
### Setup
|
|
|
|
|
|
![Vehicle 2](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson6/Images/Vehicle2.JPG)
|
|
|
|
|
|
### Results
|
|
|
|
|
|
|
|
|
## Vehicle 3
|
|
|
|
|
|
### Setup
|
|
|
|
|
|
![Vehicle 3](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson6/Images/Vehicle3.JPG)
|
|
|
|
|
|
### Results
|
|
|
|
|
|
|
|
|
## Conclusion
|
... | ... | @@ -40,3 +137,8 @@ The plan is to follow the instructions for Lesson 6 [1]. |
|
|
[1] http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson6.dir/Lesson.html
|
|
|
|
|
|
### Videos
|
|
|
|
|
|
[Vehicle 1 - Excitatory] - http://youtu.be/_MwM8BArTkA
|
|
|
[Vehicle 1 - Inhibitory] - http://youtu.be/M4v3csjxmYQ
|
|
|
[Vehicle 1 - Negative motor power] - http://youtu.be/2u8VhV_bmUE
|
|
|
|