Thu Feb 4 09:35:33 EST 2010
Gavia captured in Echo-sounder
I just got back from New Zealand where we ran our Gavia AUV in several lakes and Tasman Bay. Most of our work was related to water chemistry rather than seafloor mapping but it was super fun and very interesting. On one of our adventures in Tasman Bay we drifted over Gavia’s path and caught a glimpse of here on the boat’s echo-sounder. I took a snapshot. Its the blob about 19.5 m down under the cross-hairs.:

Thu Jan 7 09:06:09 EST 2010
Parrot AR.Drone uses Iphone for Navigation - Coolest thing EVER
I was recently sent a link about the new Parrot AR.Drone remote control quad-rotor helicopter. It is navigated using the tilt sensors of the iphone which is cool in itself. But it also has a live video feed from one of two cameras back to the iphone so you can see its poing of view. It comes with an optional shroud for the rotors so you can bump into things if your flying in tight spaces. Check out their video:
As if all this isn’t enough, the very best thing about it is that they are planning to release a software developer’s kit for it! Oh the science we could do. Now I wonder what payload it might be able to carry.
We'd need a small onboard auxiliary power supply, data logger, a GPS, and maybe a tilt sensor. Ocean Server has a small enough attitude sensor with onboard magnetic compass. Yes, there’s lots of cool stuff we could do with one of these.
Thu Jan 7 08:48:42 EST 2010
New Vacuum Robot uses SLAM
Neato Robotics has just released a competitor to the Roomba (iRobot’s vaccuum cleaner). This is the first commercial consumer robot I know of tha uses SLAM – (Simultaneous Localization and Mapping) in which a vehicle maps its environment as it navigates through it allowing it to keep track of where it has been and where it is going.Their robot does its mapping with a laser scanner. Very cool.
Wed Jan 6 12:47:50 EST 2010
Executing Python from Within MATLAB
Today I figured out a way to execute python code from within MATLAB. This wil work on OS-X and Linux and a variant should work under Windows – depending no your python installation. Here’s how it works.
First create the following bash script:
#!/bin/bash
#
# Val Schmidt
# CCOM/JHC
# Jan 2010
#
# A script to provide a wrapper for execution of python from MATLAB.
PYTHONCODE=/Users/vschmidt/svnsandbox/Gavia/python
/usr/bin/env python $PYTHONCODE/$@
Be sure to modify the PYTHONCODE variable to point to the
directory of python scripts you want to execute. Make the script
executable (chmod +x executepy.sh) and put it in your
path somewhere.
From within MATLAB you can execute your script like this:
unix('source ~/.bash_profile; executepy.sh pythonscript args')
Where pythonscript is the python script you want to
execute and args are it’s arguments. It is assumed
here that.bash_profile contains your PATH definition
(or redefinition). You may have to modify that. You could also
modify your PATH on the fly rather than the source statement above
if there are things in .bash_profile you don’t want MATLAB’s shell
to execute.
This method doesn’t return anything to MATLAB directly. I'm not aware of a way to do that, other than saving the results of your python script to a file that MATLAB can natively read in a subsequent command. (See scipy.io.savemat.)
Tue Jan 5 22:16:05 EST 2010
Direct Path to Bottom Bounce Propagation Time Difference vs. Range
Today for a project I'm helping with in ocean acoustics I made a nomograph of the differenced in receive time of a transient signal that follows both a direct path and a bottom bounce trajectory, as a function of range.

As a submariner in the Navy We did this kind of ranging all the time, but I've never properly done the calculations complete with ray-trace model. You can see some wiggle in the curve at the most distant ranges where my algorithm for detecting where the two ranges intersect gets a little wonky.
Mon Jan 4 17:31:32 EST 2010
Logon Real Time Airport Monitor
I just ran across this site which shows a 10 minute delayed feed of Airport traffic into and out of Logon International Airport. Check it out!

