00001 00002 #ifndef AUBO_REALTIME_COMMUNICATION_H_ 00003 #define AUBO_REALTIME_COMMUNICATION_H_ 00004 00005 #include <vector> 00006 #include <stdlib.h> 00007 #include <stdio.h> 00008 #include <string.h> 00009 #include <sys/time.h> 00010 #include <thread> 00011 #include <mutex> 00012 #include <condition_variable> 00013 #include <sys/types.h> 00014 #include <sys/socket.h> 00015 #include <netinet/in.h> 00016 #include <netinet/tcp.h> 00017 #include <netdb.h> 00018 #include <iostream> 00019 #include <unistd.h> 00020 #include <arpa/inet.h> 00021 #include <errno.h> 00022 #include <fcntl.h> 00023 #include <sys/types.h> 00024 00025 #include "robot_state.h" 00026 00027 class AuboRealtimeCommunication { 00028 private: 00029 int sockfd_; 00030 struct sockaddr_in serv_addr_; 00031 struct hostent *server_; 00032 std::string local_ip_; 00033 bool keepalive_; 00034 std::thread comThread_; 00035 int flag_; 00036 std::recursive_mutex command_string_lock_; 00037 std::string command_; 00038 void run(); 00039 00040 00041 public: 00042 bool connected_; 00043 RobotState* robot_state_; 00044 00045 AuboRealtimeCommunication(std::condition_variable& msg_cond, std::string host); 00046 bool start(); 00047 void halt(); 00048 00049 void setSpeed(double q0, double q1, double q2,double q3, double q4, double q5, double acc); 00050 void addCommandToQueue(std::string inp); 00051 std::string getLocalIp(); 00052 00053 void setMessagePush(bool flag); 00054 void getRobotPosition(); 00055 void getRobotJointStatus(); 00056 void getRobotSystemStatus(); 00057 void getRobotEndSpeed(); 00058 00059 }; 00060 00061 #endif /* Aubo_REALTIME_COMMUNICATION_H_ */