segwayrmp400.h
00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2009 Goutham Mallapragda, Anthony Cascone, Rich Mattes & Brian Gerkey
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 /*
00021  Desc: Segway RMP 400 Driver
00022  Authors: Goutham Mallapragada, Anthony Cascone, Rich Mattes
00023  Updated: July 21, 2009
00024 */
00025 
00026 #ifndef __SEGWAYRMP400_H_
00027 #define __SEGWAYRMP400_H_
00028 
00029 #include <stdio.h>
00030 #include <pthread.h>
00031 #include <string.h>
00032 #include <stdlib.h>
00033 #include <math.h>
00034 #if !defined (WIN32)
00035   #include <unistd.h>
00036   #include <netinet/in.h>
00037 #endif
00038 
00039 #include <libplayercore/playercore.h>
00040 
00041 
00043 class SegwayRMP400 : public ThreadedDriver
00044 {
00045 
00046 public:
00047 
00049         SegwayRMP400(ConfigFile* cf, int section);
00050 
00052         virtual int MainSetup();
00053 
00055         virtual void MainQuit();
00056 
00057 private:
00058 
00059         // Devices
00060         Device* segwayrmp2d[2];                         
00061         Device* segwayrmp3d[2];                         
00062 
00063         // Device Addresses
00064         player_devaddr_t segwayrmp2d_id[2];             
00065         player_devaddr_t segwayrmp3d_id[2];             
00066 
00067         player_devaddr_t position3d_id;                 
00068         player_devaddr_t position2d_id;                 
00069 
00070         // Device Data Structures
00071         player_position2d_data_t rmp2d_data[2];         
00072         player_position3d_data_t rmp3d_data[2];         
00073 
00074         player_position2d_data_t position2d_data;       
00075         player_position2d_cmd_vel_t position2d_cmd;     
00076 
00077         player_position3d_data_t position3d_data;       
00078         player_position3d_cmd_vel_t position3d_cmd;     
00079 
00080         // Flags
00081         bool provide_2d;                                
00082         bool provide_3d;                                
00083 
00084         int counter;
00086         void Main();
00087 
00089         int ProcessMessage(QueuePointer &resp_queue, player_msghdr_t* hdr, void* data);
00090 
00092         void ProcessData();
00093 
00095         int HandlePosition3DCmd(player_position3d_cmd_vel_t* cmd);
00096 
00098         int HandlePosition2DCmd(player_position2d_cmd_vel_t* cmd);
00099         
00101         bool newfront3d, newback3d, newfront2d, newback2d;
00102 
00104         bool fullspeed;
00105 };
00106 
00107 #endif