segwayrmp400.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2009 Goutham Mallapragda, Anthony Cascone, Rich Mattes & Brian Gerkey
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  */
20 /*
21  Desc: Segway RMP 400 Driver
22  Authors: Goutham Mallapragada, Anthony Cascone, Rich Mattes
23  Updated: July 21, 2009
24 */
25 
26 #ifndef __SEGWAYRMP400_H_
27 #define __SEGWAYRMP400_H_
28 
29 #include <stdio.h>
30 #include <pthread.h>
31 #include <string.h>
32 #include <stdlib.h>
33 #include <math.h>
34 #if !defined (WIN32) || defined (__MINGW32__)
35  #include <unistd.h>
36 #endif
37 #if !defined (WIN32)
38  #include <netinet/in.h>
39 #endif
40 
41 #include <libplayercore/playercore.h>
42 
43 
44 // SegwayRMP400 Position Driver
46 {
47 
48 public:
49 
50  // Standard Constructor
51  SegwayRMP400(ConfigFile* cf, int section);
52 
53  // Initialize (Player Standard)
54  virtual int MainSetup();
55 
56  // Shutdown (Player Standard)
57  virtual void MainQuit();
58 
59 private:
60 
61  // Devices
62  Device* segwayrmp2d[2]; // child segwayrmp200 devices for 2d subsrciption
63  Device* segwayrmp3d[2]; // child segwayrmp200 devices for 3d subsrciption
64 
65  // Device Addresses
66  player_devaddr_t segwayrmp2d_id[2]; // 2d Position Interface Address (Output)
67  player_devaddr_t segwayrmp3d_id[2]; // 3d Position Interface Address (Output)
68 
69  player_devaddr_t position3d_id; // 3d Position Interface Address (Input)
70  player_devaddr_t position2d_id; // 2d Position Interface Address (Input)
71 
72  // Device Data Structures
73  player_position2d_data_t rmp2d_data[2]; // Incoming data from child segwayrmp200 devices 2d
74  player_position3d_data_t rmp3d_data[2]; // Incoming data from child segwayrmp200 devices 3d
75 
76  player_position2d_data_t position2d_data; // Output data for parent segwayrmp400 device 2d
77  player_position2d_cmd_vel_t position2d_cmd; // Output cmd for parent segwayrmp400 device 2d
78 
79  player_position3d_data_t position3d_data; // Output data for parent segwayrmp400 device 3d
80  player_position3d_cmd_vel_t position3d_cmd; // Output cmd for parent segwayrmp400 device 3d
81 
82  // Flags
83  bool provide_2d; // Provide 2d interface Flag
84  bool provide_3d; // Provide 3d interface Flag
85 
86  int counter;
87  // Main
88  void Main();
89 
90  // Process message function (Player Standard)
91  int ProcessMessage(QueuePointer &resp_queue, player_msghdr_t* hdr, void* data);
92 
93  // Packages position data and publishes
94  void ProcessData();
95 
96  // Internal method to handle position 3D commands
98 
99  // Internal method to handle position 2D commands
101 
102  // Flags for new data
103  bool newfront3d, newback3d, newfront2d, newback2d;
104 
105  // Flag for full speed data reporting.
106  bool fullspeed;
107 };
108 
109 #endif
Class for loading configuration file information.
Definition: configfile.h:196
position 2d velocity command
Definition: player_interfaces.h:617
void Main()
Main method for driver thread.
Definition: segwayrmp400.cc:268
Generic message header.
Definition: player.h:161
virtual void MainQuit()
Cleanup method for driver thread (called when main exits)
Definition: segwayrmp400.cc:247
A device address.
Definition: player.h:145
Base class for drivers which oeprate with a thread.
Definition: driver.h:552
Data: state (PLAYER_POSITION3D_DATA_STATE)
Definition: player_interfaces.h:2476
Command: velocity (PLAYER_POSITION3D_CMD_SET_VEL)
Definition: player_interfaces.h:2504
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:74
An autopointer for the message queue.
Definition: message.h:73
void ProcessData()
Definition: segwayrmp400.cc:421
virtual int MainSetup()
Sets up the resources needed by the driver thread.
Definition: segwayrmp400.cc:197
position2d data
Definition: player_interfaces.h:606
int HandlePosition3DCmd(player_position3d_cmd_vel_t *cmd)
Definition: segwayrmp400.cc:390
int HandlePosition2DCmd(player_position2d_cmd_vel_t *cmd)
Definition: segwayrmp400.cc:405
SegwayRMP400(ConfigFile *cf, int section)
Definition: segwayrmp400.cc:116
int ProcessMessage(QueuePointer &resp_queue, player_msghdr_t *hdr, void *data)
Message handler.
Definition: segwayrmp400.cc:292
Definition: segwayrmp400.h:45