00001 00002 //Include system headers 00003 #include <fcntl.h> 00004 #include <termios.h> 00005 #include <cstring> 00006 #include <iostream> 00007 #include <math.h> 00008 #include <sstream> 00009 #include <cstdio> 00010 00011 // Define COM port 00012 //#define COM_PORT "/dev/ttyUSB0" 00013 00014 // Define Baud Rate 00015 #define BAUDRATE B115200 00016 00017 //#define BAUDRATE B4800 00018 00019 // Define Port Timeout 00020 #define TIMEOUT_SEC 10 00021 00022 namespace Servo 00023 { 00024 /*************** 00025 * SSC-32 servo controller library 00026 * 00027 *****************/ 00028 class SSC32 00029 { 00030 private: 00031 int fd; // file description for the serial port 00032 struct termios port_settings; 00033 struct timeval timeout; 00034 std::string command; 00035 std::string Port, Position, Speed; 00036 const char *Output; 00037 int nrOfPorts; 00038 double servoLimits[32][6]; 00039 public: 00040 SSC32(); 00041 ~SSC32(); 00042 void initSerial(); 00043 bool startSerial(std::string); 00044 void stopSerial(); 00045 bool SendMessage(int Port, int position, int speed); 00046 bool CheckIfFinished(); 00047 }; 00048 };//namespace