Programming for Lego Mindstorms using Eclipse to take you back to your childhood!
-
Upload
benjamin-cabe -
Category
Technology
-
view
5.401 -
download
2
description
Transcript of Programming for Lego Mindstorms using Eclipse to take you back to your childhood!
![Page 1: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/1.jpg)
Programming forLego® Mindstorms™using Eclipseto take you back to your childhood!
Benjamin CabéOct 28th, 2009
![Page 2: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/2.jpg)
Agenda
The Mindstorms NXT brick
The LeJOS VM
Eclipse + Mindstorms = FUN!• Implementing an RSE connector• Data visualization inside an Eclipse editor• State machines modeling and code generation
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 3: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/3.jpg)
The NXT brick
32-bit ARM7 processor @48MHz
256kB of Flash
64kB of RAM
100x64 pixel LCD display
USB 2.0
Bluetooth
Open Source firmware!©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 4: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/4.jpg)
4 input ports
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 5: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/5.jpg)
3 output ports (motors)
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 6: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/6.jpg)
LeJOS NXJ VM
A tiny (10kb) but still cool Java VM• Threads / Synchronization• Exceptions• Most of the java.lang, java.util and java.io
classes• Generics, enums, « for each » loops• A “robotics”, event-based, API• Open Source!
Limitations• No Garbage Collector• No switch()
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 7: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/7.jpg)
LeJOS NXJ Eclipse plug-in
Useful to upload firmware and/or programs to the brick
Not much integrated in the IDE…
… how about leveraging DSDP/TM?!
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 8: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/8.jpg)
TM/RSE hacking
LeJOS NXJ comes with APIs to :• List/get/send files• Execute programs• Get sensor states
… it should be possible to define an RSE connector and a file subsystem…!
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 9: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/9.jpg)
Brief RSE introduction
A framework at Eclipse to connect to remote systems and provide:• remote file systems through SSH, FTP, a dedicated
agent, or whatever• remote shell access• remote process monitoring• remote debugging (gdb)
It comes with generic, reusable, UI
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 10: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/10.jpg)
TM/RSE hacking (2)
In a couple of hours:• A new 'LeJOS' system is available• An RSE file 'subsystem' allows to:
–Browse the brick's filesystem–Remotely execute programs
• Another subystem could bewritten to retrieve sensors values
Nota: Communication with the brick can be done using either BT or USB
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 11: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/11.jpg)
TM/RSE hacking (3)
Very straightforward 1..1 mapping between RSE and LEJOS APIs
Example: LejosRemoteFile implementation
public void launch() throws IOException {
LejosConnectorService connector = (LejosConnectorService) getParentRemoteFileSubSystem()
.getConnectorService();
connector.getComm().startProgram(_hostFile.getName());
}
RSE
LEJOS©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 12: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/12.jpg)
Let’s toy a cool sonar!
Follows a closed track
Scans the interior of the track with the ultrasonic sensor
Writes a binary output file into flash memory• The file will be retrieved using the RSE connector
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 13: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/13.jpg)
Robot behavior
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 14: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/14.jpg)
Robot Java program
public static void main(String[] args) {
tachoNav = new TachoNavigator(5.6f, 11.5f, Motor.A, Motor.B);
File fRadar = new File("result.radar");
FileOutputStream fosRadar = new FileOutputStream(fRadar);
tachoNav.goTo(0, TERRAIN_WIDTH, true);
while (tachoNav.isMoving()) {
int dist = ultrasonic.getDistance();
fosRadar.writeInt(dist);
}
}
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 15: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/15.jpg)
Display captured data
In an Eclipse editor associated to .radar files• Parse binary files• Process signal • sin(α)… cos(α)… Remember?!
Since the ambient noise level is also recorded, we can display it in a similar manner http://www.sxc.hu/photo/1099687
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 16: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/16.jpg)
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 17: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/17.jpg)
17
State machines modeling
LeJOS comes with an event-based robotics API, remember?
Eclipse has a bunch of cool modeling/diagramming/code generation technologies
… how about mixing both?!
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 18: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/18.jpg)
18
LeJOS Visual Development Toolkit
A state machine framework on top of LeJOS
A GMF editor
Xpand templates for code generation
An integration with the LeJOS Eclipse plugin• Auto-deployment of the binary• Communication between the brick and the IDE to
monitor the state machine
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 19: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/19.jpg)
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 20: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/20.jpg)
©2009 Sierra Wireless inc. – Made available under EPL v1.0
![Page 22: Programming for Lego Mindstorms using Eclipse to take you back to your childhood!](https://reader036.fdocuments.in/reader036/viewer/2022070316/555a2787d8b42ab3088b4b3b/html5/thumbnails/22.jpg)
If you wanna play by yourself!
http://www.mindstorms.com
http://lejos.sourceforge.net
http://www.juanantonio.info/p_articles/archive/2008/leJOSStatemachineDevelopmentToolkit.pdf
http://www.eclipse.org/dsdp/tm/
©2009 Sierra Wireless inc. – Made available under EPL v1.0