Turtlebot simulation with ROS in the Nootrix virtual machine

Facebooktwitterredditpinterestlinkedinmail


[In English]

Siguiendo con la idea de utilizar la máquina virtual de Nootrix para Indigo 32, he estado trabajando con las opciones incluidas en ROS para simular  el robot Turtlebot usando Gazebo y rviz.

Para lograr una visualización y teleoperación básicas hay que ejecutar lo siguiente:

  • Instalar todo lo que haga falta para simular el Turtlebot:
    • sudo apt-get install ros-indigo-turtlebot-simulator
    • sudo apt-get install ros-indigo-turtlebot-apps
    • sudo apt-get install ros-indigo-simulators
  • Abrir un terminal y ejecutar roslaunch turtlebot_gazebo turtlebot_world.launch
  • Abrir otro terminal y ejecutar roslaunch turtlebot_rviz_launchers view_navigation.launch
  • Abrir un último terminal y lanzar un nodo que permita la teleoperación. Yo he utilizado roslaunch kobuki_keyop keyop.launch, ya que el funcionamiento de la otra opción de teleoperación (roslaunch turtlebot_teleop keyboard_teleop.launch) no me queda claro.
  • El resultado puede verse en este vídeo.

Para navegar con Turtlebot y construir un mapa, se puede consultar este tutorial o este otro. Ninguno de los dos funciona:

  • En un terminal, se ejecuta roslaunch turtlebot_gazebo turtlebot_world.launch. Hasta ahí, todo ok.
  • En otro terminal, ejecutar roslaunch turtlebot_gazebo gmapping_demo.launch. Ahí se fastidia el invento, y al cabo de unos momentos aparece el mensaje [ WARN] [1437734908.414750431, 97.100000000]: MessageFilter [target=odom ]: Dropped 100.00% of messages so far. Please turn the [ros.gmapping.message_notifier] rosconsole logger to DEBUG for more information.
  • Si en un tercer terminal se lanza rviz con roslaunch turtlebot_rviz_launchers view_navigation.launch, el fixed frame por defecto es map, y el elemento map aparece en amarillo y con el mensaje No map received.
  • Si se abre otro terminal para teleoperar el robot (roslaunch kobuki_keyop keyop.launch), el robot se mueve tanto en Gazebo como en rviz, pero sin mostrar las lecturas de las sensores.
  • Finalmente, si en otro terminal intentamos grabar el mapa con rosrun map_server map_saver -f mimapa, el mensaje que aparece es Waiting for the map.

Para averiguar qué estaba fallando, comprobé diferentes cosas:

  • Si el árbol de transformadas estaba completamente conectado: rosrun tf view_frames. Aparentemente, sí lo está.tftree
  • Hacer un source antes de cada roslaunch: source /opt/ros/indigo/setup.bash 
  • Comprobar el topic /map (en el que, según rviz, se lee el mapa), para ver si los nodos implicados accedían a él: rqt_graph, rosnode info slam_gmapping, rosnode info rviz. Todo bien también.
  • Comprobar qué información se transmitía por el topic /map. A pesar de que los nodos estaban bien conectados, al hacer rosrun tf tf_echo /map /odom los valores que circulaban por él eran siempre nulos, incluso si movía el robot con la teleoperación del kobuki.

Después de buscar ayuda infructuosamente por tooooda internet ;), pensé en instalar ROS directamente sobre mi Xubuntu 14.04, sin máquina virtual. Lo hice, volví a lanzar Gazebo, rviz y la teleoperación del kobuki, y tachán tachán, apareció un error distinto: [ERROR] [1433813576.466253926, 24.270000000]: Scan message must contain angles from -x to x, i.e. angle_min = -angle_max. Este error me sonaba de haberlo visto reportado y resuelto en answers.ros.org, así que hice lo que se decía en esta respuesta y conseguí hacer un mapa con gmapping.

Así que se me ocurrió replicar esa solución en el ROS de la máquina virtual, y esta vez sí, logré un hermoso mapilla virtualmente simulado 🙂

mapiki

Digamos que he logrado la solución ingenieril (funciona) pero no la científica (no sé por qué) 😉 Cualquier explicación sobre qué estaba fallando será bienvenida.


[En español]

According to my idea of using the Indigo 32 Nootrix virtual machine, I have been checking the options included in ROS for simulating the Turtlebot robot with Gazebo and rviz.

