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
publicvoidaction(){
publicvoidaction(){
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=newThread(newRunnable(){
_ping=newThread(newRunnable(){
publicvoidrun(){
publicvoidrun(){
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
publicbooleanbwd(){
publicbooleanbwd(){
longtime=System.currentTimeMillis();
longtime=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;returntrue;}
if(_suppressed){_suppressed=false;returntrue;}
if(takeControl()){returntrue;}
if(takeControl()){returntrue;}
}
}
BumperCar.leftMotor.stop();
BumperCar.leftMotor.stop();
BumperCar.rightMotor.stop();
BumperCar.rightMotor.stop();
returnfalse;
returnfalse;
}
}
privatevoidturn(){
privatevoidturn(){
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
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:
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.