Support for Lego Mindstorms EV3

5 views (last 30 days)
John
John on 24 Sep 2013
Answered: Dan Lluch on 11 Dec 2015
Are there estimates of when the Lego Mindstorms EV3 hardware will be supported with Matlab and Simulink?
  6 Comments
Remi
Remi on 11 Dec 2013
Hey thanks for the quick answer. I am useing the Compiler: Microsoft Visual C++ 2010. But I recall that I had severe Problems installing Windows SDK I just tried it again and it won't work... But atleast now I know the problem. So thanks for the kind help.
Liam O'Sullivan
Liam O'Sullivan on 22 Jan 2014
Remi - please refer below to my answer labelled as USB connectivity.

Sign in to comment.

Accepted Answer

Peter Corke
Peter Corke on 15 Nov 2013
This has matured, check out https://wiki.qut.edu.au/display/cyphy/Lego+EV3
for the details: documentation and MATLAB code. We can run with Bluetooth, USB, and WiFi for Mac/Linux/Windows (except Bluetooth-Linux combo).
Please provide feedback here or else at https://groups.google.com/forum/#!forum/robotics-tool-box
  3 Comments
Liam O'Sullivan
Liam O'Sullivan on 17 Nov 2013
Some examples are given here. If you wish to connect to the EV3 brick via usb you can run
b = Brick('ioType','usb')
After the Brick object has been created you can check the connection by playing a beep tone
b.beep(5,500)
Liam O'Sullivan
Liam O'Sullivan on 24 Jan 2014
Edited: Liam O'Sullivan on 24 Jan 2014
A frequently asked question section has been added to the toolkit website! Please refer there first before asking questions here :)

Sign in to comment.

More Answers (10)

Dan Lluch
Dan Lluch on 11 Dec 2015
MathWorks provided support for MATLAB in 14b (passing data back and forth), and Simulink in 14a(programming the device). You can read more about capabilities and features on both workflows here:
HTH Dan

Peter Corke
Peter Corke on 30 Oct 2013
Have a look at
https://wiki.qut.edu.au/display/cyphy/Lego+EV3
we've tried to figure out how the EV3 works, and we have a MATLAB class that talks to the Ev3 brick over Bluetooth or Wifi. Right now we need to have the Instrumentation Toolbox on a PC, but in a day or so we'll have this working for Mac/Linux without Instrumentation Toolbox.
USB cable interface is hard because it requires an HID driver.
  2 Comments
John
John on 31 Oct 2013
Thanks for the link. I'll take a look.
Peter Corke
Peter Corke on 31 Oct 2013
Would be happy for comments and feedback. It's a work in progress, but I think sufficiently useful at this point to share. Working on more sensors, richer motor interface, and Win/Mac/Linux portability.

Sign in to comment.


Kutay Ça??l Ça??l
Kutay Ça??l Ça??l on 20 Nov 2013
When I try to run these code, I am getting the following error; By the way, I am using Matlab R2013a and Mac OS X platform. Please, share your opinion. Thanks.
--------------------------------------------------------------- Warning: The following error was caught while executing 'Brick' class destructor: Attempt to reference field of non-structure array. Error using loadlibrary (line 419) Failed to preprocess the input file. Output from preprocessor is:/bin/bash: gcc-4.2: command not found
Error in hidapi (line 94) loadlibrary(hid.slib,hid.sheader);
Error in usbBrickIO (line 58) brickIO.handle = hidapi(0,brickIO.vendorID,brickIO.productID,brickIO.nReadBuffer,brickIO.nWriteBuffer);
Error in Brick (line 114) brick.conn = usbBrickIO(brick.debug); ---------------------------------------------------------
  1 Comment
Liam O'Sullivan
Liam O'Sullivan on 21 Nov 2013
You need to have Xcode installed on your Mac to run the loadlibrary command in MATLAB. I believe this is missing since it cannot find the 'gcc-4.2' command or it isn't in your path.

Sign in to comment.


Ulrich
Ulrich on 23 Nov 2013
When I tried to run the example.m with my EV3 attached via USB on a Win32/Win7 system I got the error:
Invalid MEX-file 'D:\SRC\EV3_Matlab_Corke\hidapi.dll': D:\SRC\EV3_Matlab_Corke\hidapi.dll ist keine zulässige Win32-Anwendung. Error in usbBrickIO (line 58) brickIO.handle = hidapi(0,brickIO.vendorID,brickIO.productID,brickIO.nReadBuffer,brickIO.nWriteBuffer); Error in Brick (line 114) brick.conn = usbBrickIO(brick.debug); Error in Example (line 4) b = Brick('ioType','usb');
Do I have to flash a special firmware? Is there a tutorial to get started?
Best regards Uli
  1 Comment
Liam O'Sullivan
Liam O'Sullivan on 23 Nov 2013
Edited: Liam O'Sullivan on 7 Jan 2014
The current build of the source has only been tested with R2013a 64-bit in Windows 7 64-bit. The error here is that it cannot load the MEX-file (hidapi.dll) which is used for the USB connections between MATLAB and the EV3 brick. The hidapi.dll file that is distributed with the source is compiled for 64-bit machines so I think that is where the problem is.
Note that no special firmware is required for the toolkit software to interact with the EV3 brick.

Sign in to comment.


Amr
Amr on 26 Dec 2013
Hi Liam,
I have MATLAB 2013a and Windows 7 Pro 64bit, SDK 64 installed, and when I run Example.m I get the following: Error using loadlibrary (line 419) There was an error loading the library "C:\Users\amr\Downloads\EV3MATLAB\hidapi.dll" The specified module could not be found.
Error in hidapi (line 94) loadlibrary(hid.slib,hid.sheader);
Error in usbBrickIO (line 58) brickIO.handle = hidapi(0,brickIO.vendorID,brickIO.productID,brickIO.nReadBuffer,brickIO.nWriteBuffer);
Error in Brick (line 120) brick.conn = usbBrickIO(brick.debug);
Error in Example (line 4) b = Brick('ioType','usb');
Caused by: Error using loaddefinedlibrary The specified module could not be found. Please Advise, Amr
  3 Comments
