LEGO EV3 + Matlab/Simulink + WiFi : the Windows 10 experience

Facebooktwitterredditpinterestlinkedinmail


[In English]

Bueno, pues después de pegarme con el Lego, Matlab/Simulink y la conexión wifi en Ubuntu, he probado con la opción Windows montando yo la red con un router wifi, en este caso. Estos son los pasos a seguir:

  1. El router que he usado es un Linksys Compact Wireless-G. Como el PC que he utilizado está detrás de un proxy, en las opciones de configuración de red de Windows 10 ha sido necesario especificar que el proxy no se use para la URL del administrador web del router.
  2. El firmware del LEGO EV3 para poder trabajar con wifi en Simulink/Matlab 2016b es el 1.08. Ni el firmware 1.09 ni el 1.03 funcionan.
  3. Para conectar el EV3 usando los dongles Edimax o NetGear que explicaba en la entrada que enlazo al principio del post, he añadido la red del router con la opción Add Hidden Network, indicando el SSID que aparece en el administrador web del router. La seguridad es None.
  4. El funcionamiento correcto de la conexión se puede comprobar haciendo un ping desde el Command Prompt de Windows.
  5. Antes de trabajar en Simulink, es recomendable comprobar que el robot está accesible desde la ventana de comandos de Matlab.
  6. Finalmente, lanzar Simulink, seleccionar la opción WiFi como Host to Target Connection en los parámetros de configuración del hardware del modelo, especificando la IP y el Device ID del robot (esa información está disponible en la pestaña Settings , opción Brick Info del EV3).

Con este procedimiento he conseguido descargar un programa en el EV3. También es cierto que a partir de ahí el robot se ha colgado. Pero, al menos, la conexión se ha hecho…


[En español]

Well, after fighting the Lego, Matlab/Simulink and WiFi connection under Ubuntu, I have tried the Windows option, but in this case I also set up a network with a WiFi router. These are the steps to follow:

  1. I have used a Linksys Compact Wireless-G router. Since the PC I have worked with is behind a proxy, I had to add the router web admin URL to the no-proxy exceptions in the network configuration of Windows 10.
  2. The LEGO EV3 firmware that works with WiFi in Simulink/Matlab 2016b is version 1.08. Neither version 1.09 nor 1.03 works.
  3. In order to connect the EV3 with the Edimax or NetGear dongles that I explained in the link at the beginning of this post, I have added the WiFi network of the router with the option Add Hidden Network, using the SSID shown in the router web admin page. I have chosen None security option.
  4. You can check that the robot has connected to the router with a simple ping from the Windows Command Prompt.
  5. Before launching Simulink, it is a good idea to check that  the robot is accessible from the Matlab commands window.
  6. Finally, you should launch Simulink, choose the WiFi option on the Target Hardware Resources of your model, incluing the IP and Device ID values of the robot (you can get those values in the Settings label of the EV3, option Brick Info).

Following these steps I have managed to download a program to the EV3. It is also true that from that moment the robot got frozen, but at least the connection was made…

LEGO EV3 + Matlab/Simulink + WiFi: the Ubuntu experience

Facebooktwitterredditpinterestlinkedinmail


[In English]

Nuestros queridos LEGO NXT han cumplido más que suficiente con su misión, así que este año nos hemos pasado a la nueva versión del robot, la EV3.

Eso significa que ya no podemos programar los robots en NXC usando BricxCC, que en mi opinión formaban una combinación estupenda: software libre y programación en C, muy adecuada para alumnos de grados de Ingeniería Informática. Tras evaluar diferentes posibilidades, hemos decidido usar Simulink para programarlos. Y, por ahora, echo en falta dos cosas importantes, que me hacen pensar que la vida con el NXT era mejor (enorme suspiro):

  • En primer lugar, no hay soporte para trabajar con Matlab/Simulink usando el EV3 conectado con el USB en Ubuntu. Francamente, no entiendo esta decisión.
  • En segundo lugar, la conexión del EV3 con Matlab/Simulink usando wifi no es nada sencilla. Centrándome en el tema de la wifi, a continuación resumo las pruebas que he realizado hasta el momento, junto con la información que he recopilado preparando las mismas. El resumen corto es que no hay forma de trabajar con la wifi en Ubuntu y hay que irse a Windows; si estoy haciendo algo mal y un alma caritativa me saca de mi error se lo agradecería 🙂

Los dongles wifi que he probado son el Netgear 300 (el único que Lego recomienda es el Netgear 150, pero ya no se encuentra fácilmente), el Edimax N150 (que en muchas webs aparece como compatible con el anterior), y un TPLink que he encontrado en el laboratorio y del que desconozco el modelo. El EV3 necesita conectarse a un router. Con los tres dongles he podido conectarme al router de casa, pero sólo con el Netgear 300 y el Edimax los ordenadores que he empleado han sido capaces de detectar el robot (basta con hacer un ping desde el ordenador a la IP del EV3), así que todo lo que sigue se refiere a los dos primeros.