In order to get a basic visualization and teleoperation, you should follow these steps:

  • First, get all the tools to simulate the Turtlebot:
    • sudo apt-get install ros-indigo-turtlebot-simulator
    • sudo apt-get install ros-indigo-turtlebot-apps
    • sudo apt-get install ros-indigo-simulators
  • Open a terminal and run roslaunch turtlebot_gazebo turtlebot_world.launch
  • Open another terminal and run roslaunch turtlebot_rviz_launchers view_navigation.launch
  • Open a third terminal and launch something that lets you to teleoperate the robot. I have used  roslaunch kobuki_keyop keyop.launch, since how the other ROS option for teleoperation works (roslaunch turtlebot_teleop keyboard_teleop.launch) is not clear to me.
  • You can see the results in this video.

If you want to navigate the Turtlebot and get a map, you have this tutorial or this other. None of them works:

  • Open a terminal and run roslaunch turtlebot_gazebo turtlebot_world.launch. Everything is ok.
  • In other terminal, run roslaunch turtlebot_gazebo gmapping_demo.launch. This is where things go wrong and you get the message [ WARN] [1437734908.414750431, 97.100000000]: MessageFilter [target=odom ]: Dropped 100.00% of messages so far. Please turn the [ros.gmapping.message_notifier] rosconsole logger to DEBUG for more information.
  • If you open a third terminal with roslaunch turtlebot_rviz_launchers view_navigation.launch, the default fixed frame is map, and the map element is shown in yellow, with the message No map received.
  • If you open another terminal for teleoperation (roslaunch kobuki_keyop keyop.launch), the robot moves both in Gazebo and rviz, but it does not show the sensor readings.
  • Finally, if you open another terminal and try to store the map with rosrun map_server map_saver -f mimap, you get a Waiting for the map message.

Here is a list of all the things I tried to solve the problem:

  • Was the transforms tree properly connected (rosrun tf view_frames)?. Apparently, it was.tftree
  • I sourced before every roslaunch: source /opt/ros/indigo/setup.bash 
  • I checked the /map topic (where the map is read, according to rviz), in order to see in the involved nodes were properly connected: rqt_graph, rosnode info slam_gmapping, rosnode info rviz. Everything seemed ok too.
  • I checked which information was sent through the /map topic. Despite of the nodes being well connected, rosrun tf tf_echo /map /odom proved that all the values moving across the topic were always null, even if the robot was teleoperated with the kobuki node.

After vainly googling half the internet ;), I thought I could install ROS directly on my Xubuntu 14.04, without virtual machine. I did it, run again Gazebo, rviz and kobuki teleoperation and, oh boy, I got a different error: [ERROR] [1433813576.466253926, 24.270000000]: Scan message must contain angles from -x to x, i.e. angle_min = -angle_max. I recalled this error from answers.ros.org, so I did what it was explained  in this answer and finally I got a map.

So I applied that solution to the ROS on the virtual machine, and finally I got a lovely virtually simulated little map 🙂

mapiki

We could say that this is the engineering solution (it works), but not the scientific solution (I don’t know why) 😉 Any explanation on what was failing will be heartily welcomed.

Arduino + ROS Indigo 32 on Nootrix Virtual Machine

Facebooktwitterredditpinterestlinkedinmail


[In English]
ROS puede conectarse con un Arduino sin problemas. Mi objetivo es comprobar si esta conexión puede hacerse a través de la máquina virtual que proporciona Nootrix, ya que es la que utilizo en clase, puesto que facilita el trabajo con máquinas Windows, y también es más rápida y sencilla de instalar para los alumnos.

En mi máquina tengo instalado Xubuntu 14.04, uso Virtual Box 4.3.10, y la máquina virtual que he instalado es la de  ROS Indigo de 32 bits. Una vez que has instalado la máquina de ROS en Virtual Box, hay que seguir estos pasos:

  • Si tu usuario no está en vboxusers, añádelo  con sudo adduser tu_usuario vboxusers (o sudo usermod -aG vboxusers tu_usuario).
  • Arrancar la máquina virtual y escoger el Arduino de los dispositivos USB en el menú Dispositivos de Virtual Box.
  • Seguir las instrucciones de instalación de Arduino (con catkin); hay una pequeña variación en la máquina Nootrix: el directorio de sketches está en $HOME/Arduino.

