zteel created page: Week11 sumo wrestling robots authored by Klaus Fyhn Jacobsen's avatar Klaus Fyhn Jacobsen
...@@ -50,12 +50,12 @@ We want a behavior that if the ESCAPE button is pressed, System.Exit(0) is calle ...@@ -50,12 +50,12 @@ We want a behavior that if the ESCAPE button is pressed, System.Exit(0) is calle
When the escape button is pressed, the robot takes the following action: When the escape button is pressed, the robot takes the following action:
```java ```java
public void action() { public void action() {
LCD.drawString("Now exiting...", 0, 0); LCD.drawString("Now exiting...", 0, 0);
BumperCar.leftMotor.stop(); BumperCar.leftMotor.stop();
BumperCar.rightMotor.stop(); BumperCar.rightMotor.stop();
System.exit(0); System.exit(0);
} }
``` ```
Which simply stops the motors and exits the system if the ESCAPE button is pressed. Which simply stops the motors and exits the system if the ESCAPE button is pressed.
...@@ -75,14 +75,14 @@ Getting the distance takes a little time, which goes against the contract of a b ...@@ -75,14 +75,14 @@ Getting the distance takes a little time, which goes against the contract of a b
```java ```java
_ping = new Thread(new Runnable(){ _ping = new Thread(new Runnable(){
public void run() { public void run() {
while (true) { while (true) {
sonar.ping(); sonar.ping();
_distance = sonar.getDistance(); _distance = sonar.getDistance();
Delay.msDelay(20); Delay.msDelay(20);
} }
}}); }});
_ping.start(); _ping.start();
``` ```
...@@ -93,44 +93,44 @@ To get the robot to move backwards for one second before turning, the following ...@@ -93,44 +93,44 @@ To get the robot to move backwards for one second before turning, the following
```java ```java
BumperCar.leftMotor.backward(); BumperCar.leftMotor.backward();
BumperCar.rightMotor.backwart(); BumperCar.rightMotor.backwart();
Delay.msDelay(1000); Delay.msDelay(1000);
``` ```
#### Making call interruptible #### Making call interruptible
A problem with the implementation of Detect Wall is that both delay and the last rotate is blocking calls, meaning that we cannot do anything new. This have been solved by making small methods that do the same, but we have use some busy waiting instead, where we do checks if it should start from the beginning or if it has been suppressed. A problem with the implementation of Detect Wall is that both delay and the last rotate is blocking calls, meaning that we cannot do anything new. This have been solved by making small methods that do the same, but we have use some busy waiting instead, where we do checks if it should start from the beginning or if it has been suppressed.
```java ```java
// The backwards method returns if it has been interrupted // The backwards method returns if it has been interrupted
public boolean bwd() { public boolean bwd() {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
BumperCar.leftMotor.backward(); BumperCar.leftMotor.backward();
BumperCar.rightMotor.backward(); BumperCar.rightMotor.backward();
while (System.currentTimeMillis() < time + 1000) { while (System.currentTimeMillis() < time + 1000) {
if (_suppressed) {_suppressed = false; return true;} if (_suppressed) {_suppressed = false; return true;}
if (takeControl()){ return true; } if (takeControl()){ return true; }
} }
BumperCar.leftMotor.stop(); BumperCar.leftMotor.stop();
BumperCar.rightMotor.stop(); BumperCar.rightMotor.stop();
return false; return false;
} }
private void turn() { private void turn() {
BumperCar.rightMotor.resetTachoCount(); BumperCar.rightMotor.resetTachoCount();
BumperCar.rightMotor.backward(); BumperCar.rightMotor.backward();
BumperCar.leftMotor.backward(); BumperCar.leftMotor.backward();
while (BumperCar.rightMotor.getTachoCount() > -180) { while (BumperCar.rightMotor.getTachoCount() > -180) {
if (_suppressed) {_suppressed = false; return;} if (_suppressed) {_suppressed = false; return;}
if(takeControl()){ action(); return; } if(takeControl()){ action(); return; }
} }
BumperCar.leftMotor.stop(); BumperCar.leftMotor.stop();
BumperCar.rightMotor.backward(); BumperCar.rightMotor.backward();
while (BumperCar.rightMotor.getTachoCount() > -360) { while (BumperCar.rightMotor.getTachoCount() > -360) {
if (_suppressed) {_suppressed = false; return;} if (_suppressed) {_suppressed = false; return;}
if(takeControl()){ action(); return; } if(takeControl()){ action(); return; }
} }
} }
``` ```
...@@ -192,7 +192,7 @@ The implementation is found on GitLab[9]. ...@@ -192,7 +192,7 @@ The implementation is found on GitLab[9].
#### Bumpers #### Bumpers
By discarding the motor and the ultrasonic sensor, we suddenly had a bit more weight to play with, so we could remount our back wall with touch sensors. And because we no longer needed a sensor port for the ultrasonic sensor, we were able to separate the front wall from the three other walls. The change picture below. By discarding the motor and the ultrasonic sensor, we suddenly had a bit more weight to play with, so we could remount our back wall with touch sensors. And because we no longer needed a sensor port for the ultrasonic sensor, we were able to separate the front wall from the three other walls. The change picture below.
![IMAG0695](http://gitlab.au.dk/uploads/lego-group-3/lego/befac979c4/IMAG0695.jpg) ![small_IMAG0695](http://gitlab.au.dk/uploads/lego-group-3/lego/66bec032dd/small_IMAG0695.jpg)
Image 4: The robot after removing the ultrasonic sensor and adding touch sensors in the back. Image 4: The robot after removing the ultrasonic sensor and adding touch sensors in the back.
...@@ -209,13 +209,15 @@ We tried setting the motor speed to the maximum possible. This resulted in the r ...@@ -209,13 +209,15 @@ We tried setting the motor speed to the maximum possible. This resulted in the r
We also found that we could get more force by making the robot drive the other way, one reason was that we realised that if the front bumper was pressed, the wheels had a small friction against our construction, but also our weight distribution was more fitting for the robot to drive “backwards”, so we modified the robot to drive the other, which was the final modification to the robot and can be seen in the picture below. We also found that we could get more force by making the robot drive the other way, one reason was that we realised that if the front bumper was pressed, the wheels had a small friction against our construction, but also our weight distribution was more fitting for the robot to drive “backwards”, so we modified the robot to drive the other, which was the final modification to the robot and can be seen in the picture below.
![IMAG0696](http://gitlab.au.dk/uploads/lego-group-3/lego/5a1736ce12/IMAG0696.jpg) ![small_IMAG0696](http://gitlab.au.dk/uploads/lego-group-3/lego/9be6f4e5eb/small_IMAG0696.jpg)
Image 5: Final version of the robot, after moving the light sensor to the other end and making that the front of the robot. Image 5: Final version of the robot, after moving the light sensor to the other end and making that the front of the robot.
We ended up with the following behavior priority queue: We ended up with the following behavior priority queue:
EXIT > Front touch > Sides touched > Avoid Edge > Cruise EXIT > Front touch > Sides touched > Avoid Edge > Cruise
Our final implementation can be found on GitLab[8].
# Conclusion # Conclusion
We have been very limited by the weight limitation, because of our vast amounts of sensors and especially the rcx cables. We have found that a motor mounted ultrasonic sensor is simply too slow to use in a sumo fight, a solution could have been to use two ultrasonic sensors, but we did not have weight or sensor ports to spare. Most interestingly is our experience with using multiple touch sensors connected to the same port through rcx cables. It was surprising how well we could distinguish the sensors solely because of small differences in the measured raw value. We have been very limited by the weight limitation, because of our vast amounts of sensors and especially the rcx cables. We have found that a motor mounted ultrasonic sensor is simply too slow to use in a sumo fight, a solution could have been to use two ultrasonic sensors, but we did not have weight or sensor ports to spare. Most interestingly is our experience with using multiple touch sensors connected to the same port through rcx cables. It was surprising how well we could distinguish the sensors solely because of small differences in the measured raw value.
...@@ -246,15 +248,3 @@ https://gitlab.au.dk/lego-group-3/lego/blob/master/Week9/EnemyDetector.java ...@@ -246,15 +248,3 @@ https://gitlab.au.dk/lego-group-3/lego/blob/master/Week9/EnemyDetector.java
[1], description - link
* // remember using / referencing to litteratur for higher grade than 7
![small_IMAG0695](http://gitlab.au.dk/uploads/lego-group-3/lego/66bec032dd/small_IMAG0695.jpg)
![small_IMAG0696](http://gitlab.au.dk/uploads/lego-group-3/lego/9be6f4e5eb/small_IMAG0696.jpg)
![small_IMAG0697](http://gitlab.au.dk/uploads/lego-group-3/lego/131d658b4e/small_IMAG0697.jpg)