I've written a small sketch for Arduino to make a led blink with a function that resembles a human heartbeat. 

On [1] Stevens and Lakin describe a detailed mathematical analysis of the signal of the cardiac pulse. 

I've taken one of their equations that close to the cardiac pulse and generated a lookup table for the luminosity value.

  f(x)=(sin(x)^13) * cos(x-PI/10)

  check the function graphed on Google 

Check the code at Github.

[1] Stevens, Scott; Lakin, William. A Differentiable, Periodic Function for Pulsatile Cardiac 

    Output Based on Heart Rate and Stroke Volume

    http://math.bd.psu.edu/faculty/stevens/Publications/paper3.pdf

 

 

The Adafruit Raspberry Pi Cobbler is a nice breakout for the Raspberry Pi GPIO designed to connect to a breadboard. While not expensive (US$7.95) shipping simple electronic devices to Mexico can double it's price due shipping and it may take several weeks to be delivered. So I decided to make one from components I could get easily here.

Components:

  • 25 cms of 26 pin ribbon cable
  • Two female 26 headers for ribbon cable (press connectors)
  • One generic protoboard
  • One strip of break away headers with 26 pins
  • One strip of break away headers with 26 double pins

First, build the ribbon cable following Gert's instructions.

Now, take a look at the protoboard I got from Steren. Looks like a solderless breadboard. Notice that each row the left side of the vertical tracks has two single point pads while the right side has three. I used the side with two pads, and inserted the row of double pins on them. The ribbon cable will be connected to this headers.

The protoboard. Notice the 2 single pads side and the 3 single pads side on each row
The double pin header row. It's position corresponds to the two single pads

The single pin headers will connect the protoboard with the breadboard. As this terminals have to be longer and must be soldered on the copper side of the breadboard, I inserted them upside down and then pushed them from the top just to the plastic to make them as long as they can on the bottom side.

The single pin headers inserted upside down. Check the three leftmost pins that have been pushed down further.

Given the odd layout of the protoboard, I found easier to put the right side headers one hole farther and put jumpers between the tracks. Check how the solder bridges the up and down facing pins and tracks.

The jumpers on the up side and the soldering on the down side.

Finally, cut it using a Dremel. I should have done this before the soldering!.

Side view.
Runni
 [...]

I've been working on a project to build a Laser Range Finder using a Raspberry Pi, an Arduino and OpenCV using a webcam. I hope that eventually this project may be used on a mobile robot using the algorithms taught on Udacity CS373 specially SLAM (Synchronous Location and Mapping).

The First Prototype

This first protoype is more a proof of concept than a usable device. Anyway, it's working pretty well except for it being quite slow.

  • Raspberry Pi Model B running:
    • Archlinux ARM with a modified kernel to support the Arduino and the Webcam
    • OpenCV 2.4.1
    • Python 2.7
    • The LRF software
  • Arduino UNO connected via USB to the Raspberry Pi. Runs a controller that receives a message to turn on and off the laser. I hope it will also control some servos later.
  • A Logitech c270 webcam, disassembled, so it can be installed on the casing
  • Sparkfun TTL Controlled Laser Module
  • A targus mini USB hub
  • My Powered USB cable to provide the extra current that the Raspberry Pi can't provide to the USB devices
  • A couple of USB power sources, one for the RPi and the other for the USB devices
  • A lousy acrylic casing, the first thing I've done with acrylic

Also check the video for an overview on it's parts and how it works.

This prototype is very slow (one measurement takes about 10 seconds) but I'm optimistic that it may become more functional on a couple of iterations, specially with the upcoming Raspberry Pi Foundation CSI camera. The device is pretty accurate and precise on short distances but, as expected, both decrease at large distances. I would estimate that from a distance up to 35cms it's very accurate, from 35 to about 60cms has pretty good and up to 2m it may be good enough for a small robot.Later I'll post more details on the measured precision and accuracy and some tricks to enhance them.

As you can see on the video, it has a simple web interface to trigger the measurement process. It can also be done command line by SSHing to the Raspberry Pi. I'll also

 [...]
  • July 8, 2012
  • Updated over 2 years ago
  • 6 Comments
  • Permalink

Seguimos analizando el comportamiento del los candidatos que buscan empleo en OCCMundial. En esta ocasión recreamos una visualización que hicimos hace mas de un año sobre las "rutas" que se generan cuando la gente solicita empleo fuera de la zona donde reside. Para ello obtuvimos un conjunto de datos de 48,801 solicitudes de empleo anonimizadas, marcadas con las direcciones de origen (la del candidato) y destino (de la vacante según lo capturado por el reclutador). Para obtener las coordenadas geográficas de ambos puntos usamos el API de Google Maps al cual le enviamos las direcciones lo más limpias posible y obtuvimos la coordenadas más próximas que Google pudo encontrar. Estos datos los graficamos en un mapa en forma de curvas de llegada/salida en Processing usando el método para mapas georeferenciados que describí hace algún tiempo usando mapa blanco con líneas negras de este otro post.

En la visualización se pueden ver las principales ciudades de México ligadas mediante curvas. Cada curva tiene un origen, es decir, un punto de dónde un candidato está solicitando un empleo, y un destino, el lugar donde se está ofreciendo la vacante. En el punto de origen la linea tiene una mayor curvatura y en el destino llega casi recta. Por ejemplo, en la siguiente imagen se muestra la zona de Puerto Vallarta (derecha) y Guadalajara (derecha) donde se puede ver dos cosas: que a Guadalajara llega y se va mucho mas gente que en Puerto Vallarta, pero que al mismo tiempo mucho mas gente quiere ir de Guadalajara a Puerto Vallarta que a la inversa.