Una vez instalados los elementos básicos para trabajar con Arduino en ROS, veamos qué hace falta para ejecutar uno de los ejemplos básicos incluidos en la instalación de Arduino: HelloWorld.ino, en el que el Arduino publica en un topic el  mensaje “hello world!”.

  • Seguir las instrucciones para ejecutar HelloWorld (importante: asegurarse que se han escogido las instrucciones para  Indigo).
  • Para averiguar qué dev utilizar: lsusb, y luego dmesg | grep tty.
  • Ahora hay que dar permisos a ese dispositivo serie, con cd /dev/ y luego sudo chmod 666 ttyACM0.
  • Después, pasamos el programa al Arduino, seleccionando bien el puerto.
  • Abrir un terminal con roscore.
  • Abrir otro terminal con rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0.
  • Abrir otro terminal con rostopic echo chatter (chatter es el nombre del topic usado en el código .ino de ejemplo)
  • Aviso: como ROS está usando rosserial, el Serial Monitor de Arduino no funciona (al menos con Arduino UNO)

El resultado se puede ver en el vídeo al final del post 🙂


[En español]

ROS can be easily connected to an Arduino board. But I wanted to check if this connection could be done with the Nootrix virtual machine, the one I use for my classes since it makes easier to work with ROS if you have Windows machines, and it helps the ROS installation for the students.

My machine runs on Xubuntu 14.04, I use Virtual Box 4.3.10, and the virtual machine I have chosen is ROS Indigo 32 bits. Once you have installed the ROS virtual machine on Virtual Box, you should  follow these steps:

  • If your user does not belong to vboxusers  group, you should add it with sudo adduser your_user vboxusers (or sudo usermod -aG vboxusers your_user).
  • Run the virtual machine and choose Arduino from the USB devices listed on the Virtual Box Devices menu.
  • Go to  Arduino installation and follow those steps (use catkin); there is a sligth modification on the Nootrix machine: the sketches folder is stored in $HOME/Arduino.

Now we have all the basic elements to work with Arduino under ROS; let’s see what else we need to run one of the basic examples included with the Arduino installation: HelloWorld.ino, which makes Arduino publish a “hello world!” message in a topic.

  • Follow these steps to run  HelloWorld (it is important to choose the proper instructions, i.e., the Indigo ones).
  • In order to know which dev to use: lsusb, and then dmesg | grep tty.
  • Now you have to grant permissions to that serial device: cd /dev/ and then sudo chmod 666 ttyACM0.
  • Then you upload the program to the Arduino, choosing the right port.
  • Open a terminal and run roscore.
  • Open another terminal and run rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0.
  • Open another terminal and run rostopic echo chatter (chatter is the name of the topic used in the .ino example code)
  • Warning: since ROS is using rosserial, Arduino’s Serial Monitor does not work (at least with Arduino UNO)

And voilà, here we have our Arduino publishing in a ROS topic 🙂

Arduino + Autodesk123

Facebooktwitterredditpinterestlinkedinmail

He descubierto Autodesk 123D circuits Electronics Labs, una aplicación en la nube donde se pueden implantar, programar y simular circuitos electrónicos en protoboard usando diferentes elementos, como Arduino. Aquí va un pequeño ejemplo de lo que se puede hacer.

I have discovered Autodesk 123D circuits Electronic Labs, a cloud application which allows to implement, program and simulate electronics circuits on a breadboard using different elements, like Arduino. Here you have a small example of what can be done.

Android Studio + NDK + Xubuntu 14.04

Facebooktwitterredditpinterestlinkedinmail


[In English]

Estos son los pasos necesarios para instalar Android Studio y NDK sobre Xubuntu 14.04 (en colaboración con Juan Antonio Fernández Madrigal)

Consideraciones previas

  • No es posible instalarlo en una máquina virtual, ya que el emulador necesita para funcionar virtualización, no disponible dentro de una máquina virtual.
  • Hacen falta bastantes gigas de disco para instalarlo todo, así que hay que asegurarse de tener suficiente espacio.
  • Aquí pueden encontrarse tutoriales para aprender a programar con Android Studio.
  • Bibliografía disponible en Jábega (catálogo de la Biblioteca de la Universidad de Málaga)
    • El Gran libro de Android : [actualizado a la versión KitKat y Android L Preview] / Jesús Tomás Gironés
    • Building Android apps / Mike McGrath
    • Manual imprescindible de desarrollo de aplicaciones para Android. Edición 2015/ Joan Ribas Lequerica
    • Profesional Android open accesory programing with Arduino [Recurso electrónico]/ Andreas Göransson,
    • Android Studio application development [Recurso electrónico] / Belén Cruz Zapata.

