zteel created page: Week11 sumo wrestling robots authored by Sune Brinch Sletgård's avatar Sune Brinch Sletgård
...@@ -198,7 +198,24 @@ Image 4: The robot after removing the ultrasonic sensor and adding touch sensors ...@@ -198,7 +198,24 @@ Image 4: The robot after removing the ultrasonic sensor and adding touch sensors
With this design we however have another problem. We only know if have something in front of us, which is what we want, or if we have been touched on one of the three sides we do not want. Then we got the idea that we might be able to distinguish the walls from each other by small differences in the raw value from the touch sensors. This will be possible if the sensors are inaccurate i.e. the sensors do not all produce the same value, but precise i.e. the sensors keeps reproducing the same value. If they did, we could make an analog to digital converter [11] on our NXT, thus freeing up ports while we get all the information we wanted. With this design we however have another problem. We only know if have something in front of us, which is what we want, or if we have been touched on one of the three sides we do not want. Then we got the idea that we might be able to distinguish the walls from each other by small differences in the raw value from the touch sensors. This will be possible if the sensors are inaccurate i.e. the sensors do not all produce the same value, but precise i.e. the sensors keeps reproducing the same value. If they did, we could make an analog to digital converter [11] on our NXT, thus freeing up ports while we get all the information we wanted.
We tested all the unused touch sensors in LegoLab, and found the the raw value returned by SensorPort.readRawValue() ranged in 181-185 with readings from the individual sensor being fairly consistent. We were able to pair touch sensors to get raw values of 98, 99 and 100. It was possible to get readings of +/- 3, but most readings of the paired sensors were the same. Although detecting which bumper is pressed using the raw values, may sometimes be imprecise, it is still better than random guessing. Every bumper is mounted on two touch sensors. We tested all the unused touch sensors in LegoLab, and found the the raw value returned by SensorPort.readRawValue() ranged in 181-185 with readings from the individual sensor being fairly consistent. We were able to pair touch sensors to get raw values of 98, 99 and 100. It was possible to get readings of +/- 3, but most readings of the paired sensors were the same. Because the individual sensors are paired with another sensor with similar raw value, we are also able to detect which bumper is pressed, even when only one sensor is pressed. Although detecting which bumper is pressed using the raw values, may sometimes be imprecise, it is still better than random guessing.
```java
int value = SensorPort.S1.readRawValue();
if ((value >= 100 && value < 105) || (value >= 184 && value <= 187) ) { // Left side pressed
Car.turnLeft();
} else if (value <= 98 || (value >= 179 && value <= 181)) { // Right side pressed
Car.turnRight();
} else { // Back bumper pressed
if (AvoidEdge.wasWhiteRightLast) {
Car.turnLeft();
} else {
Car.turnRight();
}
}
```
Code showing bumper selection.
We have found that we are surprisingly good at detecting which sensors have been activated. Before testing we considered using an average value over the latest measurements, an idea we discarded, because our experiments showed it was unnecessary. We even considered connecting the front bumper to the side and rear bumpers, in order to free up a sensor port. We ended up keeping them separate, as adding another sensor would push the robot above the weight requirement. We have found that we are surprisingly good at detecting which sensors have been activated. Before testing we considered using an average value over the latest measurements, an idea we discarded, because our experiments showed it was unnecessary. We even considered connecting the front bumper to the side and rear bumpers, in order to free up a sensor port. We ended up keeping them separate, as adding another sensor would push the robot above the weight requirement.
... ...
......