fs100_state.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  *
00003  * C++ class for continous trajectory point streaming using FS100 controller mh5l robot
00004  * Author: Asger Winther-Jørgensen (awijor@elektro.dtu.dk)
00005  *
00006  * Software License Agreement (LGPL License)
00007  *
00008  *  Copyright (c) 2014, Technical University of Denmark
00009  *  All rights reserved.
00010  
00011  *  This program is free software; you can redistribute it and/or modify  
00012  *  it under the terms of the GNU Lesser General Public License as        
00013  *  published by the Free Software Foundation; either version 2 of the    
00014  *  License, or (at your option) any later version.                       
00015  *                                                                        
00016  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00017  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00018  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00019  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00020  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00022  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00024  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00026  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  *  POSSIBILITY OF SUCH DAMAGE.
00028  *********************************************************************/
00029 
00030 #ifndef FS100STATE_H
00031 #define FS100STATE_H
00032 
00033 
00034 #include <stdio.h>
00035 #include <stdlib.h>
00036 #include <unistd.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 <pthread.h>
00045 
00046 
00047 #include "motoman_direct_message.h"
00048 
00049 
00051 
00054 class Fs100State
00055 {
00056 private:
00057     //private variables and functions
00058     
00059     const char* IP; 
00060     int sockfd, portno, n, i,run_thread; 
00061     struct sockaddr_in serv_addr; 
00062     struct hostent *server; 
00063     pthread_t recvthreadID; 
00064     SimpleMsg joint_data; 
00065     bool joint_values_updated; 
00066     char raw_data[148];  
00068     pthread_mutex_t mut_lock; 
00069     pthread_cond_t mut_cond; 
00070     float current_pos[6]; 
00071     bool pos_updated; 
00073     static void *recvDataThread(void *This);
00074     void recvData();
00075     void socketError(const char *msg);
00076     void byteSwap(char* data,int length);
00077     void serialize(SimpleMsg *msg, char *data,int size);
00078     void deserializeJointFeedback(char *data,SimpleMsg *msg);
00079     void deserializeMotionReply(char *data,SimpleMsg *msg);
00080     void printMotionReply(SimpleMsg *msg);
00081     void printJointFeedback();
00082     int getLength(char* data);
00083     
00084     
00085 
00086 public:
00087     //public variables and functions
00089 
00092     Fs100State(const char* ip){
00093     IP = ip;
00094     portno = 50241;
00095     i = 1;
00096     pthread_mutex_t mut_lock = PTHREAD_MUTEX_INITIALIZER;
00097     }
00099 
00102     int init();
00103     
00105 
00108     int makeConnect();
00109     
00111 
00114     void pgmClose();
00115     
00117 
00121     bool getJointsUpdated(float* joints);
00122 };
00123 
00124 
00125 
00126 #endif //FS100STATE


fs100_motoman
Author(s): Asger Winther-Jørgensen (Technical Univeristy of Denmark)
autogenerated on Fri Aug 28 2015 10:42:16