[racket] usb/serial port

From: Eduardo Costa (edu500ac at gmail.com)
Date: Sun Sep 7 12:54:01 EDT 2014

Racketeers.

I work with a small research team that is building a navigation system for
blind people. The hardware is similar to the one used in robotic vision:
Cameras, sonar, GPS, laser measurement sensors, and the like. There are two
sonar systems: (a) A sonar belt around the head to avoid hitting walls,
light poles, etc. This sonar belt has 8 sonars. There is also a pair of
sonars to avoid irregularities on the sidestep. This watch your step sonar
also detects curbs, and activates a camera in charge of recognising zebra
crossings.

The Artificial Intelligence programs are mostly written in Lush. In fact,
the idea is to use the deep learning libraries and image processing
facilities provided in Lush. There are also Common Lisp libraries, like
cl-viola-jones and opticl. The probability of hitting are calculated by
using the Rasch method for each Artificial Intelligence library. Then the
probabilities are combined through the Condorcet's theorem. Once one has
the probability distribution, it is easy to design a gh-filter.

For the time being, the servlets are written in Racket, except for the
Rasch model that is written in Bigloo. As Junia reported to this list, the
Rasch model written in Racket stopped working. Therefore Junia ported the
Rasch model to Bigloo to perform the calibration of the system.

The cameras use the image capture provided by Lush. However, our team
designed custom hardware for the GPS, sonars and other sensors. This system
sends the signal as a string via serial USB to a computer (OS-X or Linux),
that feeds the servlets. Here is how I use it in OS-X 10.9.4:

1- I connect the sonar to a USB port. In this example, I will use the watch
your step sonar. The sonar is supposed to rotate, in order to create a
synthetic aperture  sonar. However I fixed it to simplify the example.

2- I discover where is the sonar:

Eduardos-Mac-mini:~ edu500ac$ ls /dev/tty.*

/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem1421

/dev/tty.Bluetooth-Modem


3- screen /dev/tty.usbmodem1421 9600


4- If I send D, I get a single reading of the sonar. If I send C, I get
continuous reading.


D

Distancia = 00141 mm

D

Distancia = 00176 mm

Dist. Error

D

Distancia = 01261 mm

D

Distancia = 01716 mm


Distancia = 01452 mm

Distancia = 01445 mm

Distancia = 01447 mm

Distancia = 01170 mm

Distancia = 01713 mm

Distancia = 00011 mm

Distancia = 00085 mm

Distancia = 00119 mm

Distancia = 02698 mm

Distancia = 00149 mm

Distancia = 01852 mm

Distancia = 01851 mm


As you can see, we are trying to employ prêt à porter systems, like Lush
(provided by Yann Lecun), deep learning (eblearn, provided by Koray
Kavukcuoglu), opticl (provided by Cyrus Harmon), etc.


Is there a Racket library for USB/serial communication with our equipment?
I mean, is there something like OS-X screen written in Racket? I found the
following answer to a similar question:


I am not sure if there a library specifically written in racket for
reading/writing to serial ports, however, you can read/write to character
devices using standard i/o routines.


Could a member of this list elaborate on this answer?  For instance, how
can I open a device from Racket? I tried:


> (define out (open-output-file "/dev/tty.usbmodem1421"))

. . ../../Applications/Racket
v6.1/share/pkgs/drracket/drracket/private/rep.rkt:1123:24:
open-output-file: cannot open output file

  path: /dev/tty.usbmodem1421

  system error: Permission denied; errno=13

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140907/1823b4bb/attachment.html>

Posted on the users mailing list.