31
Comment:
|
5066
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
Describe LearningRobots here. | ## Please edit system and help pages ONLY in the master wiki! ## For more information, please see MoinMoin:MoinDev/Translation. ##master-page:FrontPage #format wiki #language en #pragma section-numbers 2 = Learning Robots = This wiki site is part of the [[https://venus.tue.nl/owinfo-cgi/owi_0695.opl?vakcode=DBD04&language=NL | Learning Robots]] module. <<TableOfContents>> == Connecting MATLAB and Arduino == === Arduino support in MATLAB === * Math``Works has a software package to support Arduino directly in MATLAB. You can find the package from [[http://www.mathworks.nl/academia/arduino-software/arduino-matlab.html | its website]]. Please notice that: * You do need to login with your MATLAB account, in order to download the package and get access to other resources such as tutorials. * Check out the [[http://www.mathworks.nl/academia/arduino-software/arduino-matlab.html]] to find a useful Webinar. * In the downloaded zip file, readme.txt has very detailed instructions for installing the firmware to Arduino and the necessary library to MATLAB. * if you plan to use servo motors, you need the [[http://arduino.cc/en/Main/ArduinoMotorShield|motor shield]] for MATLAB to control the motors properly using the given package. * To get the online documentation of the arduino class in MATLAB, type in "arduino(" and wait for a dialogue box to pop up: [[attachment:arduinomatlab.jpg|{{attachment:arduinomatlabthumb.jpg}}]] === MATLAB-Processing-Arduino: Using matlabcontrol in Processing === * The matlabcontrol library for Java is available from [[http://code.google.com/p/matlabcontrol/]] * To install the library to be used in Processing: 1. Download "matlabcontrol jar with source files included" from [[http://code.google.com/p/matlabcontrol/downloads/list]]. 1. Rename the jar file (for example, matlabcontrol-4.0.0.jar) to "matlabcontrol.jar". 1. Create a directory in your Processing library path: {{{<Sketchbook location>\libraries\matlabcontrol\library}}}, put "matlabcontrol.jar" in this directory. 1. To verify your installation, start processing, go to menu "Sketch->Import Library", you should be able to able to import "matlabcontrol": [[attachment:matlabcontrol.jpg|{{attachment:matlabcontrolthumb.jpg}}]] * Follow the [[http://code.google.com/p/matlabcontrol/wiki/Walkthrough|Walkthrough]] to understand how to communicate to MATLAB in JAVA. * Similar approach described in the [[http://code.google.com/p/matlabcontrol/wiki/Walkthrough|Walkthrough]] can be done in Processing. Take the "Hello World" example in Java: {{{ #!java public static void main(String[] args) throws MatlabConnectionException, MatlabInvocationException { //Create a proxy, which we will use to control MATLAB MatlabProxyFactory factory = new MatlabProxyFactory(); MatlabProxy proxy = factory.getProxy(); //Display 'hello world' just like when using the demo proxy.eval("disp('hello world')"); //Disconnect the proxy from MATLAB proxy.disconnect(); } }}} The same can be done in Processing by removing the "main" skeleton. However in Processing we need to catch the exceptions: {{{ #!java import matlabcontrol.internal.*; import matlabcontrol.extensions.*; import matlabcontrol.*; try { //Create a proxy, which we will use to control MATLAB MatlabProxyFactory factory = new MatlabProxyFactory(); MatlabProxy proxy = factory.getProxy(); //Display 'hello world' just like when using the demo proxy.eval("disp('hello world')"); //Disconnect the proxy from MATLAB proxy.disconnect(); } catch (Exception e) { //do nothing, or cry. } }}} Other examples in the [[http://code.google.com/p/matlabcontrol/wiki/Walkthrough|Walkthrough]] can be modified in a similar manner for Processing. * This approach has been used successfully by F.N.A. Al-Kaylani, K.J.F de Greef and N.M. Nelson in their project. See their report: [[attachment:Learning_Robots_SuggestionRobot.pdf]] === MATLAB-socket<=>socket-Processing-Arduino: Using TCP/IP client/server sockets === * Both MATLAB and Processign are able to communicate with the others over a TCP/IP connection, acting as either a client or a server. * Robbert van Vliet, Rik Vegt, Martijn Kors and Michael Geertshuis are able to use this approach in their project. In their report you can find the technical details: [[attachment:Learning_Robots_Socket.pdf]] === MATLAB-datafile-Processing-Arduino: Using a data file === * If there is no need of real time communication between MATLAB and processing, you can first let MATLAB write its output to a data file, then let Processing read from it, or vice versa. * Jelle Dekker, Laura van Geel, Jasper de Kruiff and Vincent Klerkx are very successful in applying this approach to their cleaning robot. See their report: [[attachment:Cleaning_Robot.pdf]] == Other interesting links == * NeurophNeuralNetwork * MaxJavaArduino * LegoBeyondToys * [[LegoBeyondToys/1209 | Using leJOS with Neural networks]] |
Learning Robots
This wiki site is part of the Learning Robots module.
Contents
1. Connecting MATLAB and Arduino
1.1. Arduino support in MATLAB
MathWorks has a software package to support Arduino directly in MATLAB. You can find the package from its website. Please notice that:
- You do need to login with your MATLAB account, in order to download the package and get access to other resources such as tutorials.
Check out the http://www.mathworks.nl/academia/arduino-software/arduino-matlab.html to find a useful Webinar.
- In the downloaded zip file, readme.txt has very detailed instructions for installing the firmware to Arduino and the necessary library to MATLAB.
if you plan to use servo motors, you need the motor shield for MATLAB to control the motors properly using the given package.
- To get the online documentation of the arduino class in MATLAB, type in "arduino(" and wait for a dialogue box to pop up:
1.2. MATLAB-Processing-Arduino: Using matlabcontrol in Processing
The matlabcontrol library for Java is available from http://code.google.com/p/matlabcontrol/
- To install the library to be used in Processing:
Download "matlabcontrol jar with source files included" from http://code.google.com/p/matlabcontrol/downloads/list.
- Rename the jar file (for example, matlabcontrol-4.0.0.jar) to "matlabcontrol.jar".
Create a directory in your Processing library path: <Sketchbook location>\libraries\matlabcontrol\library, put "matlabcontrol.jar" in this directory.
To verify your installation, start processing, go to menu "Sketch->Import Library", you should be able to able to import "matlabcontrol":
Follow the Walkthrough to understand how to communicate to MATLAB in JAVA.
Similar approach described in the Walkthrough can be done in Processing. Take the "Hello World" example in Java:
1 public static void main(String[] args) throws MatlabConnectionException, MatlabInvocationException 2 { 3 //Create a proxy, which we will use to control MATLAB 4 MatlabProxyFactory factory = new MatlabProxyFactory(); 5 MatlabProxy proxy = factory.getProxy(); 6 7 //Display 'hello world' just like when using the demo 8 proxy.eval("disp('hello world')"); 9 10 //Disconnect the proxy from MATLAB 11 proxy.disconnect(); 12 }
The same can be done in Processing by removing the "main" skeleton. However in Processing we need to catch the exceptions:
1 import matlabcontrol.internal.*; 2 import matlabcontrol.extensions.*; 3 import matlabcontrol.*; 4 5 try { 6 //Create a proxy, which we will use to control MATLAB 7 MatlabProxyFactory factory = new MatlabProxyFactory(); 8 MatlabProxy proxy = factory.getProxy(); 9 10 //Display 'hello world' just like when using the demo 11 proxy.eval("disp('hello world')"); 12 13 //Disconnect the proxy from MATLAB 14 proxy.disconnect(); 15 } 16 catch (Exception e) { 17 //do nothing, or cry. 18 }
Other examples in the Walkthrough can be modified in a similar manner for Processing.
This approach has been used successfully by F.N.A. Al-Kaylani, K.J.F de Greef and N.M. Nelson in their project. See their report: Learning_Robots_SuggestionRobot.pdf
1.3. MATLAB-socket<=>socket-Processing-Arduino: Using TCP/IP client/server sockets
- Both MATLAB and Processign are able to communicate with the others over a TCP/IP connection, acting as either a client or a server.
Robbert van Vliet, Rik Vegt, Martijn Kors and Michael Geertshuis are able to use this approach in their project. In their report you can find the technical details: Learning_Robots_Socket.pdf
1.4. MATLAB-datafile-Processing-Arduino: Using a data file
- If there is no need of real time communication between MATLAB and processing, you can first let MATLAB write its output to a data file, then let Processing read from it, or vice versa.
Jelle Dekker, Laura van Geel, Jasper de Kruiff and Vincent Klerkx are very successful in applying this approach to their cleaning robot. See their report: Cleaning_Robot.pdf