00001 /* 00002 * ControlComm.h 00003 * 00004 * Created on: Apr 26, 2009 00005 * Author: jgoppert 00006 */ 00007 00008 #ifndef CONTROLCOMM_H_ 00009 #define CONTROLCOMM_H_ 00010 00011 #include <SerialStream.h> 00012 #include <string> 00013 #include <jsw.h> 00014 00015 using namespace LibSerial; 00016 00017 namespace uvsim 00018 { 00019 00020 static const char m_msgHeader = 'A'; 00021 static const char m_msgFooter = 'Z'; 00022 static const char * joystickCalibration = "/usr/local/share/uvsim/joystick"; 00023 00024 union checksum 00025 { 00026 short int sint; 00027 char byte[2]; 00028 }; 00029 00030 class ControlComm 00031 { 00032 public: 00033 ControlComm(std::string servoPort, bool useJoystick); 00034 virtual ~ControlComm(); 00035 void update(); 00036 private: 00037 bool m_useJoystick; 00038 SerialStream m_serialPort; 00039 checksum sum; 00040 char m_msg[3]; 00041 float m_throttle, m_steering, m_headingAngleFeedback; 00042 bool m_autoMode; 00043 js_data_struct m_joystick; 00044 }; 00045 00046 } 00047 00048 #endif /* CONTROLCOMM_H_ */