Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef FS100CMD_H
00030 #define FS100CMD_H
00031
00032
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include <unistd.h>
00036 #include <time.h>
00037 #include <string.h>
00038 #include <sys/types.h>
00039 #include <sys/socket.h>
00040 #include <netinet/in.h>
00041 #include <netinet/ip.h>
00042 #include <netinet/tcp.h>
00043 #include <netdb.h>
00044 #include <queue>
00045 #include <pthread.h>
00046
00047 #include "motoman_direct_message.h"
00049
00052 typedef struct{
00053 float pos[6];
00054 float vel[6];
00055 float time;
00056 }cmd;
00057
00059
00062 class Fs100Cmd{
00063 private:
00064
00065 const char* IP;
00066 int sockfd, portno, n, i,run_thread;
00067 volatile int seq;
00068 unsigned int thread_sleep;
00069 float abs_time;
00070 volatile bool stop_all;
00071
00072
00073
00074 struct sockaddr_in serv_addr;
00075 struct hostent *server;
00076 pthread_t cmdthreadID;
00077 SimpleMsg joint_data,motion_rpl;
00078 char raw_data[255];
00079 char traj_buffer[152];
00080 char motion_reply_buffer[76];
00081 static void *cmdPushThread(void *This);
00082 std::queue<cmd> cmdList;
00083
00084
00085 void cmdPush();
00086 void socketError(const char *msg);
00087 void byteSwap(char* data,int length);
00088 void serialize(SimpleMsg *msg, char *data,int size);
00089 void deserializeMotionReply(char *data,SimpleMsg *msg);
00090 int buildTrajPos(SimpleMsg *tm,float pos[6],float time,int seq);
00091 int buildTrajFull(SimpleMsg *tm,float pos[6],float vel[6],float time,int seq);
00092 void motionReady(SimpleMsg *msg);
00093 void trajectoryStart(SimpleMsg *msg);
00094 void trajectoryStop(SimpleMsg *msg);
00095 void printErrorCodeMsg(SimpleMsg *msg);
00096 void printMotionReply(SimpleMsg *msg);
00097 void printTrajFull(SimpleMsg *msg);
00098 int getLength(char* data);
00099
00100
00101
00102 public:
00103
00105
00108 Fs100Cmd(const char* ip){
00109 IP = ip;
00110 portno = 50240;
00111 i = 1;
00112 pthread_mutex_t mut_lock = PTHREAD_MUTEX_INITIALIZER;
00113 }
00115
00118 int init();
00119
00121
00124 int makeConnect();
00125
00127
00131 int start(int retry);
00132
00133
00135
00139 bool resetTrajectory(int *retry);
00140
00142
00149 bool pushTraj(float pos[6],float vel[6],float time,int seq);
00151
00156 bool addCmdToQueue(cmd cmd_point);
00158
00164 bool addPointToQueue(float pos[6],float vel[6],float time);
00165
00167
00170 void pgmClose();
00171 };
00172
00173
00174
00175 #endif //FS100CMD