... | ... | @@ -117,3 +117,134 @@ We believe that a way to make this work could be done by creating a new behavior |
|
|
|
|
|
When creating our wrestling robot, we used the alternated code Behavior.java, Arbitrator.java and BumperCar.java from [8]. When using this code the interruption worked, since we here were able to change the priority dynamically.
|
|
|
|
|
|
|
|
|
## Opening tests with the sumo robot
|
|
|
After experimenting with the above exercises we went on to try to program some simple features which should be used in a sumo wrestling contest. First we wanted to make sure that the robot would stay inside the white lines so it would not “kill” itself during a battle. To test this we made a test environment with two pieces of paper on the floor where we wanted the robot to drive back and forth when detecting the white paper with the two light sensors which was placed in the front and the back of the robot (see Figure 1 and 3). The test went fine and we made the robot work within the environment as we wanted it to.
|
|
|
|
|
|
|
|
|
![IMG_1761](http://gitlab.au.dk/uploads/u4099/legolabtimadala/34da1a6866/IMG_1761.JPG)
|
|
|
##### Figure 3: the backend of the robot where one of the light sensors are placed
|
|
|
|
|
|
|
|
|
### Testing the forklift arm and kicker
|
|
|
We now wanted to test out the forklift and the kicker arm. We have implemented a touch sensor in the front of the robot as seen in [Figure 1] which we would use to make the robot aware of enemies when being close. When the touch sensor is being activated we made the arms kick and also keep moving forward so we could, hopefully, push the enemies outside the sumo area in a battle [video 1].
|
|
|
|
|
|
[![image alt text](http://img.youtube.com/vi/GaNep60og0A/0.jpg)](http://www.youtube.com/watch?v=GaNep60og0A)
|
|
|
##### Video 1: [1]
|
|
|
|
|
|
|
|
|
|
|
|
The forklift operates very well on light items, but when trying it against other robots, the build was not strong enough to lift them. We therefore modified our legocar to be more robust, but to do this, we exchanged the touch sensor with a sonar to measure if our opponent was in the distance of our forklift.
|
|
|
|
|
|
### Wrestling robot
|
|
|
Goal: The main goal of our robot is to be able to stay within the wrestlingarea and not cross the edge. Of course, one way to do this is to not let the robot move at all. This would be rather boring instead we just drive forward until light sensors registers the white colored edge. To not drive over the edge, the robot then turns and drives forward again. This behaviour depends on the three light sensors that is placed on the front and back of the car. When testing it on the wrestling area, we observed, that when turning on the white colored edge, the backend of the robot fell over the edge. This was due to the fact, that the code for the front sensor:
|
|
|
|
|
|
```
|
|
|
Motor.B.backward();
|
|
|
Motor.C.backward();
|
|
|
int now = (int)System.currentTimeMillis();
|
|
|
while (!_suppressed && ((int)System.currentTimeMillis()< now + 2000) )
|
|
|
{
|
|
|
Thread.yield(); //don't exit till suppressed
|
|
|
}
|
|
|
Motor.B.rotate(-720, true);
|
|
|
Motor.C.stop();
|
|
|
while (!_suppressed && Motor.B.isMoving() )
|
|
|
{
|
|
|
Thread.yield(); //don't exit till suppressed
|
|
|
}
|
|
|
Motor.B.stop();
|
|
|
Motor.C.stop();
|
|
|
```
|
|
|
##### Code Snippet 3
|
|
|
|
|
|
was not suppressed by the light sensor on the back of the robot when this measured a white area. This resulted in the robot falling over the edge.
|
|
|
|
|
|
To overcome this obstacle, we changed the priority of the action() when running, so the takeControl could be triggered and hereby start driving away from the edge when the light sensor on the back registered the white area.
|
|
|
|
|
|
```
|
|
|
public int takeControl() {
|
|
|
|
|
|
if ((frontRightls > whiteThreshold) || (frontLeftls > whiteThreshold) || (backRightls > whiteThreshold))
|
|
|
return 150;
|
|
|
if (_active)
|
|
|
return 125;
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public void action() {
|
|
|
_suppressed = false;
|
|
|
_active = true;
|
|
|
```
|
|
|
##### Codesnippet 4
|
|
|
|
|
|
|
|
|
Beside, pushing the escape-button, this behavior has top priority.
|
|
|
|
|
|
To be able to push our opponent over the edge, we created a forklift that is triggered when our sonar measures and object within the distance of 8 cm. This behavior has third priority. The only problem we experienced here was that, when lifting the forklift, the arm came in front of the sonar. Therefore, we had to stop the readings from the sonar or not let the takeControl be executed when the forklift is activated. We chose the last option, which only trigger the takeControl() if the action() is not active:
|
|
|
|
|
|
```
|
|
|
public int takeControl()
|
|
|
{
|
|
|
|
|
|
if (sonarDistance < 14 && !active )
|
|
|
return 100;
|
|
|
return 0;
|
|
|
}
|
|
|
```
|
|
|
##### Code Snippet 5
|
|
|
|
|
|
Furthermore, the readings from the sonar is handled within another thread so it does not give any latency on executing the code.
|
|
|
|
|
|
Our wrestling robot then implements following behavior priority:
|
|
|
|
|
|
![firstversionbehavior](http://gitlab.au.dk/uploads/u4099/legolabtimadala/55e67d50f5/firstversionbehavior.png)
|
|
|
##### Figure 4: behavior control of our wrestling car. 1st priority is on top(Escape-button) and lowest priority is on the bottom (no input).
|
|
|
|
|
|
|
|
|
To control the behavior of the robot we have implemented the arbitrator [5] and the behavior is defined from [6].
|
|
|
|
|
|
## Final Results
|
|
|
We ended out with a robot with a forklift attached in the front which would be activated by a sonar sensor [Figure 5]. We did not add extra LEGO bricks to make the robot heavier or build a fort around it, this ended out to be the main reason why we did not have a big chance against other robots.
|
|
|
|
|
|
|
|
|
![IMG_1771](http://gitlab.au.dk/uploads/u4099/legolabtimadala/8a35cba1b9/IMG_1771.JPG)
|
|
|
##### Figure 5: The final fighting robot with forklift in the front
|
|
|
|
|
|
|
|
|
We tried “fighting” against other robots in the battle arena [Video 2, Video 3, Video 4], where we, in the videos, did not win. But our robot almost did what we expected during the fight. The forklift did not do as much good as we have hoped, perhaps because the other robot had to be in a precise spot to activate the sonar sensor and thereby the forklift. Our robot still managed to stay inside the white lines in the arena which was one of our goals.
|
|
|
|
|
|
[![image alt text](http://img.youtube.com/vi/Atu7SQaY1To/0.jpg)](http://www.youtube.com/watch?v=Atu7SQaY1To)
|
|
|
##### Video 2: First Duel [2]
|
|
|
|
|
|
[![image alt text](http://img.youtube.com/vi/GTRwIvCHgnk/0.jpg)](http://www.youtube.com/watch?v=GTRwIvCHgnk)
|
|
|
##### Video 3: Second Duel [3]
|
|
|
|
|
|
[![image alt text](http://img.youtube.com/vi/PV5Hmiidi6o/0.jpg)](http://www.youtube.com/watch?v=PV5Hmiidi6o)
|
|
|
##### Video 4: Fourth Duel [4]
|
|
|
|
|
|
|
|
|
## References
|
|
|
1. [Video 1: ](https://youtu.be/GaNep60og0A)
|
|
|
|
|
|
2. [Video 2: First Duel](http://youtu.be/Atu7SQaY1To)
|
|
|
|
|
|
3. [Video 3 - Second Duel](http://youtu.be/GTRwIvCHgnk)
|
|
|
|
|
|
4. [Video 4: Fourth Duel](http://youtu.be/PV5Hmiidi6o)
|
|
|
|
|
|
5. (http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson9.dir/Arbitrator.java)
|
|
|
|
|
|
6. (http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson9.dir/Behavior.java)
|
|
|
|
|
|
7. (http://www.lejos.org/nxt/nxj/tutorial/Behaviors/BehaviorProgramming.htm)
|
|
|
|
|
|
8. (http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson9.dir/Lesson.html)
|
|
|
|
|
|
9. [Arbitrator1.java](https://www.dropbox.com/s/umt8e82amvlepic/Arbitrator1.java?dl=0)
|
|
|
|
|
|
10. [Behavior1.java](https://www.dropbox.com/s/2wlwgqw1r37l86i/Behavior1.java?dl=0)
|
|
|
|
|
|
11. [wrestBehave.java](https://www.dropbox.com/s/sx57lsqohbhvfln/wrestBehave.java?dl=0) |