Support for Lego Mindstorms EV3

Are there estimates of when the Lego Mindstorms EV3 hardware will be supported with Matlab and Simulink?

6 Commenti

+1 on this one, I have the same question.
+1 on this one, I have the same question.
Remi
Remi il 4 Dic 2013
Modificato: Remi il 4 Dic 2013
First I would like to thank you for this awsome work, but I am still experiencing some difficulties of using this Toolbox. I have the following Matlab Version running on Win 7 Enterprise Service Pack 1:
MATLAB Version: 7.14.0.739 (R2012a) MATLAB License Number: •••••• Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1) Java Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode
This Matlab version seems not to be capable of loading the mex function library. When I try to load it I get the following error: >> loadlibrary('hidapi.dll','hidapi.h'); Error using loadlibrary (line 419) There was an error loading the library "D:\schm_ri\Documents\Matlab\EV3\hidapi.dll" Das angegebene Modul wurde nicht gefunden.
Caused by: Error using loaddefinedlibrary Das angegebene Modul wurde nicht gefunden.
Remi - have you setup your mex compiler with
mex -setup
I used visual studio to compile the hidapi.dll so I recommend that you download the Windows SDK and use that as your mex compiler in MATLAB.
Remi
Remi il 11 Dic 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.
Remi - please refer below to my answer labelled as USB connectivity.

Accedi per commentare.

 Risposta accettata

Peter Corke
Peter Corke il 15 Nov 2013

0 voti

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 Commenti

Labiba
Labiba il 15 Nov 2013
I am trying to use the code. I have having difficulty running the hidapi file. Matlab keeps complaining everything I try to run something.Can you please explain how the hidapi file works and how to use it properly?
Thanks!
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 il 24 Gen 2014
Modificato: Liam O'Sullivan il 24 Gen 2014
A frequently asked question section has been added to the toolkit website! Please refer there first before asking questions here :)

Accedi per commentare.

Più risposte (10)

Dan Lluch
Dan Lluch il 11 Dic 2015

1 voto

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 il 30 Ott 2013

0 voti

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 Commenti

John
John il 31 Ott 2013
Thanks for the link. I'll take a look.
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.

Accedi per commentare.

Kutay Ça??l Ça??l
Kutay Ça??l Ça??l il 20 Nov 2013

0 voti

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 Commento

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.

Accedi per commentare.

Ulrich
Ulrich il 23 Nov 2013

0 voti

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 Commento

Liam O'Sullivan
Liam O'Sullivan il 23 Nov 2013
Modificato: Liam O'Sullivan il 7 Gen 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.

Accedi per commentare.

Amr
Amr il 26 Dic 2013

0 voti

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 Commenti

Are you using 32-bit or 64-bit MATLAB? At the moment, I cannot get the hidapi.dll working with 32-bit MATLAB running on a Win 7 64-bit installation.
Alan Bindemann
Alan Bindemann il 18 Gen 2014
Modificato: Alan Bindemann il 20 Gen 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
Thanks for the feedback Alan, please refer below to my answer labelled as USB connectivity.

Accedi per commentare.

Winty
Winty il 16 Gen 2014
Modificato: Winty il 16 Gen 2014

0 voti

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 il 17 Gen 2014

0 voti

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 Commenti

Winty
Winty il 17 Gen 2014
Modificato: Winty il 23 Gen 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?
Winty - please refer below to my answer labelled as USB connectivity.

Accedi per commentare.

Liam O'Sullivan
Liam O'Sullivan il 22 Gen 2014
Modificato: Liam O'Sullivan il 25 Gen 2014

0 voti

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 Commenti

Winty
Winty il 23 Gen 2014
Modificato: Winty il 23 Gen 2014
First thanks for your awesome work!
I still have the same issues when I try to run Brick.m I get this error Message as I got before:
Warning: The following error was caught while executing 'Brick' class destructor: Attempt to reference field of non-structure array. Error using loadlibrary (line 418) There was an error loading the library "hidapi" The specified module could not be found.
Error in hidapi (line 86) loadlibrary(hid.slib,@hidapi_proto)
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);
Caused by: Error using loaddefinedlibrary The specified module could not be found.
There's no difference when I delete the hidapi.dll and run Example.m - same error. So I think, Matlab can't find or open that file.
Any suggestions to get that fixed?
Winty
Winty il 23 Gen 2014
With the new version from today everything seems to work fine. Thanks a lot for your help and work!
Winty
Winty il 28 Gen 2014
Hi Liam, is it possible to use variables created in the official LEGO MINDSTORMS Education EV3 Software within Matlab? I want to run a program made with this software and i need a value of a variable in Matlab for that.
Best regards,
winty
Theodore
Theodore il 28 Gen 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.
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).

Accedi per commentare.

Dale Martin
Dale Martin il 12 Mar 2014

0 voti

1 Commento

John
John il 12 Mar 2014
Modificato: John il 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?

Accedi per commentare.

Signe Engelsholm
Signe Engelsholm il 2 Apr 2014

0 voti

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

Categorie

Prodotti

Richiesto:

il 24 Set 2013

Risposto:

il 11 Dic 2015

Community Treasure Hunt

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

Start Hunting!

Translated by