00001 /*************************************************************** 00002 00003 Intelligent Ground Vehicle Competition 2010 00004 Pennsylvania State University - Robotics Club 00005 Learn more at www.psurobotics.org 00006 Protected by the GNU General Public License 00007 00008 This source file originally developed by: 00009 + Rich Mattes rjm5066@psu.edu 00010 00011 File: OS5000.h 00012 Desc: Communication protocol for OS5000 compass. 00013 This class assumes the "$OHPR" output method with 00014 a bitmask of 1297 (azimuth, pitch, roll, temp, accelerometers, gyros) 00015 00016 ***************************************************************/ 00017 00018 // Inclusion guard 00019 #ifndef __OS5000_H_ 00020 #define __OS5000_H_ 00021 00022 // Includes 00023 #include <string.h> 00024 #include <stdint.h> 00025 #include <stdlib.h> 00026 #include <stdio.h> 00027 #include <iostream> 00028 #include <sstream> 00029 #include "flexiport/flexiport.h" 00030 #include "flexiport/port.h" 00031 #define DEBUG 0 00032 00033 // Serial Timeout (seconds) 00034 #define SERIAL_TIMEOUT 0.4 00035 00036 struct CompassData{ 00037 char Header[8]; 00038 double Bearing; 00039 double Roll; 00040 double Pitch; 00041 double Temp; 00042 double Acc[3]; 00043 double Gyro[2]; 00044 }; 00045 00046 class OS5000 00047 { 00048 public: 00049 00052 OS5000(char *DevicePath, int UpdateRate); 00053 00055 ~OS5000(); 00056 00058 int InitCompass(); 00059 00062 int CheckCompass(); 00063 00065 int ResetCompass(); 00066 00068 int GetInfo(CompassData*); 00069 00070 private: 00071 00072 // Starts the serial port 00073 int SetupPort(char* PortOpts); 00074 00075 // Stops the serial port. 00076 int ShutdownPort(); 00077 00078 // Sets correct compass configuration 00079 int ConfigureCompass(int UpdateRate); 00080 00081 // The options to use when configuring the port 00082 char PortOptions[128]; 00083 int UpdateRate; 00084 00085 // The Flexiport port object 00086 flexiport::Port* port; 00087 00089 clock_t LastReadTime; 00090 00091 int ErrorCount; 00092 }; 00093 00094 // Inclusion guard 00095 #endif
1.5.5