Algunas de las pruebas han requerido cambiar el firmware del EV3. Los diferentes firmware que he utilizado son las siguientes: 1.03 (descargable desde aquí), 1.03 adaptada para el dongle Edimax (descargada de aquí , aparece como 1.04 cuando se descarga en el robot), y 1.08 (descargada de aquí).

La tabla recoge todas las configuraciones de software que he probado junto con el resultado obtenido. Las figuras se incluyen al final de la entrada.


[En español]

Our beloved LEGO NXT have heroically fulfilled their mission, so this year we have moved on to the new version of the robot, the EV3 robot.

This means that we no longer can program the robots  in NXC using BricxCC, which in my opinion made a perfect match: open source software and C based programming, very suitable for students of Computer Science bachelors. After evaluating different options, we have chosen Simulink for programming the robots. And, for now, I miss two main things which make me think that life was better with the NXT (massive sigh):

  • To begin with, it is not possible to work in Ubuntu with Matlab/Simulink using the EV3 connected via USB. Frankly, I do not understand this decission.
  • Secondly, it is not easy to connect EV3 with Matlab/Simulink using WiFi. Focusing in the WiFi issues, in the following I sum up the tests I have done so far, along with the information I have gathered while preparing those tests. The short summary is that there is no way to work with the WiFi using Ubuntu and you have to move to Windows; if I am doing something wrong and some charitative soul takes me out of my mistake I would really appreciate it 🙂

The WiFi dongles I have tried are the Netgear 300 (the only that Lego supports is the Netgear 150, but it cannot be easily found nowadays),  the Edimax N150 (many webpages report that it is compatible with Netgear 150), and a TPLink  that I found in the lab (I unfortunately do not know the model). EV3 has to connect to a router. The three dongles connected the robot to my home router, but only Netgear 300 and Edimax 150 assured that my laptops could detect the robot (with a ping from the laptop to the EV3’s IP), so all that is explained in the following only refers to the first two dongles.

Some of the test required changing the firmware of the EV3. These are the firmwares I have used: 1.03 (available here), 1.03 adapted for the Edimax dongle (available here , it is numbered as 1.04 when downloaded into the robot), and 1.08 (available here).

The table shows all the software configurations I have tried along with the obtained result. Figures are included at the end of the post.

 

Fig 1.- WiFi error with Matlab R2015a

Fig 2.- WiFi error with Matlab R2016b

Fig 3.- Gcc error with Simulink R2016b

Scorbot days

Facebooktwitterredditpinterestlinkedinmail

Siento no aparecer mucho por aquí… clases, clases everywhere 🙂 Para compensar, este es el vídeo que he preparado para la práctica basada en Scorbot de la asignatura Programación de Robots.

I’m afraid I’m not writing too much lately … teaching, teaching everywhere 🙂 To compensate, here is the video I have prepared for the Scorbot-based lab session of our robot programming course.

R + Arduino + ROS + ultrasonic sensor HC-SR04

Facebooktwitterredditpinterestlinkedinmail

Con el objetivo de ilustrar el uso de frameworks robóticos de programación en la asignatura “Programación de Robots”, y aprovechando el trabajo previo que comenté aquí, este curso voy a incluir un ejercicio de clase que consiste en que un sónar HC-SR04 conectado a un Arduino envíe las medidas de distancia a un nodo ROS que mueve la tortuguita en función de la cercanía a los obstáculos, y además las distancias se leen y representan gráficamente usando R. Espero que a mis alumnos les guste 🙂

In order to explain how to use robotic frameworks in a “Robot Programming” course, and reusing the previous work I commented here, I have prepared a class exercise where an ultrasonic sensor HC-SR04 connected to an Arduino sends distance measurements to a ROS node which moves the turtle according to how close the obstacles are detected, and also the distances are read and drawn using R. I hope my students enjoy it 🙂

ros1ros2

¡Feliz Navidad! Merry Christmas!!

Facebooktwitterredditpinterestlinkedinmail

Finalmente, hemos dejado cerradas las primeras pruebas unitarias del Turtlebot con el WidowX. En el vídeo al final del post puede verse al brazo realizando un home (con la pinza funcionando), moviendo cada articulación en ambos sentidos, y relajando cada articulación. El código completo está en mi GitHub. Así que, con la satisfacción del deber  cumplido… ¡¡Feliz Navidad :)!!

navidad2015

Finally, we have finished the first unit tests of our Turtlebot with the WidowX on board. The video at the end of this post shows the robot homing (with the gripper opening and closing), moving each joint in both directions, and relaxing each joint. The code can be downloaded from my Github. So, with the satisfaction of the duty fulfilled… Merry Christmas )!!

WidowX + ROS: joints directions

Facebooktwitterredditpinterestlinkedinmail

Seguimos con las pruebas unitarias del brazo WidowX, y ahora nos hemos centrado en ver cuáles son los sentidos de movimiento de las articulaciones 1 a 5, partiendo del “home” que hicimos anteriormente. El código se ha añadido a las pruebas unitarias iniciales (fichero widowx_arm_testing.cpp en mi GitHub).

We keep on working on the unit tests for the WidowX arm, but now we have focused on the direction of movement for joints 1 to 5, assuming that the robot is in the “home” position as we explained before. The code has been appended to the first unit tests (file widowx_arm_testing.cpp at my GitHub).