This is really cool, but isn’t this a security threat? I wonder who uses this. It won’t load on my iphone so it is not likely something you could scan before coming to pick someone up. You certainly get a feel for what it must be like to be an air traffic controller – Shew! Fun to watch.
I wonder if the Coast Guard would ever do this for shipping via AIS. (“No” is probably the answer to that question.)
Mon Jan 4 16:33:30 EST 2010
Saving MATLAB .mat files in python
I've been working on how to save MATLAB .mat files using
python’s scipy module. Here are some hints for using
the scipy.io.savemat command. There
is a nice tutorial on the subject.
In python:
import scipy.io as p
nav = {} # this is a dictionary
nav['lat'] = 38.4
nav['lon'] = -70.1
p.savemat('test.mat',nav)
In MATLAB
load test.mat
whos
lat lon
Ok so now, how do we save a MATLAB structure? After some research it seems I need a scipy update. My current version (as part of my Enthought Python Distribution is 0.6. The current version supplied by the folks at Enthought is 0.8 and the tutorial above seems to be using 0.7. So standby…
YES! It works! Here’s how:
import scipy.io as p
data = {}
nav = {}
nav['lat'] = 38.4
nav['lon'] = -70.1
data['nav'] = nav
p.savemat('test.mat',data)
In MATLAB
>load test.mat
>nav
nav =
lat: 38.399999999999999
lon: -70.099999999999994
Perfect!
Mon Jan 4 13:44:30 EST 2010
Programming MATLAB Mex files
Last night I began my first attempt at programming c-routines
(so-called mex files) that can be called natively from
MATLAB to speed up specific tasks. It’s realy cool!
Here’s some quick code and hints to get you started.
/* [output1 output2] = mymexfile( input1, input2)*/
#include <mex.h>
#include <math.h>
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
mexPrintf("Hello, world!\n");
}
Thee’s no main() function in a mex file. Rather
everything goes in the mexFunction routine. Here are
the arguments:
- nlhs: The number of output (left hand size) elements, 2 in this case (output1 and output2).
- plhs[]: An array of pointers to each of the output data structures.
- nrhs: The number of input (right hand size) arguments, 2 in thse case (input1 and input2)
- prhs[]: An array of points to each of the input data structures.
Input and output data structures are of type
mxArray. I like to assign the inputs to something more
understandable like this.
mxArray *pinput1, *pinput2;
double *input1, *input2;
pinput1 = prhs[0];
pinput2 = prhs[1];
input1 = mxGetPr(pinput1);
input2 = mxGetPr(pinput2);
Here I've given the input pointer list more meaningful names
(pinput1, pinput2) and extracted a
pointer to each input array (input1 and
input2). This allows one to address the input as
input1[0], input1[2], etc.
To write data back out, you have to create variables of mxArray type and assign them to the output pointer list. Here’s how:
plhs[0] = mxCreateDoubleMatrix(1, N, mxREAL); /*output1*/
plhs[1] = mxCreateDoubleMatrix(1, N, mxREAL); /*output2*/
output1 = mxGetPr(plhs[0]);
output2 = mxGetPr(plhs[1]);
output1[0] = 10.5;
output2[0] = 13.3;
Here we create output matrices. A pointer to each is stored in plhs. Then we get pointers to the data within each. These now look like arrays which can be indexed as normal and assigned output values as makes sense.
An example error message:
mexErrMsgTxt("Duplicate sound speed depth values. Exiting...\n");
An example print statement (prints into MATLAB):
mexPrintf("Starting Point: %f,%f\n",xo[0],zo[0]);
Finally to compile the code you simply navigate to the directory form within MATLAB and type:
mex mymexfile.c
You'll get an executable which you can run just like a MATLAB m-file.
[output1 output2] = mymexfile(input1,input2);
I'm coding up a ray-tracing algorithm to expedite processing of
sonar data in MATLAB. Although it is not exactly an apples to
apples comparison, the mex c-code I've written executes more than
45 times faster than the same basic algorithm as a
native MATLAB script.
Tue Dec 29 16:02:13 EST 2009
SSH tunneling
Kurt Schwehr had a great post last month about making ssh tunneling easier.
I wonder how robust a combination of these methods with fuse (mounting
shares over an ssh connection) and autossh
would be. It could give you a way to put sensors in the field and
have them log data (or at least periodically upload data) to any
server within CCOM by simply writing to what looks like a local
part of the file system. Would want to do something smart when the
link is down, but it seems like it might be possible.