Alan Bindemann
Alan Bindemann on 18 Jan 2014
Edited: Alan Bindemann on 20 Jan 2014
Liam,
I am also having problems getting the loadlibrary command to work with the hidapi.dll as well. My setup is as follows:
  • Windows 7 64-bit
  • MATLAB R2013a 64-bit
  • Microsoft SDK 7.1 Installed and configured using mex -setup
  • Revision 1160 of the QUT_EV3 module from the SVN repository.
When I try running Example.m the code errors out at line 419 of the loadlibrary command (The specified module could not be found). I've looked in the debugger and can't see anything obviously amiss.
When I looked at the hidapi.dll using DependencyWalker, it complains that it cannot find MSVCR120D.dll.
Any suggestions would be appreciated.
Thanks, Alan
Liam O'Sullivan
Liam O'Sullivan on 22 Jan 2014
Thanks for the feedback Alan, please refer below to my answer labelled as USB connectivity.

Sign in to comment.


Winty
Winty on 16 Jan 2014
Edited: Winty on 16 Jan 2014
Hi Liam,
I've got the same problem with the hidapi.dll file. I'm running Matlab 2013a 64bit on Windows 7 x64. The Windows SDK is set as compiler for mex files.
I also tried to get the toolkit running with Matlab 2010bSP1. I'm using this Compiler: Microsoft Visual C++ 2010 Express, because the Windows SDK is not shown within the mex setup in R2010bSP1. With that Version the hidapi.dll seems to be loaded, but i get another error when i try to run the Brick.m file:
Warning: The following error was caught while executing 'Brick' class destructor: Attempt to reference field of non-structure array. ??? Error using ==> usbBrickIO Illegal attribute 'Abstract'.
Error in ==> Brick>Brick.Brick at 120 brick.conn = usbBrickIO(brick.debug);
Any suggestions to solve that Problem?
Best regards, Winty

Liam O'Sullivan
Liam O'Sullivan on 17 Jan 2014
Hi Winty,
Can you use the Microsoft Visual C++ 2010 Express compiler in 2013a?
The 'Abstract' functionality was added into MATLAB from version 2012a. Thus for versions earlier than this you will have to remove 'BrickIO' from the various interface files to get them to work e.g. change 'classdef usbBrickIO < BrickIO' in usbBrickIO.m to 'classdef usbBrickIO < handle' etc.
  2 Comments
Winty
Winty on 17 Jan 2014
Edited: Winty on 23 Jan 2014
Thanks for your quick reply!
Unfortunately the Visual C++ 2010 Express compiler isn't shown when i use mex -setup so i can't use it.
Yesterday I found out that Matlab can't find the hidapi.dll. I get the same error "The specified module could not be found." when I delete that dll from the folder. Maybe Matlab or windows SDK don't have the permission to use this file or something?
Do you have any idea why matlab 2013a can't load the hidapi.dll file?
Liam O'Sullivan
Liam O'Sullivan on 22 Jan 2014
Winty - please refer below to my answer labelled as USB connectivity.

Sign in to comment.


Liam O'Sullivan
Liam O'Sullivan on 22 Jan 2014
Edited: Liam O'Sullivan on 25 Jan 2014
USB connectivity - I have uploaded a new version of the toolbox (available here) which should hopefully rectify the issues some users have been having with EV3 USB connections (32-bit MATLAB is now supported). The toolbox should now work without having to download the Windows SDK and configuring your mex compiler for MATLAB. Feedback welcome! Frequently asked questions has also been added to the toolkit website.
  5 Comments
Theodore
Theodore on 28 Jan 2014
Many thanks, Liam.
Some tips for beginners like me:
- After Liam updated the library, his tools will run on a 32bit Matlab student version.
- As of today, the latest link is at QUT EV3 MATLAB toolkit
- Download, unzip.
- Connect your brick with the USB cable.
- Start Matlab
- Drag and drop "Example.m" from the unzip location onto the command window.
- You will see this: EDU>> run('E:\Matlab\CyPyLabEV3\EV3\Example.m')
your brick will connect.
Liam O'Sullivan
Liam O'Sullivan on 2 Feb 2014
Hi Winty, I can't find an easy way of doing what you want using the communication protocol in the default EV3 firmware.
I have however added mailbox functionality to the toolkit as explained here . Thus you can send the variable data via a messaging block in the Lego NXT-G environment and it can be received in MATLAB. Please note though that mailbox messaging will only work with a bluetooth connection in MATLAB (you will need the instrumentation and control toolbox for that in Windows).

Sign in to comment.


Dale Martin
Dale Martin on 12 Mar 2014
  1 Comment
John
John on 12 Mar 2014
Edited: John on 12 Mar 2014
I just noticed this. That's great news.
Update: In looking a little closer at the EV3 support, I notice that there only seems to be Simulink support (NXT2.0 had both Simulink and Matlab support). Are there any plans to offer command-line support? Does this have to do with how bluetooth-serial commands are handled (or not) on the EV3 hardware?

Sign in to comment.


Signe Engelsholm
Signe Engelsholm on 2 Apr 2014
This toolkit is great!
However, it seems that it sometimes doesn't work properly when operating multiples motors at the same time. Have anybody had similar experiences? Or a solution to the problem?
Regards Signe

Categories

Find more on LEGO MINDSTORMS EV3 Hardware in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!