Desarrollamos también una visualización inteactiva que permite observar mejor las rutas de llegada y salida. Al colocar el mouse en alguna ciudad se resaltan las rutas de salida en azul y las de

 [...]

La visualización de información es uno de los aspectos fundamentales del análisis de datos en la actualidad, como en el caso de la reciente visualización de amistad en Facebook que tuvo gran éxito

En OCCMundial estamos trabajando en geolocalización de ofertas de trabajo. Obtuvimos datos muy interesantes pero al tratar de visualizarlos con un mapa de fondo para hacer más interesante la presentación de los datos me encontré con el problema de conseguir un mapa georeferenciado sobre el cual mostrar la información. De otras regiones tales como el mundo completo, Estados Unidos o Europa es sencillo conseguirlos pero fue más complicado en el caso de México. Tampoco encontré un procedimiento sencillo para generarlo, por lo que en este post pongo mi experiencia y los resultados esperando que le sirvan a alguien más. La idea vino de Minigis que lo usa en un mapa mundial.

El problema consiste en conseguir una imagen de un mapa en el cual se tenga una correspondencia entre coordenadas geográficas y los pixeles. Los buenos mapas que escalan con el nivel de zoom son imágenes vectoriales.Wikimedia es un excelente recurso para comenzar. Los mapas estan en formato SVG. Aquí se encuentran los mapas de México. Es importante fijarse en el tipo de proyección ya que afecta el aspecto del mapa. Para este caso necesitamos un mapa equirectangular en el cual las coordenadas geográficas se pueden mapear de forma lineal con los pixeles de la imagen. Aunque el mejor mapa de México que conseguí tiene división política por municipios, lo que lo hace pesado y no muy bonito para algunos casos, pero es suficientemente bueno para nuestro uso.

Desafortunadamente el mapa no especifica las coordenadas que comprende por lo que es necesario averiguarlas. Usando Inkscape abrí el mapa y encontré que tiene marcados parale

 [...]

These are my notes on how I got OpenCV running on the Raspberry Pi today with a webcam. On this post you can find the Debian version that I did earlier.

  • Install Arch Linux ARM from image, use this guide.
  • Expand linux parition, also detailed on the same guide.
  • Configure copying arm224_start.elf to start.elf to get more memory for the apps
  • Configure networking: edit /etc/rc.conf and /etc/resolv.conf. Check this topic
  • Modify pacman configuration /etc/pacman.conf to use curl to download packages for my slow connection by uncommenting the line:
     XferCommand = /usr/bin/curl -C - -f %u > %o
  • I tried several times to update pacman and system using
    pacman -Syu
    but some errors about udev and libusb were found, and I finally gave up with this step. At last, everything worked except lxde which I don't need, so I'll check this back some other time.
  • Install lxde. I'm not sure if some libraries installed by this are useful to OpenCV.
    pacman -S lxde xorg-xinit xf86-video-fbdev
    
  • lxde didn't worked: every time I tried to xinit, it throwed a error about libudev.so.1 not being found.
  • Install python2 (which was already installed but was updated), numpy, opencv and samples:
    pacman -S python2 python2-numpy opencv opencv-samples
    
  • Finally I run a simple test I use to open the webcam stream, take a frame and save it. It didn't worked immediatly since I found that a Dell multimedia keyboard I had attached to a USB hub with my DIY USB powered cable with the webcam had some issues. But after solving it, the camera works and saves the image. The sample is this:
    import cv2.cv as cv
    import time
    
    #cv.NamedWindow("camera", 1)
    
    #capture = cv.CaptureFromCAM(-1)
    capture = cv.CreateCameraCapture(1)
    #cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FPS, 3)
    cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_WIDTH, 1280)
    cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_HEIGHT, 720)
    
    img = cv.QueryFrame(capture)
    
    print "Captured "
    cv.SaveImage("output.jpg",img)
 [...]
  • June 8, 2012
  • Updated over 2 years ago
  • 16 Comments
  • Permalink

UPDATE 2:Here is my guide for Arch Linux

UPDATE: I've moved to Archlinux because it has the webcam modules included. OpenCV is really easy to install: pacman -S opencv

Installing OpenCV (2.3.1) on the Raspberry Pi is pretty easy using the base Debian Squeeze image and following these instructions for Debian/Ubuntu.You will need to have more space on the root partition so I recommend resizing it to at least 3GB (see the video tutorial using GParted or follow these instructions). Here they are with some comments on the few issues I found:

I found an error trying to install cmake for the first time, so first do

sudo apt-get update

two times before anything else. The first time I did the update an error on "duplicate sources" was shown thus the second update was necessary.

Install in the following order:

sudo apt-get install build-essential
sudo apt-get install cmake 
sudo apt-get install pkg-config 
sudo apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3 
sudo apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2 
sudo apt-get install zlib1g-dbg zlib1g zlib1g-dev 
sudo apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools 
sudo apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs 
sudo apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev 
sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0  libgstreamer0.10-dev 
sudo apt-get install libxine1-ffmpeg  libxine-dev libxine1-bin 
sudo apt-get install libunicap2 libunicap2-dev 
sudo apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils 
sudo apt-get install swig 
sudo apt-get install libv4l-0 libv4l-dev 
sudo apt-get install  python-numpy 
sudo apt-get install libpython2.6 python-dev python2.6-dev 
sudo apt-get install libgtk2.0-dev pkg-config

The package build-essential was already installed on my device so maybe you don't need to install it. Note that for the eighth line the original link say

 [...]
  • May 22, 2012
  • Updated over 2 years ago
  • 41 Comments
  • Permalink