stdr_server.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  STDR Simulator - Simple Two DImensional Robot Simulator
3  Copyright (C) 2013 STDR Simulator
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 
16  Authors :
17  * Manos Tsardoulias, etsardou@gmail.com
18  * Aris Thallas, aris.thallas@gmail.com
19  * Chris Zalidis, zalidis@gmail.com
20 ******************************************************************************/
21 
23 
24 namespace stdr_server {
25 
30  Server::Server(int argc, char** argv)
31  :_spawnRobotServer(_nh, "stdr_server/spawn_robot",
32  boost::bind(&Server::spawnRobotCallback, this, _1), false)
33 
34  ,_registerRobotServer(_nh, "stdr_server/register_robot",
35  boost::bind(&Server::registerRobotCallback, this, _1), false)
36 
37  ,_deleteRobotServer(_nh, "stdr_server/delete_robot",
38  boost::bind(&Server::deleteRobotCallback, this, _1), false)
39 
40  ,_id(0)
41  {
42  //~ _spawnRobotServer.registerGoalCallback(
43  //~ boost::bind(&Server::spawnRobotCallback, this) );
44 
45  if (argc > 2) {
46  ROS_ERROR("%s", USAGE);
47  exit(-1);
48  }
49 
50  if (argc == 2) {
51  std::string fname(argv[1]);
52  _mapServer.reset(new MapServer(fname));
53 
56  }
57 
59  "/stdr_server/load_static_map", &Server::loadMapCallback, this);
60 
62  "/stdr_server/load_static_map_external",
64 
65  while (!ros::service::waitForService("robot_manager/load_nodelet",
66  ros::Duration(.1)) && ros::ok())
67  {
68  ROS_WARN("Trying to register to robot_manager/load_nodelet...");
69  }
70 
71  _spawnRobotClient = _nh.serviceClient<nodelet::NodeletLoad>
72  ("robot_manager/load_nodelet", true);
73 
74  while (!ros::service::waitForService("robot_manager/unload_nodelet",
75  ros::Duration(.1)) && ros::ok())
76  {
77  ROS_WARN("Trying to register to robot_manager/unload_nodelet...");
78  }
79 
81  _nh.serviceClient<nodelet::NodeletUnload>("robot_manager/unload_nodelet");
82 
84  _nh.advertise<stdr_msgs::RobotIndexedVectorMsg>
85  ("stdr_server/active_robots", 10, true);
86 
88  _sourceVectorPublisherRviz = _nh.advertise<visualization_msgs::MarkerArray>(
89  "stdr_server/sources_visualization_markers", 1, true);
90 
92 
93  _addRfidTagServiceServer = _nh.advertiseService("stdr_server/add_rfid_tag",
95 
97  _nh.advertiseService("stdr_server/delete_rfid_tag",
99 
100  _rfidTagVectorPublisher = _nh.advertise<stdr_msgs::RfidTagVector>(
101  "stdr_server/rfid_list", 1, true);
102 
104 
106  "stdr_server/add_co2_source",
108 
110  _nh.advertiseService("stdr_server/delete_co2_source",
112 
113  _CO2SourceVectorPublisher = _nh.advertise<stdr_msgs::CO2SourceVector>(
114  "stdr_server/co2_sources_list", 1, true);
115 
117 
119  "stdr_server/add_thermal_source",
121 
123  _nh.advertiseService("stdr_server/delete_thermal_source",
125 
127  _nh.advertise<stdr_msgs::ThermalSourceVector>(
128  "stdr_server/thermal_sources_list", 1, true);
129 
131 
133  "stdr_server/add_sound_source",
135 
137  _nh.advertiseService("stdr_server/delete_sound_source",
139 
140  _soundSourceVectorPublisher = _nh.advertise<stdr_msgs::SoundSourceVector>(
141  "stdr_server/sound_sources_list", 1, true);
142  }
143 
148  stdr_msgs::AddRfidTag::Request &req,
149  stdr_msgs::AddRfidTag::Response &res)
150  {
152  stdr_msgs::RfidTag new_rfid = req.newTag;
153  if(_rfidTagMap.find(new_rfid.tag_id) != _rfidTagMap.end())
154  {
155  res.success = false;
156  res.message = "Duplicate rfid_id";
157  return false;
158  }
159 
161  _rfidTagMap.insert(std::pair<std::string, stdr_msgs::RfidTag>(
162  new_rfid.tag_id, new_rfid));
163 
165  stdr_msgs::RfidTagVector rfidTagList;
166  visualization_msgs::MarkerArray RFIDMarkerArray;
167 
168  for(RfidTagMapIt it = _rfidTagMap.begin() ; it != _rfidTagMap.end() ; it++)
169  {
170  rfidTagList.rfid_tags.push_back(it->second);
171  RFIDMarkerArray.markers.push_back(toMarker(it->second, true));
172  }
173  _rfidTagVectorPublisher.publish(rfidTagList);
174 
175  _sourceVectorPublisherRviz.publish(RFIDMarkerArray);
176 
179 
181  res.success = true;
182  return true;
183  }
184 
189  stdr_msgs::AddCO2Source::Request &req,
190  stdr_msgs::AddCO2Source::Response &res)
191  {
193  stdr_msgs::CO2Source new_source = req.newSource;
194  if(_CO2SourceMap.find(new_source.id) != _CO2SourceMap.end())
195  {
196  res.success = false;
197  res.message = "Duplicate CO2 id";
198  return false;
199  }
200 
202  _CO2SourceMap.insert(std::pair<std::string, stdr_msgs::CO2Source>(
203  new_source.id, new_source));
204 
206  stdr_msgs::CO2SourceVector CO2SourceList;
207  visualization_msgs::MarkerArray C02MarkerArray;
208 
209  for(CO2SourceMapIt it = _CO2SourceMap.begin()
210  ; it != _CO2SourceMap.end() ; it++)
211  {
212  CO2SourceList.co2_sources.push_back(it->second);
213  C02MarkerArray.markers.push_back(toMarker(it->second, true));
214  }
215  _CO2SourceVectorPublisher.publish(CO2SourceList);
216  _sourceVectorPublisherRviz.publish(C02MarkerArray);
217 
218 
221 
223  res.success = true;
224  return true;
225  }
226 
231  stdr_msgs::AddThermalSource::Request &req,
232  stdr_msgs::AddThermalSource::Response &res)
233  {
235  stdr_msgs::ThermalSource new_source = req.newSource;
236  if(_thermalSourceMap.find(new_source.id) != _thermalSourceMap.end())
237  {
238  res.success = false;
239  res.message = "Duplicate thermal source is";
240  return false;
241  }
242 
244  _thermalSourceMap.insert(std::pair<std::string, stdr_msgs::ThermalSource>(
245  new_source.id, new_source));
246 
248  stdr_msgs::ThermalSourceVector thermalSourceList;
249  visualization_msgs::MarkerArray thermalMarkerArray;
250 
251  for(ThermalSourceMapIt it = _thermalSourceMap.begin()
252  ; it != _thermalSourceMap.end() ; it++)
253  {
254  thermalSourceList.thermal_sources.push_back(it->second);
255  thermalMarkerArray.markers.push_back(toMarker(it->second, true));
256  }
257  _thermalSourceVectorPublisher.publish(thermalSourceList);
258  _sourceVectorPublisherRviz.publish(thermalMarkerArray);
259 
260 
263 
265  res.success = true;
266  return true;
267  }
268 
273  stdr_msgs::AddSoundSource::Request &req,
274  stdr_msgs::AddSoundSource::Response &res)
275  {
277  stdr_msgs::SoundSource new_source = req.newSource;
278  if(_soundSourceMap.find(new_source.id) != _soundSourceMap.end())
279  {
280  res.success = false;
281  res.message = "Duplicate sound source is";
282  return false;
283  }
284 
286  _soundSourceMap.insert(std::pair<std::string, stdr_msgs::SoundSource>(
287  new_source.id, new_source));
288 
290  stdr_msgs::SoundSourceVector soundSourceList;
291  visualization_msgs::MarkerArray soundMarkerArray;
292 
293  for(SoundSourceMapIt it = _soundSourceMap.begin()
294  ; it != _soundSourceMap.end() ; it++)
295  {
296  soundSourceList.sound_sources.push_back(it->second);
297  soundMarkerArray.markers.push_back(toMarker(it->second, true));
298  }
299  _soundSourceVectorPublisher.publish(soundSourceList);
300  _sourceVectorPublisherRviz.publish(soundMarkerArray);
301 
302 
305 
307  res.success = true;
308  return true;
309  }
310 
315  stdr_msgs::DeleteRfidTag::Request &req,
316  stdr_msgs::DeleteRfidTag::Response &res)
317  {
318 
319  std::string name = req.name;
320  if(_rfidTagMap.find(name) != _rfidTagMap.end())
321  {
322  // Publish deletion to RVIZ
323  visualization_msgs::MarkerArray rfidMarkerArray;
324  rfidMarkerArray.markers.push_back(toMarker(_rfidTagMap[name], false));
325  _sourceVectorPublisherRviz.publish(rfidMarkerArray);
326 
327  _rfidTagMap.erase(name);
328 
330  stdr_msgs::RfidTagVector rfidTagList;
331 
332  for(RfidTagMapIt it = _rfidTagMap.begin() ;
333  it != _rfidTagMap.end() ; it++)
334  {
335  rfidTagList.rfid_tags.push_back(it->second);
336  }
337  _rfidTagVectorPublisher.publish(rfidTagList);
340  }
341  else
342  {
343  return false;
344  }
345  return true;
346  }
347 
352  stdr_msgs::DeleteCO2Source::Request &req,
353  stdr_msgs::DeleteCO2Source::Response &res)
354  {
355  std::string name = req.name;
356  if(_CO2SourceMap.find(name) != _CO2SourceMap.end())
357  {
358  // Publish deletion to RVIZ
359  visualization_msgs::MarkerArray CO2MarkerArray;
360  CO2MarkerArray.markers.push_back(toMarker(_CO2SourceMap[name], false));
361  _sourceVectorPublisherRviz.publish(CO2MarkerArray);
362 
363  _CO2SourceMap.erase(name);
364 
366  stdr_msgs::CO2SourceVector CO2SourceList;
367 
368  for(CO2SourceMapIt it = _CO2SourceMap.begin() ;
369  it != _CO2SourceMap.end() ; it++)
370  {
371  CO2SourceList.co2_sources.push_back(it->second);
372  }
373  _CO2SourceVectorPublisher.publish(CO2SourceList);
376  }
377 
378  else
379  {
380  return false;
381  }
382  return true;
383  }
384 
389  stdr_msgs::DeleteThermalSource::Request &req,
390  stdr_msgs::DeleteThermalSource::Response &res)
391  {
392 
393  std::string name = req.name;
394  if(_thermalSourceMap.find(name) != _thermalSourceMap.end())
395  {
396  // Publish deletion to RVIZ
397  visualization_msgs::MarkerArray thermalMarkerArray;
398  thermalMarkerArray.markers.push_back(toMarker(_thermalSourceMap[name], false));
399  _sourceVectorPublisherRviz.publish(thermalMarkerArray);
400 
401  _thermalSourceMap.erase(name);
402 
404  stdr_msgs::ThermalSourceVector thermalSourceList;
405 
406  for(ThermalSourceMapIt it = _thermalSourceMap.begin() ;
407  it != _thermalSourceMap.end() ; it++)
408  {
409  thermalSourceList.thermal_sources.push_back(it->second);
410  }
411  _thermalSourceVectorPublisher.publish(thermalSourceList);
414  }
415  else
416  {
417  return false;
418  }
419  return true;
420  }
421 
426  stdr_msgs::DeleteSoundSource::Request &req,
427  stdr_msgs::DeleteSoundSource::Response &res)
428  {
429 
430  std::string name = req.name;
431  if(_soundSourceMap.find(name) != _soundSourceMap.end())
432  {
433  // Publish deletion to RVIZ
434  visualization_msgs::MarkerArray soundMarkerArray;
435  soundMarkerArray.markers.push_back(toMarker(_soundSourceMap[name], false));
436  _sourceVectorPublisherRviz.publish(soundMarkerArray);
437 
438  _soundSourceMap.erase(name);
439 
441  stdr_msgs::SoundSourceVector soundSourceList;
442 
443 
444  for(SoundSourceMapIt it = _soundSourceMap.begin() ;
445  it != _soundSourceMap.end() ; it++)
446  {
447  soundSourceList.sound_sources.push_back(it->second);
448 
449  }
450  _soundSourceVectorPublisher.publish(soundSourceList);
453  }
454  else
455  {
456  return false;
457  }
458  return true;
459  }
460 
468  stdr_msgs::LoadMap::Request& req,
469  stdr_msgs::LoadMap::Response& res)
470  {
471  if (_mapServer) {
472  ROS_WARN("Map already loaded!");
473  return false;
474  }
475  _mapServer.reset(new MapServer(req.mapFile));
478 
479  return true;
480  }
481 
489  stdr_msgs::LoadExternalMap::Request& req,
490  stdr_msgs::LoadExternalMap::Response& res)
491  {
492  if (_mapServer) {
493  ROS_WARN("Map already loaded!");
494  return false;
495  }
496  _mapServer.reset(new MapServer(req.map));
497 
500 
501  return true;
502  }
503 
510  const stdr_msgs::SpawnRobotGoalConstPtr& goal)
511  {
512  stdr_msgs::SpawnRobotResult result;
513 
514  std::string f_id;
515  if(hasDublicateFrameIds(goal->description, f_id))
516  {
517  result.message = std::string("Double frame_id:") + f_id;
519  return;
520  }
521 
522  if (addNewRobot(goal->description, &result)) {
524 
526  stdr_msgs::RobotIndexedVectorMsg msg;
527  for (RobotMap::iterator it = _robotMap.begin();
528  it != _robotMap.end(); ++it)
529  {
530  msg.robots.push_back( it->second );
531  }
532 
534  return;
535  }
536 
538  }
539 
546  const stdr_msgs::DeleteRobotGoalConstPtr& goal)
547  {
548 
549  stdr_msgs::DeleteRobotResult result;
550 
551  if (deleteRobot(goal->name, &result)) {
552 
553  // publish to active_robots topic
554  stdr_msgs::RobotIndexedVectorMsg msg;
555  for (RobotMap::iterator it = _robotMap.begin();
556  it != _robotMap.end(); ++it)
557  {
558  msg.robots.push_back( it->second );
559  }
562  return;
563  }
564 
566  }
567 
574  const stdr_msgs::RegisterRobotGoalConstPtr& goal)
575  {
576 
577  boost::unique_lock<boost::mutex> lock(_mut);
578  stdr_msgs::RegisterRobotResult result;
579 
580  // look for the robot name in _robotMap
581  RobotMap::iterator search = _robotMap.find(goal->name);
582 
583  if (search != _robotMap.end())
584  {
585  result.description = _robotMap[goal->name].robot;
587 
589  _cond.notify_one();
590  }
591  else
592  {
594  }
595  }
596 
602  {
606  }
607 
615  stdr_msgs::RobotMsg description,
616  stdr_msgs::SpawnRobotResult* result)
617  {
618 
619  stdr_msgs::RobotIndexedMsg namedRobot;
620 
621  if(description.kinematicModel.type == "")
622  description.kinematicModel.type = "ideal";
623 
624  namedRobot.robot = description;
625 
626  namedRobot.name = "robot" + boost::lexical_cast<std::string>(_id++);
627 
628  _robotMap.insert( std::make_pair(namedRobot.name, namedRobot) );
629 
630  nodelet::NodeletLoad srv;
631  srv.request.name = namedRobot.name;
632  srv.request.type = "stdr_robot/Robot";
633 
634  boost::unique_lock<boost::mutex> lock(_mut);
635 
636  if (_spawnRobotClient.call(srv)) {
638  if( _cond.timed_wait(lock, ros::Duration(5.0).toBoost()) )
639  {
640  result->indexedDescription = namedRobot;
641 
642  lock.unlock();
643  return true;
644  }
645  }
646 
647  result->message =
648  "Robot didn't respond within time or registered with incorrect name.";
649  lock.unlock();
650  return false;
651  }
652 
660  std::string name,
661  stdr_msgs::DeleteRobotResult* result)
662  {
663 
664  RobotMap::iterator it = _robotMap.find(name);
665 
666  if (it != _robotMap.end()) {
667 
668  nodelet::NodeletUnload srv;
669  srv.request.name = name;
670 
671  if (_unloadRobotClient.call(srv)) {
672 
673  if (srv.response.success) {
674  _robotMap.erase(it);
675  }
676 
677  result->success = srv.response.success;
678  return srv.response.success;
679  }
680 
681  result->success = false;
682  return false;
683  }
684 
685  ROS_WARN("Requested to delete robot, with name %s does not exist.",
686  name.c_str());
687 
688  result->success = false;
689  return false;
690  }
691 
692  bool Server::hasDublicateFrameIds(const stdr_msgs::RobotMsg& robot,
693  std::string &f_id)
694  {
695  std::set<std::string> f_ids;
696  for(unsigned int i = 0 ; i < robot.laserSensors.size() ; i++)
697  {
698  if(f_ids.find(robot.laserSensors[i].frame_id) == f_ids.end())
699  {
700  f_ids.insert(robot.laserSensors[i].frame_id);
701  }
702  else
703  {
704  f_id = robot.laserSensors[i].frame_id;
705  return true;
706  }
707  }
708  for(unsigned int i = 0 ; i < robot.sonarSensors.size() ; i++)
709  {
710  if(f_ids.find(robot.sonarSensors[i].frame_id) == f_ids.end())
711  {
712  f_ids.insert(robot.sonarSensors[i].frame_id);
713  }
714  else
715  {
716  f_id = robot.sonarSensors[i].frame_id;
717  return true;
718  }
719  }
720  for(unsigned int i = 0 ; i < robot.rfidSensors.size() ; i++)
721  {
722  if(f_ids.find(robot.rfidSensors[i].frame_id) == f_ids.end())
723  {
724  f_ids.insert(robot.rfidSensors[i].frame_id);
725  }
726  else
727  {
728  f_id = robot.rfidSensors[i].frame_id;
729  return true;
730  }
731  }
732  for(unsigned int i = 0 ; i < robot.co2Sensors.size() ; i++)
733  {
734  if(f_ids.find(robot.co2Sensors[i].frame_id) == f_ids.end())
735  {
736  f_ids.insert(robot.co2Sensors[i].frame_id);
737  }
738  else
739  {
740  f_id = robot.co2Sensors[i].frame_id;
741  return true;
742  }
743  }
744  for(unsigned int i = 0 ; i < robot.soundSensors.size() ; i++)
745  {
746  if(f_ids.find(robot.soundSensors[i].frame_id) == f_ids.end())
747  {
748  f_ids.insert(robot.soundSensors[i].frame_id);
749  }
750  else
751  {
752  f_id = robot.soundSensors[i].frame_id;
753  return true;
754  }
755  }
756  for(unsigned int i = 0 ; i < robot.thermalSensors.size() ; i++)
757  {
758  if(f_ids.find(robot.thermalSensors[i].frame_id) == f_ids.end())
759  {
760  f_ids.insert(robot.thermalSensors[i].frame_id);
761  }
762  else
763  {
764  f_id = robot.thermalSensors[i].frame_id;
765  return true;
766  }
767  }
768  return false;
769  }
770 
774  visualization_msgs::Marker Server::toMarker(const stdr_msgs::CO2Source& msg, bool added)
775  {
776  visualization_msgs::Marker marker = createMarker(msg, added);
777 
778  // Set the namespace and id for this marker. This serves to create a unique ID
779  // Any marker sent with the same namespace and id will overwrite the old one
780  marker.ns = "co2";
781  marker.id = atoi(msg.id.c_str());
782 
783  // Set the color specific to the source type -- be sure to set alpha to something non-zero!
784  marker.color.r = 0.0f;
785  marker.color.g = 1.0f;
786  marker.color.b = 0.0f;
787  marker.color.a = 1.0;
788 
789  return marker;
790  }
791 
795  visualization_msgs::Marker Server::toMarker(const stdr_msgs::ThermalSource& msg, bool added)
796  {
797  visualization_msgs::Marker marker = createMarker(msg, added);
798 
799  // Set the namespace and id for this marker. This serves to create a unique ID
800  // Any marker sent with the same namespace and id will overwrite the old one
801  marker.ns = "thermal";
802  marker.id = atoi(msg.id.c_str());
803 
804  // Set the color specific to the source type -- be sure to set alpha to something non-zero!
805  marker.color.r = 1.0f;
806  marker.color.g = 0.0f;
807  marker.color.b = 0.0f;
808  marker.color.a = 1.0;
809 
810  return marker;
811  }
812 
816  visualization_msgs::Marker Server::toMarker(const stdr_msgs::SoundSource& msg, bool added)
817  {
818  visualization_msgs::Marker marker = createMarker(msg, added);
819 
820  // Set the namespace and id for this marker. This serves to create a unique ID
821  // Any marker sent with the same namespace and id will overwrite the old one
822  marker.ns = "sound";
823  marker.id = atoi(msg.id.c_str());
824 
825  // Set the color specific to the source type -- be sure to set alpha to something non-zero!
826  marker.color.r = 0.0f;
827  marker.color.g = 0.0f;
828  marker.color.b = 1.0f;
829  marker.color.a = 1.0;
830 
831  return marker;
832  }
833 
837  visualization_msgs::Marker Server::toMarker(const stdr_msgs::RfidTag& msg, bool added)
838  {
839  visualization_msgs::Marker marker = createMarker(msg, added);
840 
841  // Set the namespace and id for this marker. This serves to create a unique ID
842  // Any marker sent with the same namespace and id will overwrite the old one
843  marker.ns = "rfid";
844  marker.id = atoi(msg.tag_id.c_str());
845 
846  // Set the color specific to the source type -- be sure to set alpha to something non-zero!
847  marker.color.r = 0.0f;
848  marker.color.g = 0.0f;
849  marker.color.b = 0.0f;
850  marker.color.a = 1.0;
851 
852  return marker;
853  }
854 
856  {
857  visualization_msgs::MarkerArray ma;
858  for(SoundSourceMapIt it = _soundSourceMap.begin()
859  ; it != _soundSourceMap.end() ; it++)
860  {
861  ma.markers.push_back(toMarker(it->second, true));
862  }
863  for(CO2SourceMapIt it = _CO2SourceMap.begin()
864  ; it != _CO2SourceMap.end() ; it++)
865  {
866  ma.markers.push_back(toMarker(it->second, true));
867  }
868  for(ThermalSourceMapIt it = _thermalSourceMap.begin()
869  ; it != _thermalSourceMap.end() ; it++)
870  {
871  ma.markers.push_back(toMarker(it->second, true));
872  }
873  for(RfidTagMapIt it = _rfidTagMap.begin() ; it != _rfidTagMap.end() ; it++)
874  {
875  ma.markers.push_back(toMarker(it->second, true));
876  }
878  }
879 
884  template <class SourceMsg>
885  visualization_msgs::Marker Server::createMarker(const SourceMsg& msg, bool added)
886  {
887  visualization_msgs::Marker marker;
888 
889  marker.header.frame_id = "/map_static";
890  marker.header.stamp = ros::Time();
891 
892  uint32_t shape = visualization_msgs::Marker::SPHERE;
893  marker.type = shape;
894 
895  // Set the marker action.
896  if(added) {
897  marker.action = visualization_msgs::Marker::ADD;
898  }
899  else {
900  marker.action = visualization_msgs::Marker::DELETE;
901  }
902 
903  marker.pose.position.x = msg.pose.x;
904  marker.pose.position.y = msg.pose.y;
905  marker.pose.position.z = 0;
906  marker.pose.orientation.x = 0.0;
907  marker.pose.orientation.y = 0.0;
908  marker.pose.orientation.z = 0.0;
909  marker.pose.orientation.w = 1.0;
910 
911  marker.scale.x = 0.5;
912  marker.scale.y = 0.5;
913  marker.scale.z = 0.5;
914 
915  marker.lifetime = ros::Duration();
916  return marker;
917  }
918 
919 } // end of namespace stdr_robot
bool deleteThermalSourceCallback(stdr_msgs::DeleteThermalSource::Request &req, stdr_msgs::DeleteThermalSource::Response &res)
Service callback for deleting a thermal source from the environment.
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void registerRobotCallback(const stdr_msgs::RegisterRobotGoalConstPtr &goal)
Action callback for robot registering.
bool hasDublicateFrameIds(const stdr_msgs::RobotMsg &robot, std::string &f_id)
Implements the STDR map server functionalities.
Definition: map_server.h:39
MapServerPtr _mapServer
ROS publisher for the ensemble of robots.
Definition: stdr_server.h:316
ros::Publisher _CO2SourceVectorPublisher
The addThermalSource srv server.
Definition: stdr_server.h:375
bool addNewRobot(stdr_msgs::RobotMsg description, stdr_msgs::SpawnRobotResult *result)
Adds new robot to simulator.
ros::ServiceServer _addSoundSourceServiceServer
The deleteSoundSource srv server.
Definition: stdr_server.h:385
void publish(const boost::shared_ptr< M > &message) const
void spawnRobotCallback(const stdr_msgs::SpawnRobotGoalConstPtr &goal)
Action callback for robot spawning.
bool deleteSoundSourceCallback(stdr_msgs::DeleteSoundSource::Request &req, stdr_msgs::DeleteSoundSource::Response &res)
Service callback for deleting a sound source from the environment.
ros::ServiceServer _deleteCO2SourceServiceServer
The CO2 source list publisher towards the GUI.
Definition: stdr_server.h:373
SpawnRobotServer _spawnRobotServer
Action server for deleting robots.
Definition: stdr_server.h:335
bool addSoundSourceCallback(stdr_msgs::AddSoundSource::Request &req, stdr_msgs::AddSoundSource::Response &res)
Service callback for adding new sound source to the environment.
bool loadExternalMapCallback(stdr_msgs::LoadExternalMap::Request &req, stdr_msgs::LoadExternalMap::Response &res)
Service callback for loading the map from GUI.
ros::Publisher _rfidTagVectorPublisher
The addCO2Source srv server.
Definition: stdr_server.h:367
The main namespace for STDR Server.
bool call(MReq &req, MRes &res)
bool deleteRfidTagCallback(stdr_msgs::DeleteRfidTag::Request &req, stdr_msgs::DeleteRfidTag::Response &res)
Service callback for deleting an rfid tag from the environment.
bool addCO2SourceCallback(stdr_msgs::AddCO2Source::Request &req, stdr_msgs::AddCO2Source::Response &res)
Service callback for adding new CO2 source to the environment.
ros::NodeHandle _nh
A pointer to a MapServe object.
Definition: stdr_server.h:314
RegisterRobotServer _registerRobotServer
Action server for spawning robots.
Definition: stdr_server.h:333
ros::ServiceClient _spawnRobotClient
Action client for robot unloading.
Definition: stdr_server.h:322
RfidTagMap _rfidTagMap
An std::map that contains the CO2 sources existent in the environment.
Definition: stdr_server.h:345
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool deleteRobot(std::string name, stdr_msgs::DeleteRobotResult *result)
Deletes a robot from simulator.
ros::ServiceServer _deleteRfidTagServiceServer
The rfid tag list publisher.
Definition: stdr_server.h:365
CO2SourceMap _CO2SourceMap
An std::map that contains the thermal sources existent in the environment.
Definition: stdr_server.h:347
#define ROS_WARN(...)
ros::ServiceServer _deleteSoundSourceServiceServer
The sound source list publisher.
Definition: stdr_server.h:387
std::map< std::string, stdr_msgs::CO2Source >::iterator CO2SourceMapIt
Definition: stdr_server.h:85
ros::ServiceServer _loadMapService
Service server for loading maps from GUI.
Definition: stdr_server.h:326
RobotMap _robotMap
Index that shows the next robot id.
Definition: stdr_server.h:340
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
ros::Publisher _thermalSourceVectorPublisher
The addSoundSource srv server.
Definition: stdr_server.h:382
std::map< std::string, stdr_msgs::ThermalSource >::iterator ThermalSourceMapIt
Definition: stdr_server.h:89
ros::ServiceServer _addThermalSourceServiceServer
The deleteThermalSource srv server.
Definition: stdr_server.h:378
visualization_msgs::Marker createMarker(const SourceMsg &msg, bool added)
Creates a marker message corresponding to every element of msg that is independent of the source&#39;s sp...
SoundSourceMap _soundSourceMap
Boost mutex for conflict avoidance.
Definition: stdr_server.h:351
bool addThermalSourceCallback(stdr_msgs::AddThermalSource::Request &req, stdr_msgs::AddThermalSource::Response &res)
Service callback for adding new thermal source to the environment.
ros::ServiceServer _addCO2SourceServiceServer
The deleteCO2Source srv server.
Definition: stdr_server.h:371
ros::ServiceServer _loadExternalMapService
Service server for moving robots.
Definition: stdr_server.h:328
ThermalSourceMap _thermalSourceMap
An std::map that contains the sound sources existent in the environment.
Definition: stdr_server.h:349
std::map< std::string, stdr_msgs::RfidTag >::iterator RfidTagMapIt
Definition: stdr_server.h:82
ros::ServiceServer _addRfidTagServiceServer
The deleteRfidTag srv server.
Definition: stdr_server.h:363
ros::ServiceClient _unloadRobotClient
Service server for loading maps from files.
Definition: stdr_server.h:324
#define USAGE
Definition: stdr_server.h:25
int _id
An std::map that contains the rfid tags existent in the environment.
Definition: stdr_server.h:342
bool loadMapCallback(stdr_msgs::LoadMap::Request &req, stdr_msgs::LoadMap::Response &res)
Service callback for loading the map.
ROSCPP_DECL bool ok()
ros::ServiceServer _deleteThermalSourceServiceServer
The thermal source list publisher.
Definition: stdr_server.h:380
void republishSources()
Republishes existing sources to RVIZ after a successful deletion.
visualization_msgs::Marker toMarker(const stdr_msgs::CO2Source &msg, bool added)
Translate the stdr_C02Source message into a marker message.
void deleteRobotCallback(const stdr_msgs::DeleteRobotGoalConstPtr &goal)
Action callback for robot deletion.
bool addRfidTagCallback(stdr_msgs::AddRfidTag::Request &req, stdr_msgs::AddRfidTag::Response &res)
Service callback for adding new rfid tag to the environment.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
Implements the STDR server functionalities.
Definition: stdr_server.h:99
ros::Publisher _soundSourceVectorPublisher
Definition: stdr_server.h:389
std::map< std::string, stdr_msgs::SoundSource >::iterator SoundSourceMapIt
Definition: stdr_server.h:93
bool deleteCO2SourceCallback(stdr_msgs::DeleteCO2Source::Request &req, stdr_msgs::DeleteCO2Source::Response &res)
Service callback for deleting a CO2 source from the environment.
ros::Publisher _sourceVectorPublisherRviz
The addRfidTag srv server.
Definition: stdr_server.h:360
boost::mutex _mut
Boost condition variable for conflicting avoidance.
Definition: stdr_server.h:354
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
boost::condition_variable _cond
A general Rviz publisher for all source types.
Definition: stdr_server.h:356
void activateActionServers(void)
Initializes the spawn,delete,register action servers.
ros::Publisher _robotsPublisher
Action client for robot spawning.
Definition: stdr_server.h:319
void notify_one() BOOST_NOEXCEPT
ROSCPP_DECL bool search(const std::string &ns, const std::string &key, std::string &result)
DeleteRobotServer _deleteRobotServer
An std::map that contains the robots based on theor frame_id.
Definition: stdr_server.h:337
#define ROS_ERROR(...)
ROSCPP_DECL bool waitForService(const std::string &service_name, int32_t timeout)
Server(int argc, char **argv)
Default constructor.
Definition: stdr_server.cpp:30


stdr_server
Author(s): Chris Zalidis
autogenerated on Mon Jun 10 2019 15:15:07