marvin:ecp5
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:ecp5 [2009/01/28 15:52] – deva | marvin:ecp5 [2009/01/29 00:16] – rieper | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | =====Stikord===== | + | <texit info> |
- | * Bluetooth | + | author=Johnny Rieper, Bent Bisballe Nyeng and Kasper Sohn |
- | * Protokollen (driver interfaces) | + | title=Marvin - The Balancing Robot. |
+ | </ | ||
- | ======End course project, lab report 5====== | + | ======Lab report 5 - Bluetooth controlled robot====== |
**Date:** January 19nd and 20th 2009\\ | **Date:** January 19nd and 20th 2009\\ | ||
**Duration of activity:** 8-16 (both days)\\ | **Duration of activity:** 8-16 (both days)\\ | ||
Line 12: | Line 13: | ||
=====Plan===== | =====Plan===== | ||
- | * Make pc bluetooth app read from keyboard arrows to determine control direction. | ||
* Make a bluetooth client code Behaviour on the Marvin, that can receive numbers and act on them. | * Make a bluetooth client code Behaviour on the Marvin, that can receive numbers and act on them. | ||
- | * Make a simple | + | * Make PC bluetooth |
- | FIXME: Insert | + | |
- | [[http:// | + | =====The protocol===== |
- | {{youtube> | + | {{ :marvin: |
+ | |||
+ | From wikipedia: //" | ||
+ | LeJOS has built an entire framework for bluetooth communication, | ||
+ | (([[http:// | ||
+ | We do not want to go further into the details of the protocol itself, but the way the device is shared can eventually end up in data loss(([[http:// | ||
+ | |||
+ | On the PC LeJOS has also made a bluetooth interface. This works exactly the same as the one on the NXT, and we therefore simply had to make a connection | ||
+ | |||
+ | Lejos has put a lot of effort into making the bluetooth communication easy to use, and the implementation were therefore quite straight forward. Observe the resulting code below. | ||
+ | |||
+ | We experienced a lot of slowdown in the balancing thread whenever the bluetooth communication was running, and we had to disable it entirely at numerous occations to avoid the robot falling over.\\ | ||
+ | We later discovered that the problem could be worked around by disabling some of the other behavoir threads to release more resources, and make Marvin rebalance itself while driving around | ||
+ | |||
+ | Here is a movie of the resulting remote controlled robot, with all other behaviours disabled:\\ | ||
+ | [[http:// | ||
+ | {{youtube> | ||
=====The BTControl class===== | =====The BTControl class===== | ||
{{ : | {{ : | ||
- | Bluetooth control behavior. It reads integers from a bluetooth | + | Bluetooth control behavior. It reads integers from a bluetooth input stream, interpreting them as keycodes. |
- | input stream, interpreting them as keycodes. | + | It reacts only on the keycodes connectred with the arrow keys (up, down, left, right) and tells Marvin to drive accordingly. |
- | It reacts only on the keycodes connectred with the arrow keys (up, | + | |
- | down, left, right) and tells Marvin to drive accordingly. | + | |
^ Key ^ KeyCode ^ Variable | ^ Key ^ KeyCode ^ Variable | ||
Line 79: | Line 93: | ||
</ | </ | ||
- | And on the PC a window (JFrame) captures keyboard input and redirects their keycode values to the bluetooth stream: | + | On the PC, a window (JFrame) captures keyboard input and redirects their keycode values to the bluetooth stream: |
<code java> | <code java> | ||
NXTComm nxtComm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH); | NXTComm nxtComm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH); |
marvin/ecp5.txt · Last modified: 2009/01/29 10:58 by rieper