3. Introduction
Arduino
GPS
Maps
GUI
What problem we want to solve?
Main objective
Looking for a low cost and wide range system to locate AUV.
GPRS systems coverage problems far from coast
Iridium satellite communication costs
Future
6. Introduction
Arduino
GPS
Xbee Devices
ZIGBEE
Freq: 2.4GHz
Power OUT: 63mW*
Max. Range: 3.2Km
RF Data rate: 250 Kbps
802.11bgn ("Wifi")
Freq: 2.4GHz
Power OUT: 16 dBm
Max. Range: 300m
RF Data rate: 65 Mbps
"PROPRIETARY"
Freq: 868MHz
Power OUT: 350mW
Max. Range: 40Km
RF Data rate: 24 Kbps
* 10mW limited in most EU
Maps
GUI
Future
7. Introduction
Arduino
GPS
Maps
How can I program my Arduino?
Arduino IDE
Classical way to program your Arduino
Using Python Libraries:
Python Arduino Prototyping, Pyduino, Pyfirmata,etc.
PyMite (Python-on-chip)
GUI
Future
8. Introduction
Arduino
GPS
Maps
How can I configure Xbee comunication?
Manufacturer software (X-CTU)
Moltosenso Network Manager
Serial Port (pyserial)
GUI
Future
9. Introduction
Arduino
GPS
Maps
GUI
Pyserial example using AT commands
>>> import serial
>>> ser = serial . Serial ( ’/ dev / ttyUSB0 ’ , baudrate =9600)
>>> ser . write ( ’ +++ ’)
>>> ser . write ( ’ ATID r ’)
>>> ser . read (8)
’ OK r7FFF r ’
>>> ser . write ( ’ +++ ’)
>>> ser . write ( ’ ATID 7 FF1 r ’ ’)
>>> ser . read (8)
’ OK r7FF1 r ’
>>> ser . write ( ’ +++ ’)
>>> ser . write ( ’ ATRE r ’)
>>> ser . write ( ’ ATCN r ’)
Future
10. Introduction
Arduino
GPS
Maps
GUI
Future
Programing example with Arduino IDE
# include < SoftwareSerial .h >
# define rxPin 9
# define txPin 8
SoftwareSerial gps = SoftwareSerial ( rxPin , txPin );
* VARIABLES *
void setup (){
pinMode ( rxPin , INPUT );
pinMode ( txPin , OUTPUT );
gps . begin (4800);
Serial . begin (9600);
delay (1000);
}
11. Introduction
Arduino
GPS
Maps
Programing example with Arduino IDE
void loop (){
byteGPS = 0;
byteGPS = gps . read ();
while ( byteGPS != ’$ ’ ){
byteGPS = gps . read ();
}(*)
byteGPS = gps . read ();
if ( byteGPS == ’G ’ ){ (*)
while ( byteGPS != ’* ’)
{
byteGPS = gps . read ();
GPS [ i ] = byteGPS ;
i ++;
}(*)
while (j < i ){
Serial . write ( char ( GPS [ j ]));
j ++;
}
Serial . println ();
}
}
(*) Missing lines of code
GUI
Future
12. Introduction
Arduino
GPS
Maps
Programing example with Python
from arduino import Arduino
import time
b = Arduino ( ’/ dev / ttyUSB0 ’)
pin = 9
# declare output pins as a list / tuple
b . output ([ pin ])
for xrange (10):
b . setHigh ( pin )
time . sleep (1)
print b . getState ( pin )
b . setLow ( pin )
print b . getState ( pin )
time . sleep (1)
b . close ()
https://github.com/vascop/Python-Arduino-Proto-API-v2/
GUI
Future
13. Introduction
Arduino
GPS
Maps
GUI
Future
After programing what we get?
>>> import serial
>>> from serial . tools import list_ports
>>> for port in list_ports . comports ():
...
print port
...
( ’/ dev / ttyUSB0 ’ ,... , ’ VID : PID =0403:6001 SNR = A9014UV2 ’)
( ’/ dev / ttyACM0 ’ ,... , ’ VID : PID =2341:0043 SNR = 8 5 2 3 5 3 5 3 1 3 7 3 5 1 1 1 8 1 1 2 ’)
>>> ser = serial . Serial ( ’/ dev / ttyUSB0 ’ ,9600)
>>> ser . inWaiting ()
243
>>> ser . readline ()
’ $GPGGA ,203156.000 ,4122.5905 , N ,00208.1725 , E ,...*5 r r n ’
15. Introduction
Arduino
GPS
Maps
Georefed images formats
TIFF + TFW ⇐⇒ GeoTIFF
Using a .tif file and a .tfw
Geotiff (embedded georeferencing information)
Where to obtain this files for free?
Institut Cartogràfic de Catalunya
Centro Nacional de Información Geográfica
GUI
Future
17. Introduction
Arduino
GPS
Maps
GUI
Future
How to plot a GeoTIFF?
from osgeo import gdal
import matplotlib . pyplot as plt
gtif = gdal . Open ( ’ canal . tif ’)
gtif . G et P r o j e c t i o n R e f ()
gtif_array = gtif . ReadAsArray ()
tfw = gtif . G et G eo Tr a ns f or m ()
A ,D ,B ,E ,C , F = tfw [1] , tfw [2] , tfw [4] , tfw [5] , tfw [0] , tfw [3]
L = gtif . RasterXSize
H = gtif . RasterYSize
BLX , BLY , TRX , TRY =C , F , C +( L * A ) , F +( H *( E ))
extent =[ BLX , TRX , TRY , BLY ]
fig = plt . figure ()
axes = fig . add_subplot (111)
axes . t i c k l a b e l _ f o r m a t ( useOffset = False , axis = ’ both ’)
plt . imshow ( gtif_array [:3 ,: ,:]. transpose ((1 ,2 ,0)) , extent = extent )
plt . show ()
18. Introduction
Arduino
GPS
Maps
GUI
How to plot a TIFF?
import matplotlib . pyplot as plt
twf_values =[]
file = open ( ’ c a na l_ E TR 89 _ H3 1 . tfw ’ , " r " )
for line in file :
twf_values . append ( float ( line ))
A , D , B , E , C , F = twf_values
file . close ()
file_im = plt . imread ( ’ ca na l _E T R8 9_ H 31 . tif ’ , " r " )
L = len ( file_im [1 , :])
H = len ( file_im [: , 1])
BLX , BLY , TRX , TRY =C , F , C +( L * A ) , F +( H *( E ))
fig = plt . figure ()
axes = fig . add_subplot (111)
axes . t i c k l a b e l _ f o r m a t ( useOffset = False ,
axis = ’ both ’)
plt . imshow ( file_im , extent =[ BLX , TRX , TRY , BLY ])
plt . show ()
Future