Primer paso: instalación de JAVA

  1. Bajarse de Sun el java jdk (a partir del 7 ya vale); no el jre, que sólo es el entorno de ejecución.
  2. Crear un directorio para el jdk  y descomprimir
  3. Si queremos activar los applets de java en firefox, hay que crear en donde firefox tiene los plugins (/usr/lib/mozilla/plugins) un enlace simbólico al plugin que trae el jdk para eso, que está en /dirjdk/jre/lib/amd64/libnpjp2.so. Luego se rearranca el firefox y se mira en about:plugins. También se puede ejecutar el programa jcontrol del directorio bin de java para establecer los permisos de seguridad que permiten ejecutar applets de algún sitio concreto.
  4. Añadir al final de ~/.bashrc las siguientes líneas, para que así Java quede visible para el Android Studio. Después, cerrar y abrir la consola y hacer echo $PATH y echo $JAVA_HOME para comprobar que todo ha ido bien:
    PATH=$PATH:/directoriodejdkbin
    JAVA_HOME=/directoriodejdk
    export PATH
    export JAVA_HOME

Segundo paso: instalación de Android Studio 

  1. Bajar el IDE completo (por ejemplo, el fichero android-studio-ide-141.1903250-linux.zip) de la web.
  2. Realizar la instalación siguiendo estas instrucciones.
    – Si Java no está bien instalado (ver Primer paso), al ejecutar en el directorio bin el comando ./studio.sh, aparece el mensaje “JDK Required: ‘tools.jar’ seems to be not in Studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE.”
    – En Xubuntu me ha aparecido un mensaje de error debido al demonio iBus; en esta dirección se dan posibles soluciones al problema.
    – Escoger la instalación estándar.
    – Se da la opción de KVM para acelerar la VM (en mi caso, no la he activado porque aparentemente podría afectar a Virtual Box y no he querido investigar más; más info aquí)
  3. Cuando se abra el Android Studio por primera vez, escoger la opción Configure para definir el path del SDK y el JDK. Este paso también puede hacerse con posterioridad a la instalación: abrir Android Studio, escoger File-> Other settings -> Default Project Structure. El SDK está en un directorio que se ha debido crear en la configuración; el JDK, en el directorio donde se hizo la descarga según se explicó anteriomente (ver Primer paso).
  4. Para crear un proyecto:
    – Versión mínima escogida para teléfono y tablet:  Froyo
    – Tipo de actividad: Blank activity

Tercer paso: instalación de NDK

  1. Descargar el fichero adecuado y seguir estas instrucciones.
  2. Mover el directorio descomprimido a donde se quiera, y actualizar el path
    PATH=$PATH:/directoriondk
    export PATH

Desarrollo de aplicaciones

[ACTUALIZACIÓN]

He repetido la instalación en un Ubuntu Mate 15.04 vivid, y hay varios cambios respecto a la instalación comentada anteriormente.

  • Al instalar, aparece el error Unable to run mksdcard. La solución puede encontrarse en este enlace de Blascarr.
  • La API 2.2 (Froyo) viene desinstalada por defecto, así que antes de crear una aplicación nueva hay que instalarla usando Tools -> Android -> SDK Manager.
  • Respecto a la emulación, dos puntos a tener en cuenta:
    • He necesitado dar permisos a la carpeta system_images del directorio de instalación de SDK.
    • He intentado crear un AVD usando una imagen de 64 bits, pero necesita la KVM y como, aparentemente, KVM da problemas con Virtual Box, he preferido no instalarla. Consecuencia: la emulación va lentísima 🙁


[En español]

These are the steps to follow in order to install Android Studio and NDK on Xubuntu 14.04 (post written in collaboration with Juan Antonio Fernández Madrigal)

Preliminary requests

  • This software cannot be installed on a virtual machine, since the emulator requires virtualization tools, which are not available in a virtual machines.
  • Both programs are quite demanding in hard drive space: be sure you have enough before you begin the installation.
  • Here you can find several tutorials to learn how to program with Android Studio.
  • Brief list of suggested readings (all of them available at Jábega, the catalogue of the Library of Málaga University)
    • El Gran libro de Android : [actualizado a la versión KitKat y Android L Preview] / Jesús Tomás Gironés
    • Building Android apps / Mike McGrath
    • Manual imprescindible de desarrollo de aplicaciones para Android. Edición 2015/ Joan Ribas Lequerica
    • Profesional Android open accesory programing with Arduino [Recurso electrónico]/ Andreas Göransson,
    • Android Studio application development [Recurso electrónico] / Belén Cruz Zapata.


