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 #ifndef STDR_SERVER_H
00023 #define STDR_SERVER_H
00024
00025 #define USAGE "\nUSAGE: stdr_server <map.yaml>\n" \
00026 " map.yaml: map description file\n"
00027
00028 #include <ros/ros.h>
00029 #include <actionlib/server/simple_action_server.h>
00030 #include <stdr_server/map_server.h>
00031 #include <stdr_msgs/LoadMap.h>
00032 #include <stdr_msgs/LoadExternalMap.h>
00033 #include <stdr_msgs/RegisterGui.h>
00034 #include <stdr_msgs/RegisterRobotAction.h>
00035 #include <stdr_msgs/SpawnRobotAction.h>
00036 #include <stdr_msgs/DeleteRobotAction.h>
00037 #include <stdr_msgs/RobotIndexedMsg.h>
00038 #include <stdr_msgs/RobotIndexedVectorMsg.h>
00039
00040 #include <stdr_msgs/RfidTagVector.h>
00041 #include <stdr_msgs/AddRfidTag.h>
00042 #include <stdr_msgs/DeleteRfidTag.h>
00043
00044 #include <stdr_msgs/CO2SourceVector.h>
00045 #include <stdr_msgs/AddCO2Source.h>
00046 #include <stdr_msgs/DeleteCO2Source.h>
00047
00048 #include <stdr_msgs/ThermalSourceVector.h>
00049 #include <stdr_msgs/AddThermalSource.h>
00050 #include <stdr_msgs/DeleteThermalSource.h>
00051
00052 #include <stdr_msgs/SoundSourceVector.h>
00053 #include <stdr_msgs/AddSoundSource.h>
00054 #include <stdr_msgs/DeleteSoundSource.h>
00055
00056 #include <nodelet/NodeletLoad.h>
00057 #include <nodelet/NodeletUnload.h>
00058
00063 namespace stdr_server {
00064
00065 typedef boost::shared_ptr<MapServer> MapServerPtr;
00066
00067 typedef actionlib::SimpleActionServer<stdr_msgs::SpawnRobotAction>
00068 SpawnRobotServer;
00069
00070 typedef actionlib::SimpleActionServer<stdr_msgs::RegisterRobotAction>
00071 RegisterRobotServer;
00072
00073 typedef actionlib::SimpleActionServer<stdr_msgs::DeleteRobotAction>
00074 DeleteRobotServer;
00075
00076 typedef std::map<std::string, stdr_msgs::RobotIndexedMsg> RobotMap;
00077
00078 typedef std::map<std::string, stdr_msgs::RfidTag> RfidTagMap;
00079 typedef std::map<std::string, stdr_msgs::RfidTag>::iterator RfidTagMapIt;
00080
00081 typedef std::map<std::string, stdr_msgs::CO2Source> CO2SourceMap;
00082 typedef std::map<std::string, stdr_msgs::CO2Source>::iterator CO2SourceMapIt;
00083
00084 typedef std::map<std::string, stdr_msgs::ThermalSource> ThermalSourceMap;
00085 typedef std::map<std::string, stdr_msgs::ThermalSource>::iterator
00086 ThermalSourceMapIt;
00087
00088 typedef std::map<std::string, stdr_msgs::SoundSource> SoundSourceMap;
00089 typedef std::map<std::string, stdr_msgs::SoundSource>::iterator
00090 SoundSourceMapIt;
00091
00096 class Server
00097 {
00098
00099 public:
00100
00107 Server(int argc, char** argv);
00108
00110
00117 bool loadMapCallback(stdr_msgs::LoadMap::Request& req,
00118 stdr_msgs::LoadMap::Response& res);
00119
00126 bool loadExternalMapCallback(stdr_msgs::LoadExternalMap::Request& req,
00127 stdr_msgs::LoadExternalMap::Response& res);
00128
00130
00136 void spawnRobotCallback(const stdr_msgs::SpawnRobotGoalConstPtr& goal);
00137
00143 void deleteRobotCallback(
00144 const stdr_msgs::DeleteRobotGoalConstPtr& goal);
00145
00151 void registerRobotCallback(
00152 const stdr_msgs::RegisterRobotGoalConstPtr& goal);
00153
00154 private:
00155
00160 void activateActionServers(void);
00161
00168 bool addNewRobot(stdr_msgs::RobotMsg description,
00169 stdr_msgs::SpawnRobotResult* result);
00170
00177 bool deleteRobot(std::string name, stdr_msgs::DeleteRobotResult* result);
00178
00185 bool addRfidTagCallback(
00186 stdr_msgs::AddRfidTag::Request &req,
00187 stdr_msgs::AddRfidTag::Response &res);
00188
00195 bool deleteRfidTagCallback(
00196 stdr_msgs::DeleteRfidTag::Request &req,
00197 stdr_msgs::DeleteRfidTag::Response &res);
00198
00205 bool addCO2SourceCallback(
00206 stdr_msgs::AddCO2Source::Request &req,
00207 stdr_msgs::AddCO2Source::Response &res);
00208
00215 bool deleteCO2SourceCallback(
00216 stdr_msgs::DeleteCO2Source::Request &req,
00217 stdr_msgs::DeleteCO2Source::Response &res);
00218
00225 bool addThermalSourceCallback(
00226 stdr_msgs::AddThermalSource::Request &req,
00227 stdr_msgs::AddThermalSource::Response &res);
00228
00235 bool deleteThermalSourceCallback(
00236 stdr_msgs::DeleteThermalSource::Request &req,
00237 stdr_msgs::DeleteThermalSource::Response &res);
00238
00245 bool addSoundSourceCallback(
00246 stdr_msgs::AddSoundSource::Request &req,
00247 stdr_msgs::AddSoundSource::Response &res);
00248
00255 bool deleteSoundSourceCallback(
00256 stdr_msgs::DeleteSoundSource::Request &req,
00257 stdr_msgs::DeleteSoundSource::Response &res);
00258
00259 bool hasDublicateFrameIds(const stdr_msgs::RobotMsg& robot,
00260 std::string &f_id);
00261
00262 private:
00263
00265 ros::NodeHandle _nh;
00267 MapServerPtr _mapServer;
00268
00270 ros::Publisher _robotsPublisher;
00271
00273 ros::ServiceClient _spawnRobotClient;
00275 ros::ServiceClient _unloadRobotClient;
00277 ros::ServiceServer _loadMapService;
00279 ros::ServiceServer _loadExternalMapService;
00281 ros::ServiceServer _moveRobotService;
00282
00284 RegisterRobotServer _registerRobotServer;
00286 SpawnRobotServer _spawnRobotServer;
00288 DeleteRobotServer _deleteRobotServer;
00289
00291 RobotMap _robotMap;
00293 int _id;
00294
00296 RfidTagMap _rfidTagMap;
00298 CO2SourceMap _CO2SourceMap;
00300 ThermalSourceMap _thermalSourceMap;
00302 SoundSourceMap _soundSourceMap;
00303
00305 boost::mutex _mut;
00307 boost::condition_variable cond;
00308
00310 ros::ServiceServer _addRfidTagServiceServer;
00312 ros::ServiceServer _deleteRfidTagServiceServer;
00314 ros::Publisher _rfidTagVectorPublisher;
00315
00317 ros::ServiceServer _addCO2SourceServiceServer;
00319 ros::ServiceServer _deleteCO2SourceServiceServer;
00321 ros::Publisher _CO2SourceVectorPublisher;
00322
00324 ros::ServiceServer _addThermalSourceServiceServer;
00326 ros::ServiceServer _deleteThermalSourceServiceServer;
00328 ros::Publisher _thermalSourceVectorPublisher;
00329
00331 ros::ServiceServer _addSoundSourceServiceServer;
00333 ros::ServiceServer _deleteSoundSourceServiceServer;
00335 ros::Publisher _soundSourceVectorPublisher;
00336 };
00337 }
00338
00339
00340 #endif