cmps09_calib.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Standard
00004 import serial
00005 import time
00006 
00007 class CMPS09(object):
00008     def __init__(self):
00009         # Opens up serial port 
00010         self.port = '/dev/ttyUSB0'
00011         print "CMPS09 using port %s." % self.port
00012 
00013         try:
00014             self.transport = serial.Serial(port=self.port, baudrate=9600, timeout=0.2)
00015             self.transport.open()
00016         except serial.serialutil.SerialException as e:
00017             print "CMPS09: %s" % e
00018             exit(1)
00019         
00020     # Main loop
00021     def run(self):
00022         print "Beginning calibration"
00023         self.transport.write('\x31')
00024         time.sleep(0.1)
00025         self.transport.write('\x45')
00026         time.sleep(0.1)
00027         self.transport.write('\x5A')
00028 
00029         print "Confirm vehicle is pointing north and press ENTER"
00030         v = raw_input()
00031         self.transport.write('\x5E')
00032         print "Turn to 90 degrees and press ENTER"
00033         v = raw_input()
00034         self.transport.write('\x5E')
00035         print "Turn to 180 degrees and press ENTER"
00036         v = raw_input()
00037         self.transport.write('\x5E')
00038         print "Turn to 270 degrees and press ENTER"
00039         v = raw_input()
00040         self.transport.write('\x5E')
00041         print "Calibration complete"
00042 
00043     def destroy(self):
00044         self.transport.close()
00045         print "CMPS09 shut down"
00046 
00047 
00048 #Init and run
00049 try:
00050     CMPS09().run()
00051 except OSError as e:
00052     print "Failure in calibration (%s) Retry suggested" % e
00053 
00054 CMPS09().destroy()


clearpath_sensors
Author(s): Ryan Gariepy
autogenerated on Sun Oct 5 2014 22:52:23