First step: installing Java

  1. Download java jdk from Sun (jdk 7 or later); it is important to choose jdk and not jre (jre is just the running environment).
  2. Create a folder and unzip (or untar :)) the Java jdk.
  3. If you wisht to activate the java applets in firefox, you have to create in the folder where firefox stores its plugins, a symbolic link to the plugin that the jdk offers, which is stored in /jdkfolder/jre/lib/amd64/libnpjp2.so. Then, restore firefox and check about:plugins. You can also run jcontrol in your Java bin folder, so you can set the permissions that allow to run applets from a known location.
  4. Append, at the end of ~/.bashrc, these lines, so Java can be available for Android Studio. Then, close and open again the terminal, and type echo $PATH and echo $JAVA_HOME in order to check that everything is ok:
    PATH=$PATH:/jdkbinfolder
    JAVA_HOME=/jdkfolder
    export PATH
    export JAVA_HOME

Second step: installing Android Studio

  1. Download the IDE (i.e., android-studio-ide-141.1903250-linux.zip file) from the web.
  2. Install the software according to this guideline.
    – If Java is not properly installed (see First step), when you run ./studio.sh in the bin folder, you get this message “JDK Required: ‘tools.jar’ seems to be not in Studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE.”
    – Under Xubuntu I also get an error message due to the iBus daemon; this link offers several solutions to this problem.
    – Choose standard installation.
    – You can choose KVM in order to accelerating the VM (I have rejected this option, since -apparently- it could have an influence on Virtual Box, and I did not want to risk my virtual machine; more info here)
  3. When Android Studio opens for the first time, choose the Configure option so you can define the paths for SDK and JDK. This step can also be done after installation is completed: open Android Studio, then choose File-> Other settings -> Default Project Structure. The SDK is in a folder created in the configuration process; the JDK should be stored in the folder where you downloaded it (according to First step explanations).
  4. If you want to create a project:
    – Minimum version for phone and tablet: Froyo
    – Activity type: Blank activity

Third step: installing NDK

  1.  Download the right file and follow these instructions.
  2. Move the unzipped folder to your desired location, and update the path
    PATH=$PATH:/ndkfolder
    export PATH

Applications development

[UPDATE]

I have installed the Ubuntu Mate 15.04 vivid, and there are some changes from the previously commented installation.

  • During the installation process, an Unable to run mksdcard error arises. You can fin the solution in this link at Blascarr [in Spanish].
  • API 2.2 (Froyo) is not installed by default, so prior to create a new app you have to install it with Tools -> Android -> SDK Manager.
  • Regarding emulation, two aspects should be taken into account:
    • I had to grant permissions to the folder system_images inside the SDK installation folder.
    • I tried to create a new AVD with a 64 bits image, but it requires KVM and sice, apparently, KVM is not compatible with Virtual Box, I choosed not to install that image. Consecuence: emulation is very very slow 🙁

LabVIEW Datalogging and Supervisory Control + Arduino

Facebooktwitterredditpinterestlinkedinmail

Por fin he vuelto al blog. Aquí tenéis una de las razones de mi ausencia: he estado trasteando con el módulo Datalogging and Supervisory Control de LabVIEW (version 2009) para diseñar sistemas SCADA, integrando también un Arduino. ¡¡Feliz Semana Santa :)!!

Finally, I have managed to get back to blogging. Here you have one of the reasons of my leave: I have been diving into LabVIEW’s Datalogging and Supervisory Control module (2009 version) in order to design SCADA systems, using an Arduino too. Have a happy Easter :)!!

Lecturing with style :)

Facebooktwitterredditpinterestlinkedinmail

Midiendo con un sensor FSR la fuerza ejercida por una pelota de golf / Measuring  the force applied by a golf ball with a FSR sensor

Un par de tutoriales  majos/ A couple of  nice tutorials:

  • http://www.instructables.com/id/FSR-Tutorial/?lang=es
  • https://learn.adafruit.com/force-sensitive-resistor-fsr/using-an-fsr

 

DSC_0017_red