marvin:ecp4
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
marvin:ecp4 [2009/01/28 12:50] – deva | marvin:ecp4 [2009/01/29 11:00] (current) – rieper | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | =====Stikord===== | + | <texit info> |
- | * Stadigt voksende klassediagram | + | author=Johnny Rieper, Bent Bisballe Nyeng and Kasper Sohn |
- | * Behavios | + | title=Marvin - The Balancing Robot. |
- | * Prioriteter | + | </ |
- | * Resurse fordeling | + | |
- | ======End course project, lab report 4====== | + | ======Lab report 4 - Behaviour Control====== |
**Date:** January 16nd 2009\\ | **Date:** January 16nd 2009\\ | ||
**Duration of activity:** 8-16\\ | **Duration of activity:** 8-16\\ | ||
Line 11: | Line 10: | ||
=====Project Goal===== | =====Project Goal===== | ||
- | Make drive autonomous, avoiding obstacles, using a behaviour model. | + | Make the robot drive autonomously, avoiding obstacles |
=====Plan===== | =====Plan===== | ||
- | * Move balance code to a thread. | + | * Move balance |
- | * Make control parameters writeable from outside the motor thread to make it possible to move. | + | * Make control parameters writeable from outside the motor thread to make it possible to drive around. |
- | * Copy code from previous Behaviour project ([[marvin: | + | * Copy code from previous Behaviour project |
- | * Modify the code to make it fit the Marvin. | + | * Modify the code to make it fit Marvin. |
- | === The Ultrasonic Sensor === | + | =====Theory===== |
+ | ====The Ultrasonic Sensor==== | ||
+ | Ultrasonic sensors work on a principle similar to radar or sonar by emitting an impulse and interpreting the echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor. The time interval between the emitted and received signal is then calculated in order to determine a distance to a given object. The ultrasonic sensors are also known as transducers when they both send and receive signals. The Ultrasonic Sensor(([[http:// | ||
- | Ultrasonic sensors work on a principle similar to radar or sonar by emitting an impulse and interpreting the echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor. The timer interval between the emitted and received signal is then calculated in order to determine a distance to a given object. The ultrasonic sensors are also known as transducers when they both send and receive signals. The Ultrasonic Sensor | + | {{ : |
- | {{ :marvin:sonic.png }} | + | ====Knowledge Learned from Previous Lessons==== |
+ | Prior to using a sensor for a specific purpose it is important to investigate the main use for the sensor. For example in lab session 4 (([[http:// | ||
- | === Knowledge learned from previous lessons === | + | [[http://www.youtube.com/ |
- | Prior to using a sensor for a specific purpose it is important to investigate the main use for the sensor. For example in lab session 4 (([[marvin:lab4]])) we used the light-sensor as an input for measuring tilt of the robot. Or in other words, it was not the primary use for the sensor we used it for. Another example is the ultrasonic sensor (([[marvin::lab2]])) which operates fairly precise when operated at an angle of 90 degrees to the wall, because is uses echo for measurement. When the angle was shifted to one side the sensor became increasingly inaccurate. Again you have to closely investigate the capabilities and limitations of the sensor one plans to use. As the ultrasonic sensor depends on sound, the primary limitations are echo delays and angle shifts. Therefore the best readings will be available when the sensor is positioned directly in in front of a wall. And the best readings will also be available when to sensor is close to the wall due to the fact that echoes will travel in different directions. These limitations will not be a problem in our project due to the fact that we only use the ultrasonic sensor to avoid that Marvin will hit any walls. | + | {{youtube> |
- | + | ||
- | =====The Behavior class===== | + | |
- | + | ||
- | ===RandomDrive=== | + | |
- | + | ||
- | The thread drives forward with different random numbers on each motor. This means that Marvin not necessarily (in fact not likely) will drive straight ahead. It will do this within a time interval. All these intervals are computed using a random function from Math library. | + | |
- | + | ||
- | ===AvoidFront=== | + | |
- | + | ||
- | Implemented using a sonic sensor. The thread activates a backward motion and do this for X seconds to get a away from the obstacle. Afterwards Marvin stops and turns left corresponding to a 90 degree turn to the left. | + | |
- | + | ||
- | === BTControl === | + | |
- | The thread handles blutooth communication in order to control Marvin with a remote control. The arrow keys on the computer is used instead of a remote. | + | |
+ | =====Implementation===== | ||
+ | ====The Behavior Class==== | ||
{{ : | {{ : | ||
- | A platform for a behavior | + | A platform for a behaviour |
- | suppression mechanism. An actual | + | It has access to control the Marvin by means of the control methods (forward, backward, left and right). |
- | the Behavior class. Each behavior | + | However, access can be suppressed so that the motor commands will not be performed while the behaviour |
- | It has access to control the Marvin by means of the control methods | + | |
- | (forward, backward, left and right). | + | |
- | However, access can be suppressed so that the motor commands | + | |
- | will not be performed while the behavior | + | |
^ Variable | ^ Variable | ||
Line 71: | Line 57: | ||
// Clone the Behavior list. | // Clone the Behavior list. | ||
this.behaviors = new ArrayList(); | this.behaviors = new ArrayList(); | ||
+ | |||
for(int i = 0; i < behaviors.size(); | for(int i = 0; i < behaviors.size(); | ||
Behavior b = (Behavior)behaviors.get(i); | Behavior b = (Behavior)behaviors.get(i); | ||
Line 127: | Line 114: | ||
} | } | ||
</ | </ | ||
+ | The '' | ||
+ | ====The RandomDrive Class==== | ||
+ | This behaviour drives in one of four random directions for a random number of milliseconds. | ||
+ | All of these numbers are computed using a random function from Java Math library. | ||
- | An example of a behavoir: | + | ====The AvoidFront Class==== |
+ | Implemented using a ultrasonic sensor. The behaviour activates a backward motion and do this for a number of milliseconds to back away from the obstacle. Afterwards Marvin stops and turns right corresponding to an approximately 90 degree turn. The code for the essential parts of the '' | ||
<code java> | <code java> | ||
public class AvoidFront extends Behavior | public class AvoidFront extends Behavior | ||
Line 159: | Line 151: | ||
} | } | ||
</ | </ | ||
- | The full source code for these classes can be found in the files '' | + | ====The BTController Class==== |
+ | The thread handles bluetooth communication | ||
- | [[http://www.youtube.com/watch?v=1gR1UL5FbTQ|{{: | + | The full source code for these classes can be found in the files '' |
marvin/ecp4.txt · Last modified: 2009/01/29 11:00 by rieper