zteel created page: Week11 sumo wrestling robots authored by Troels Fleischer Skov Jensen's avatar Troels Fleischer Skov Jensen
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
**Group members participating:** Sune Brinch Sletgård, Claus Hedeager Rasmussen, Klaus Fyhn Jacobsen, Troels Fleischer Skov Jensen **Group members participating:** Sune Brinch Sletgård, Claus Hedeager Rasmussen, Klaus Fyhn Jacobsen, Troels Fleischer Skov Jensen
**Activity duration:** (thursday?, friday?, sunday?, thursday?, friday?) **Activity duration:** (thursday?, friday?, sunday?, thursday?, friday?, sunday?, monday?)
# Goal # Goal
The goal is to experiment with programming a robot with different behaviours resulting in a sumo wrestling LEGO robot. The goal is to experiment with programming a robot with different behaviours resulting in a sumo wrestling LEGO robot.
...@@ -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; }
} }
} }
``` ```
...@@ -211,13 +211,24 @@ We also found that we could get more force by making the robot drive the other w ...@@ -211,13 +211,24 @@ We also found that we could get more force by making the robot drive the other w
![small_IMAG0696](http://gitlab.au.dk/uploads/lego-group-3/lego/9be6f4e5eb/small_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 Bumpy (Brutally unnatural monster of passive yellowness), 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
Diagram 1. Diagram showing the behaviors.
Our final implementation can be found on GitLab[8]. Our final implementation can be found on GitLab[8].
### Testing the robot
![small_IMAG0697](http://gitlab.au.dk/uploads/lego-group-3/lego/a13b8793bd/small_IMAG0697.jpg)
Image 6: Test robot
We created another robot as seen in the image above. The original purpose of the robot was to test the ultrasonic sensor, since it was difficult to do this without having an opponent to detect. We also had a lot of use out of it to help us think of ideas and in general test our robot without help from other groups.
# 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.
...@@ -248,4 +259,3 @@ https://gitlab.au.dk/lego-group-3/lego/blob/master/Week9/EnemyDetector.java ...@@ -248,4 +259,3 @@ https://gitlab.au.dk/lego-group-3/lego/blob/master/Week9/EnemyDetector.java
![small_IMAG0697](http://gitlab.au.dk/uploads/lego-group-3/lego/a13b8793bd/small_IMAG0697.jpg)