marvin:ecp5
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
marvin:ecp5 [2009/01/29 00:15] – rieper | marvin:ecp5 [2009/01/29 10:58] (current) – rieper | ||
---|---|---|---|
Line 5: | Line 5: | ||
======Lab report 5 - Bluetooth controlled robot====== | ======Lab report 5 - Bluetooth controlled robot====== | ||
- | **Date:** January 19nd and 20th 2009\\ | + | **Date:** January 19nd 2009\\ |
- | **Duration of activity:** 8-16 (both days)\\ | + | **Duration of activity:** 8-16\\ |
**Participants: | **Participants: | ||
Line 16: | Line 16: | ||
* Make PC bluetooth application read from keyboard arrows to determine control direction. | * Make PC bluetooth application read from keyboard arrows to determine control direction. | ||
- | + | =====Theory==== | |
- | =====The protocol===== | + | ====The Protocol==== |
{{ : | {{ : | ||
- | From wikipedia: //" | + | From wikipedia: //" |
LeJOS has built an entire framework for bluetooth communication, | LeJOS has built an entire framework for bluetooth communication, | ||
- | (([[http:// | + | (([[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:// | + | 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 (listening on the NXT and connecting on the PC) and then creating input/ | 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 (listening on the NXT and connecting on the PC) and then creating input/ | ||
- | 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. | + | 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 | + | 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 |
- | We later discovered that the problem could be worked around by disabling some of the other behavoir | + | We later discovered that the problem could be worked around by disabling some of the other behaviour |
Here is a movie of the resulting remote controlled robot, with all other behaviours disabled:\\ | Here is a movie of the resulting remote controlled robot, with all other behaviours disabled:\\ | ||
Line 36: | Line 36: | ||
{{youtube> | {{youtube> | ||
- | =====The BTControl | + | As it can be seen from the video, Marvin is not exactly reacting real-time to the control changes. This is due to the way the BTControl has been implemented, |
+ | |||
+ | =====Implementation===== | ||
+ | ====The BTControl | ||
{{ : | {{ : | ||
- | Bluetooth control | + | Bluetooth control |
- | It reacts only on the keycodes | + | It reacts only on the keycodes |
^ Key ^ KeyCode ^ Variable | ^ Key ^ KeyCode ^ Variable | ||
Line 69: | Line 72: | ||
case directionLeft: | case directionLeft: | ||
left(200); | left(200); | ||
+ | |||
+ | |||
break; | break; | ||
Line 93: | Line 98: | ||
</ | </ | ||
- | And on the PC a window (JFrame) | + | ====The PCController Class==== |
+ | On the PC, we use a window (JFrame) | ||
<code java> | <code java> | ||
NXTComm nxtComm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH); | NXTComm nxtComm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH); |
marvin/ecp5.1233184515.txt.gz · Last modified: 2009/01/29 00:15 by rieper