Archive for the ‘PHP’ Category


@tavros02 rides again!


The University of South Florida’s Tavros02 submersible autonomous vehicle (robotic submarine!), when it is deployed, tweets its position, heading, and some basic measurements. Its tweets look like this:

LAT=27.761812 LON=-82.634977 HEAD=267.30 ALT=2.36 DEP=1.10 TEM=21.16 CON=34726 #USF #SeaTweet

Well, that’s pretty cool, but I wanted to make it even cooler. So I wrote a REST service in PHP that would get the RSS feed of the sub’s Twitter timeline and convert it to a KML file (a geographic XML file, basically) that would display it on Google Maps. The KML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="">
    <Snippet>A robotic submarine with a Twitter habit, operated by the USF Marine Science EcoSystems Technology Group.</Snippet>
      <p><b>About @tavros02:</b></p>
      <p>Solar-powered Autonomous Underwater Vehicle (SAUV), #2 in <a href=''>the Tavros fleet</a>, operated by the <a href=''>USF</a> <a href=''>Marine Science</a> <a href=''>EcoSystems Technology Group</a>.</p>
        <b>Raw data</b>
          <li>Last update: Fri, 09 Nov 2012 18:58:02 +0000 (one year ago)</li>
          <li>Latitude: 27.761812</li>
          <li>Longitude: -82.634977</li>
          <li>Heading: 267.30</li>
          <li>Water depth: 2.36m</li>
          <li>Depth of vehicle below surface: 1.10m</li>
          <li>Water temperature: 21.16°C (70.1°F)</li>
          <li>Conductivity: 34726 S/m(10^-4)</li>
        <b>Computed data</b>
          <li>Practical salinity (PSS-78): 31.16 [assuming 1 standard atmosphere]</li>

Then everything changed when the Fire Nation attacked Twitter API upgraded to pure OAuth and disallowed anonymous API calls. I ended up learning a lot about OAuth in the process, and a little bit more about PHP, but I’ve got it set up again and @tavros02 is back on the map:


A few neat tricks are involved here:

  1. I used a royalty-free SVG of an arrowhead icon and modified it to use the official colors of the University of South Florida, then wrote a script to rotate it one degree at a time, 360 times, and save it as a series of 360 PNG files with a transparent background. Since @tavros02’s heading rounds to 267 degrees, the arrow is pointing almost-but-not-quite-west.
  2. When I asked why @tavros02 measures conductivity, the answer was ‘because that lets us compute salinity’. I was fascinated by this and added some code to calculate the salinity. So now the popup also displays the PSS-78 salinity, which in this case is 31.16 (it’s dimensionless).

Sadly, @tavros02 itself has not been tweeting for quite some time. The data above is the most recent available. But I’m looking forward to following her next voyage on Google Maps, thanks to a homemade PHP REST service!