marvin:lab8
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
marvin:lab8 [2008/11/07 13:01] – deva | marvin:lab8 [2008/11/09 10:21] – deva | ||
---|---|---|---|
Line 15: | Line 15: | ||
====Execution==== | ====Execution==== | ||
We modified the code to be more modular. This was not part of the exercise, but it made it a lot easier to test individual modules. Below follows | We modified the code to be more modular. This was not part of the exercise, but it made it a lot easier to test individual modules. Below follows | ||
+ | |||
+ | {{marvin: | ||
* The constant tooCloseThreshold was initially set to be 20 cm, but this was not enough to take into account our modified Marvin which has a plate seperating the two lightsensors. There this constant was changed to 35 instead. | * The constant tooCloseThreshold was initially set to be 20 cm, but this was not enough to take into account our modified Marvin which has a plate seperating the two lightsensors. There this constant was changed to 35 instead. | ||
* The constants in the thread RandonDrive.java has been change to accomdate more action, less waiting. We wanted Marvin to move longere before there were the tread ended. This caused Marvin to be more " | * The constants in the thread RandonDrive.java has been change to accomdate more action, less waiting. We wanted Marvin to move longere before there were the tread ended. This caused Marvin to be more " | ||
+ | **Video of Marvin running with default code**\\ | ||
+ | [[http:// | ||
===RandomDrive=== | ===RandomDrive=== | ||
Line 26: | Line 30: | ||
This thread waits for 10 seconds, then stops and plays a sound while printing an s on the screen. | This thread waits for 10 seconds, then stops and plays a sound while printing an s on the screen. | ||
+ | ====Modular Priority System==== | ||
+ | The priority handling was in the initial code created by handing pointers to all lower priority Behavior to each Behavior, as shown in the code below: | ||
+ | <code java> | ||
+ | rd = new RandomDrive(" | ||
+ | af = new AvoidFront (" | ||
+ | ps = new PlaySounds ("Play ", | ||
+ | </ | ||
+ | This however makes shuffling of the priorities, as well as making the introduction of new Behaviors, a very tedious task. We therefore rewrote the priority system to make it more modular and flexible.\\ | ||
+ | Below is the new stucture: | ||
+ | <code java> | ||
+ | ArrayList behaviors = new ArrayList(); | ||
+ | RandomDrive rd; | ||
+ | AvoidFront af; | ||
+ | PlaySounds ps; | ||
+ | DriveTowardsLight dl; | ||
- | http://java.sun.com/j2se/1.4.2/ | + | rd = new RandomDrive(" |
+ | dl = new DriveTowardsLight(" | ||
+ | af = new AvoidFront(" | ||
+ | ps = new PlaySounds(" | ||
+ | </ | ||
+ | The idea is to use an array of Behaviors containing all lower priority Behaviors in each Behavior.\\ | ||
+ | this array is copied and stored in the constructor of each Behavior, and can then be iterated whenever suppression of the lower levels are needed. | ||
+ | <code java> | ||
+ | private ArrayList behaviors;; | ||
- | **Video and pictures**\\ | + | public Behavior(String name, ArrayList behaviors) |
- | [[http://www.youtube.com/v/OuSbJ5-chXI|{{marvin: | + | { |
- | {{marvin: | + | . |
+ | . | ||
+ | . | ||
+ | |||
+ | // Clone the Behavior list. | ||
+ | this.behaviors = new ArrayList(); | ||
+ | for(int i = 0; i < behaviors.size(); | ||
+ | Behavior b = (Behavior)behaviors.get(i); | ||
+ | this.behaviors.add(b); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | public void suppressLower() | ||
+ | { | ||
+ | for(int i = 0; i < behaviors.size(); | ||
+ | Behavior b = (Behavior)behaviors.get(i); | ||
+ | b.setSuppress(true); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ====Java Thread==== | ||
+ | The '' | ||
+ | |||
+ | |||
+ | ====Threaded implementation of " | ||
+ | Bent writes this part | ||
**Video for "Drive towards light test" | **Video for "Drive towards light test" | ||
- | [[http:// | + | [[http:// |
+ | |||
+ | ====Conclusion==== | ||
+ | The layered behavior model seems to work very well for the implementation of an autonomous roboot. We believe that with an added push sensor Marvin would be able to navigate in any room avoiding any obstacles and find the exit with lights. |
marvin/lab8.txt · Last modified: 2008/11/14 08:50 by rieper