Turtlebot 2 movement analysis

Facebooktwitterredditpinterestlinkedinmail


[In English]

Ahora que ya tenemos el Turtlebot 2 andando, hemos querido caracterizar los motores cuando se mueven con la carga inicial del robot. Para ello, hemos seguido los siguientes pasos, que están documentados en el vídeo al final del post; en mi repositorio de GitHub está el código C++, Matlab y R:

  • Hemos creado un nodo ROS que mueve al robot con velocidad lineal x=0.1 m/sec, y almacena en fichero las medidas de los encoders de ambos motores junto con dos marcas de tiempo: las asociadas a los mensajes ROS, y las grabadas por la base Kobuki.
  • Después, analizamos las medidas con Matlab.
    • Primero, hemos representado gráficamente las medidas de los ticks frente a los dos tipos de marcas de tiempos (tanto relativas como absolutas).
    • En segundo lugar hemos representado la velocidad de cada rueda, entendiendo velocidad como la relación entre ticks y variación de tiempo. En el vídeo se observa que la velocidad aparece como rads/sec; para hacer la transformación nos hemos basado en las especificaciones de la base Kobuki. Si manualmente se hace el cálculo V = r*ω se observa que todo es correcto.
    • En tercer lugar, aprovechando la Control Toolbox de Matlab, hemos hecho una identificación de los motores de las ruedas usando un método de aproximación mediante sistemas de primer orden con retraso. La K y la τ obtenidas se han tomado como base para hacer después un reajuste manual, que se adapta bastante bien a los datos reales (sobre todo en el caso del motor derecho).
  • Finalmente, hemos hecho una representación muy básica (aún sin usar ggplot2, estamos trabajando en ello 😉 ) en R.


[En español]

Now that our Turtlebot moves, we have characterized its motors when they are moving bearing the initial load of the robot. We have followed these steps, which are documented in the video at the botton of this post; my GitHub repository stores the C++, Matlab and R code:

  • We have created a ROS node that makes the robot move with a linear x speed=0.1 m/sec, and then writes to a file the measurements of both encoders along with two timestamps: those related to ROS messages, and those taken by the Kobuki base.
  • Then, we have analysed the data using Matlab.
    • First, we have plotted the ticks values versus both timestamps (both relative and absolute).
    • In the second place, we have plotted the speed of each wheel, where speed is the relationship between ticks and time difference. You can see in the video that speed is represented as rads/sec; we transformed the values using the Kobuki mobile base specifications. If you do your maths by hand (V = r*ω), you will see that calculations are correct.
    • In the third place, using the Control Toolbox provided by Matlab, we did the identification of both motors with an approximation using a first order system with delay. The resulting K and τ are the basis for a manual recalculation, which fits quite well to the real data (especially, for the right motor).
  • Finally, we prepared a very basic R plotting (still without ggplot2, but we are working on it 😉 )

R + Arduino + ROS

Facebooktwitterredditpinterestlinkedinmail


[In English]

Como ya comenté en un post anterior, es posible integrar Arduino dentro de ROS. Por otra parte, hay un paquete rosR muy interesante que permite crear scripts R trabajando también en ROS; la documentación del paquete es completa y cubre tanto la parte ROS como la parte R:

Combinando ambos paquetes se pueden hacer cosas majas. Por ejemplo, en el vídeo al final del post se muestra cómo un nodo ROS envía las lecturas de un sensor FSR conectado a un Arduino (Duemilanove, en este caso) por un topic al que está suscrito un script R que muestra un plot con esos valores sobre la marcha. El código del sketch y del script, basados en los ejemplos proporcionados en la documentación de ambos paquetes, están en mi Github.

En este caso, he usado la máquina virtual Nootrix con ROS indigo 32, ya que me resulta útil por motivos docentes. La misma combinación Arduino-R también funciona correctamente en un Xubuntu 14.04.3 de 64 bits con ROS indigo instalado.

Por probar, he compilado la versión 64 bits de rosR en un Ubuntu Mate 15 con ROS jade distribuido entre un portátil y el netbook del Turtlebot, y también funciona… ¡¡Turtlebot, R te espera :)!!


[En español]

As I commented in a previous post, it is possible to use Arduino with ROS. Furthermore, there is a very interesting rosR package that allows to build R scripts also in ROS; the documentation of this package is complete and covers the ROS point of view as well as the R perspective:

You can build nice things using both packages. For example, the video at the bottom of this post shows how a ROS node sends the readings of a FSR sensor connected to an Arduino (Duemilanove, in this case) through a topic; a R script which is subscribed to that topic plots those values on the fly. The code of the skecth and the script, based on the examples provided in the documentation of both packages, is in my Github.

You can see in the video that I use the Nootrix ROS indigo 32 virtual machine, since I find it useful due to teaching reasons. The same Arduino-R combination also works fine under a Xubuntu 14.04.3 64 bits with ROS indigo.

I tried to compile the rosR 64 bits version under Ubuntu Mate 15 with a ROS jade distributed between a desktop and the Turtlebot netbook, and it also works… Turtlebot, R is waiting for you 🙂