stdr_gui_controller.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 
25 namespace stdr_gui
26 {
31  void spinThreadFunction(void)
32  {
33  ros::spin();
34  }
35 
42  CGuiController::CGuiController(int argc,char **argv):
43  gui_connector_(argc,argv),
44  info_connector_(argc,argv),
45  map_connector_(argc,argv),
46  argc_(argc),
47  argv_(argv)
48  {
49  setupWidgets();
50 
51  robot_following_ = "";
52 
53  map_lock_ = false;
54  map_initialized_ = false;
55 
56  icon_move_.addFile(QString::fromUtf8((
58  std::string("/resources/images/arrow_move.png")).c_str()),
59  QSize(20,20), QIcon::Normal, QIcon::Off);
60 
61  icon_delete_.addFile(QString::fromUtf8((
63  std::string("/resources/images/remove_icon.png")).c_str()),
64  QSize(20,20), QIcon::Normal, QIcon::Off);
65  }
66 
72  {
73 
74  }
75 
81  {
82 
84  "map",
85  1,
87  this);
88 
91  "stdr_server/rfid_list",
92  1,
94  this);
96  n_.serviceClient<stdr_msgs::AddRfidTag>("stdr_server/add_rfid_tag");
98  n_.serviceClient<stdr_msgs::DeleteRfidTag>("stdr_server/delete_rfid_tag");
99 
102  "stdr_server/co2_sources_list",
103  1,
105  this);
107  n_.serviceClient<stdr_msgs::AddCO2Source>("stdr_server/add_co2_source");
109  n_.serviceClient<stdr_msgs::DeleteCO2Source>(
110  "stdr_server/delete_co2_source");
111 
114  "stdr_server/thermal_sources_list",
115  1,
117  this);
119  n_.serviceClient<stdr_msgs::AddThermalSource>(
120  "stdr_server/add_thermal_source");
122  n_.serviceClient<stdr_msgs::DeleteThermalSource>(
123  "stdr_server/delete_thermal_source");
124 
127  "stdr_server/sound_sources_list",
128  1,
130  this);
132  n_.serviceClient<stdr_msgs::AddSoundSource>(
133  "stdr_server/add_sound_source");
135  n_.serviceClient<stdr_msgs::DeleteSoundSource>(
136  "stdr_server/delete_sound_source");
137 
138  QObject::connect(
139  &gui_connector_,SIGNAL(setZoomInCursor(bool)),
140  &map_connector_, SLOT(setCursorZoomIn(bool)));
141 
142  QObject::connect(
143  &gui_connector_,SIGNAL(setZoomOutCursor(bool)),
144  &map_connector_, SLOT(setCursorZoomOut(bool)));
145 
146  QObject::connect(
147  &gui_connector_,SIGNAL(setAdjustedCursor(bool)),
148  &map_connector_, SLOT(setCursorAdjusted(bool)));
149 
150  QObject::connect(
151  &map_connector_,SIGNAL(zoomInPressed(QPoint)),
152  this, SLOT(zoomInPressed(QPoint)));
153 
154  QObject::connect(
155  &map_connector_,SIGNAL(zoomOutPressed(QPoint)),
156  this, SLOT(zoomOutPressed(QPoint)));
157 
158  QObject::connect(
159  &map_connector_,SIGNAL(itemClicked(QPoint,Qt::MouseButton)),
160  this, SLOT(itemClicked(QPoint,Qt::MouseButton)));
161 
162  QObject::connect(
163  &info_connector_,SIGNAL(laserVisualizerClicked(QString,QString)),
164  this, SLOT(laserVisualizerClicked(QString,QString)));
165 
166  QObject::connect(
167  &info_connector_,SIGNAL(sonarVisualizerClicked(QString,QString)),
168  this, SLOT(sonarVisualizerClicked(QString,QString)));
169 
170  QObject::connect(
171  &info_connector_,SIGNAL(robotVisualizerClicked(QString)),
172  this, SLOT(robotVisualizerClicked(QString)));
173 
174  QObject::connect(
176  SIGNAL(saveRobotPressed(stdr_msgs::RobotMsg,QString)),
177  this, SLOT(saveRobotPressed(stdr_msgs::RobotMsg,QString)));
178 
179  QObject::connect(
181  SIGNAL(loadRobotPressed(stdr_msgs::RobotMsg)),
182  this, SLOT(loadRobotPressed(stdr_msgs::RobotMsg)));
183 
184  QObject::connect(
185  &(gui_connector_),
186  SIGNAL(robotFromFile(stdr_msgs::RobotMsg)),
187  this, SLOT(loadRobotFromFilePressed(stdr_msgs::RobotMsg)));
188 
189  QObject::connect(
190  &(gui_connector_),
191  SIGNAL(loadRfidPressed()),
192  this, SLOT(loadRfidPressed()));
193 
194  QObject::connect(
195  &(gui_connector_),
196  SIGNAL(loadThermalPressed()),
197  this, SLOT(loadThermalPressed()));
198 
199  QObject::connect(
200  &(gui_connector_),
201  SIGNAL(loadCo2Pressed()),
202  this, SLOT(loadCo2Pressed()));
203 
204  QObject::connect(
205  &(gui_connector_),
206  SIGNAL(loadSoundPressed()),
207  this, SLOT(loadSoundPressed()));
208 
209  QObject::connect(
210  this,SIGNAL(waitForRobotPose()),
211  &map_connector_, SLOT(waitForPlace()));
212 
213  QObject::connect(
214  &map_connector_,SIGNAL(robotPlaceSet(QPoint)),
215  this, SLOT(robotPlaceSet(QPoint)));
216 
217  QObject::connect(
218  this,SIGNAL(replaceRobot(std::string)),
219  &map_connector_, SLOT(waitForReplace(std::string)));
220 
221  QObject::connect(
222  &map_connector_,SIGNAL(robotReplaceSet(QPoint,std::string)),
223  this, SLOT(robotReplaceSet(QPoint,std::string)));
224 
225  timer_ = new QTimer(this);
226  connect(
227  timer_, SIGNAL(timeout()),
228  this, SLOT(updateMapInternal()));
229 
230  QObject::connect(
231  this,SIGNAL(waitForRfidPose()),
232  &map_connector_, SLOT(waitForRfidPlace()));
233 
234  QObject::connect(
235  &map_connector_,SIGNAL(rfidPlaceSet(QPoint)),
236  this, SLOT(rfidPlaceSet(QPoint)));
237 
238  QObject::connect(
239  this,SIGNAL(waitForThermalPose()),
240  &map_connector_, SLOT(waitForThermalPlace()));
241 
242  QObject::connect(
243  &map_connector_,SIGNAL(thermalPlaceSet(QPoint)),
244  this, SLOT(thermalPlaceSet(QPoint)));
245 
246  QObject::connect(
247  this,SIGNAL(waitForCo2Pose()),
248  &map_connector_, SLOT(waitForCo2Place()));
249 
250  QObject::connect(
251  this,SIGNAL(waitForSoundPose()),
252  &map_connector_, SLOT(waitForSoundPlace()));
253 
254  QObject::connect(
255  &map_connector_,SIGNAL(soundPlaceSet(QPoint)),
256  this, SLOT(soundPlaceSet(QPoint)));
257 
258  QObject::connect(
259  &map_connector_,SIGNAL(co2PlaceSet(QPoint)),
260  this, SLOT(co2PlaceSet(QPoint)));
261 
262  QObject::connect(
263  &info_connector_,SIGNAL(laserVisibilityClicked(QString,QString)),
264  this, SLOT(laserVisibilityClicked(QString,QString)));
265 
266  QObject::connect(
267  &info_connector_,SIGNAL(sonarVisibilityClicked(QString,QString)),
268  this, SLOT(sonarVisibilityClicked(QString,QString)));
269 
270  QObject::connect(
271  &info_connector_,SIGNAL(rfidReaderVisibilityClicked(QString,QString)),
272  this, SLOT(rfidReaderVisibilityClicked(QString,QString)));
273 
274  QObject::connect(
275  &info_connector_,SIGNAL(co2SensorVisibilityClicked(QString,QString)),
276  this, SLOT(co2SensorVisibilityClicked(QString,QString)));
277 
278  QObject::connect(
279  &info_connector_,SIGNAL(thermalSensorVisibilityClicked(QString,QString)),
280  this, SLOT(thermalSensorVisibilityClicked(QString,QString)));
281 
282  QObject::connect(
283  &info_connector_,SIGNAL(soundSensorVisibilityClicked(QString,QString)),
284  this, SLOT(soundSensorVisibilityClicked(QString,QString)));
285 
286  QObject::connect(
287  &info_connector_,SIGNAL(robotVisibilityClicked(QString)),
288  this, SLOT(robotVisibilityClicked(QString)));
289 
290  QObject::connect(
291  this, SIGNAL(setRobotVisibility(QString,char)),
292  &info_connector_, SLOT(setRobotVisibility(QString,char)));
293 
294  QObject::connect(
295  this, SIGNAL(setLaserVisibility(QString,QString,char)),
296  &info_connector_, SLOT(setLaserVisibility(QString,QString,char)));
297 
298  QObject::connect(
299  this, SIGNAL(setSonarVisibility(QString,QString,char)),
300  &info_connector_, SLOT(setSonarVisibility(QString,QString,char)));
301 
302  QObject::connect(
303  this, SIGNAL(setRfidReaderVisibility(QString,QString,char)),
304  &info_connector_, SLOT(setRfidReaderVisibility(QString,QString,char)));
305 
306  QObject::connect(
307  this, SIGNAL(setCO2SensorVisibility(QString,QString,char)),
308  &info_connector_, SLOT(setCO2SensorVisibility(QString,QString,char)));
309 
310  QObject::connect(
311  this, SIGNAL(setThermalSensorVisibility(QString,QString,char)),
312  &info_connector_, SLOT(setThermalSensorVisibility(QString,QString,char)));
313 
314  QObject::connect(
315  this, SIGNAL(setSoundSensorVisibility(QString,QString,char)),
316  &info_connector_, SLOT(setSoundSensorVisibility(QString,QString,char)));
317  }
318 
324  {
325  {
327  }
328  {
329  initial_map_ = running_map_ = QImage((
330  stdr_gui_tools::getRosPackagePath("stdr_gui") +
331  std::string("/resources/images/logo.png")).c_str());
332 
333  map_msg_.info.width = initial_map_.width();
334  map_msg_.info.height = initial_map_.height();
335 
337 
339 
342  }
343  }
344 
350  {
351  if ( ! ros::master::check() )
352  {
353  return false;
354  }
356 
358  boost::thread spinThread(&spinThreadFunction);
359  return true;
360  }
361 
365  void CGuiController::receiveRfids(const stdr_msgs::RfidTagVector& msg)
366  {
367  rfid_tag_pure_ = msg;
368  rfid_tags_.clear();
369  for(unsigned int i = 0 ; i < msg.rfid_tags.size() ; i++)
370  {
371  QPoint p(msg.rfid_tags[i].pose.x / map_msg_.info.resolution,
372  msg.rfid_tags[i].pose.y / map_msg_.info.resolution);
373 
374  CGuiRfidTag temp_tag(p, msg.rfid_tags[i].tag_id,
375  map_msg_.info.resolution);
376 
377  temp_tag.setMessage(QString(msg.rfid_tags[i].message.c_str()));
378 
379  rfid_tags_.insert(std::pair<QString, CGuiRfidTag>(
380  QString(temp_tag.getName().c_str()), temp_tag));
381  }
382  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
383  {
384  registered_robots_[i].setEnvironmentalTags(rfid_tag_pure_);
385  }
386  }
387 
391  void CGuiController::receiveCO2Sources(const stdr_msgs::CO2SourceVector& msg)
392  {
393  co2_source_pure_ = msg;
394  co2_sources_.clear();
395  for(unsigned int i = 0 ; i < msg.co2_sources.size() ; i++)
396  {
397  QPoint p(msg.co2_sources[i].pose.x / map_msg_.info.resolution,
398  msg.co2_sources[i].pose.y / map_msg_.info.resolution);
399 
400  CGuiCo2Source temp_source(p, msg.co2_sources[i].id,
401  map_msg_.info.resolution);
402 
403  temp_source.setPpm(msg.co2_sources[i].ppm);
404 
405  co2_sources_.insert(std::pair<QString, CGuiCo2Source>(
406  QString(temp_source.getName().c_str()), temp_source));
407  }
408  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
409  {
410  registered_robots_[i].setEnvironmentalCO2Sources(co2_source_pure_);
411  }
412  }
413 
418  (const stdr_msgs::ThermalSourceVector& msg)
419  {
420  thermal_source_pure_ = msg;
421  thermal_sources_.clear();
422  for(unsigned int i = 0 ; i < msg.thermal_sources.size() ; i++)
423  {
424  QPoint p(msg.thermal_sources[i].pose.x / map_msg_.info.resolution,
425  msg.thermal_sources[i].pose.y / map_msg_.info.resolution);
426 
427  CGuiThermalSource temp_source(p, msg.thermal_sources[i].id,
428  map_msg_.info.resolution);
429 
430  temp_source.setDegrees(msg.thermal_sources[i].degrees);
431 
432  thermal_sources_.insert(std::pair<QString, CGuiThermalSource>(
433  QString(temp_source.getName().c_str()), temp_source));
434  }
435  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
436  {
437  registered_robots_[i].setEnvironmentalThermalSources(
439  }
440  }
441 
446  (const stdr_msgs::SoundSourceVector& msg)
447  {
448  sound_source_pure_ = msg;
449  sound_sources_.clear();
450  for(unsigned int i = 0 ; i < msg.sound_sources.size() ; i++)
451  {
452  QPoint p(msg.sound_sources[i].pose.x / map_msg_.info.resolution,
453  msg.sound_sources[i].pose.y / map_msg_.info.resolution);
454 
455  CGuiSoundSource temp_source(p, msg.sound_sources[i].id,
456  map_msg_.info.resolution);
457 
458  //~ temp_source.setMessage(QString(msg.rfid_tags[i].message.c_str()));
459 
460  sound_sources_.insert(std::pair<QString, CGuiSoundSource>(
461  QString(temp_source.getName().c_str()), temp_source));
462  }
463  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
464  {
465  registered_robots_[i].setEnvironmentalSoundSources(sound_source_pure_);
466  }
467  }
468 
475  void CGuiController::receiveMap(const nav_msgs::OccupancyGrid& msg)
476  {
477  map_msg_ = msg;
479  QImage(msg.info.width,msg.info.height,QImage::Format_RGB32);
480  QPainter painter(&running_map_);
481  int d(0);
482  QColor c;
483  for( unsigned int i = 0 ; i < msg.info.width ; i++ )
484  {
485  for( unsigned int j = 0 ; j < msg.info.height ; j++ )
486  {
487  if( msg.data[j * msg.info.width + i] == -1 )
488  {
489  c=QColor(127,127,127);
490  }
491  else
492  {
493  d = (100.0 - msg.data[j * msg.info.width + i]) / 100.0 * 255.0;
494  c=QColor(d,d,d);
495  }
496  painter.setPen(c);
497  painter.drawPoint(i,j);
498  }
499  }
500  int originx = msg.info.origin.position.x / msg.info.resolution;
501  int originy = msg.info.origin.position.y / msg.info.resolution;
502  painter.setPen(Qt::blue);
503  painter.drawLine(originx, originy - 20, originx, originy + 20);
504  painter.drawLine(originx - 20, originy, originx + 20, originy);
505 
507 
508  info_connector_.updateMapInfo( msg.info.width * msg.info.resolution,
509  msg.info.height * msg.info.resolution,
510  msg.info.resolution);
512  QSize(initial_map_.width(),initial_map_.height()));
513 
514  elapsed_time_.start();
515 
516  map_initialized_ = true;
519 
520  timer_->start(50);
521 
523  "stdr_server/active_robots",
524  1,
526  this);
527  }
528 
535  void CGuiController::saveRobotPressed(stdr_msgs::RobotMsg newRobotMsg,
536  QString file_name)
537  {
538  std::string file_name_str=file_name.toStdString();
539 
540  try {
541  stdr_parser::Parser::saveMessage(newRobotMsg, file_name.toStdString());
542  }
544  {
545  gui_connector_.raiseMessage("STDR Parser - Error", ex.what());
546  }
547  }
548 
554  void CGuiController::loadRobotPressed(stdr_msgs::RobotMsg newRobotMsg)
555  {
556  if ( ! map_initialized_ )
557  {
558  return;
559  }
560  Q_EMIT waitForRobotPose();
561  }
562 
568  void CGuiController::loadRobotFromFilePressed(stdr_msgs::RobotMsg newRobotMsg)
569  {
570  if ( ! map_initialized_ )
571  {
572  return;
573  }
576  Q_EMIT waitForRobotPose();
577  }
578 
584  {
585  if ( ! map_initialized_ )
586  {
587  return;
588  }
589  Q_EMIT waitForRfidPose();
590  }
591 
597  {
598  if ( ! map_initialized_ )
599  {
600  return;
601  }
602  Q_EMIT waitForThermalPose();
603  }
604 
610  {
611  if ( ! map_initialized_ )
612  {
613  return;
614  }
615  Q_EMIT waitForCo2Pose();
616  }
617 
623  {
624  if ( ! map_initialized_ )
625  {
626  return;
627  }
628  Q_EMIT waitForSoundPose();
629  }
630 
637  {
638  if ( ! map_initialized_ )
639  {
640  return;
641  }
642  map_connector_.updateZoom(p,true);
643  }
644 
651  {
652  if ( ! map_initialized_ )
653  {
654  return;
655  }
656  map_connector_.updateZoom(p,false);
657  }
658 
665  const stdr_msgs::RobotIndexedVectorMsg& msg)
666  {
667  std::set<QString> newSensors, erasedSensorsL, erasedSensorsS;
668  for( unsigned int r = 0 ; r < msg.robots.size() ; r++ )
669  {
670  QString baseName = QString(msg.robots[r].name.c_str());
671  for(unsigned int l = 0;
672  l < msg.robots[r].robot.laserSensors.size() ; l++)
673  {
674  QString fullName = baseName + QString("/") +
675  QString(
676  msg.robots[r].robot.laserSensors[l].frame_id.c_str() );
677  newSensors.insert(fullName);
678  }
679  for(unsigned int s = 0;
680  s < msg.robots[r].robot.sonarSensors.size() ; s++ )
681  {
682  QString fullName = baseName + QString("/") +
683  QString(
684  msg.robots[r].robot.sonarSensors[s].frame_id.c_str());
685  newSensors.insert(fullName);
686  }
687  }
688 
689  for(LaserVisIterator it = laser_visualizers_.begin() ;
690  it != laser_visualizers_.end() ; it++ )
691  {
692  if( newSensors.find(it->first) == newSensors.end() )
693  {
694  erasedSensorsL.insert(it->first);
695  }
696  }
697  for(SonarVisIterator it = sonar_visualizers_.begin() ;
698  it != sonar_visualizers_.end() ; it++)
699  {
700  if(newSensors.find(it->first) == newSensors.end())
701  {
702  erasedSensorsS.insert(it->first);
703  }
704  }
705 
706  for(std::set<QString>::iterator it = erasedSensorsL.begin() ;
707  it != erasedSensorsL.end() ; it++)
708  {
709  laser_visualizers_[*it]->destruct();
710  laser_visualizers_.erase(*it);
711  }
712  for(std::set<QString>::iterator it = erasedSensorsS.begin() ;
713  it != erasedSensorsS.end() ; it++)
714  {
715  sonar_visualizers_[*it]->destruct();
716  sonar_visualizers_.erase(*it);
717  }
718 
719  }
720 
727  const stdr_msgs::RobotIndexedVectorMsg& msg)
728  {
729  if ( ! map_initialized_ )
730  {
731  return;
732  }
733  while(map_lock_)
734  {
735  usleep(100);
736  }
737  map_lock_ = true;
738 
739  cleanupVisualizers(msg);
740 
741  registered_robots_.clear();
742  all_robots_ = msg;
743  for(unsigned int i = 0 ; i < msg.robots.size() ; i++)
744  {
745  registered_robots_.push_back(CGuiRobot(msg.robots[i]));
746  }
748 
749  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
750  {
751  registered_robots_[i].setEnvironmentalTags(rfid_tag_pure_);
752  registered_robots_[i].setEnvironmentalCO2Sources(co2_source_pure_);
753  registered_robots_[i].setEnvironmentalThermalSources(thermal_source_pure_);
754  registered_robots_[i].setEnvironmentalSoundSources(sound_source_pure_);
755  }
756  map_lock_ = false;
757  }
758 
765  {
766  if ( ! map_initialized_ )
767  {
768  return;
769  }
770  while(map_lock_)
771  {
772  usleep(100);
773  }
774  map_lock_ = true;
775 
776  QPoint pnew = map_connector_.getGlobalPoint(p);
778  pnew.x() * map_msg_.info.resolution,
779  pnew.y() * map_msg_.info.resolution);
780 
781  stdr_msgs::RobotIndexedMsg newRobot;
782  try
783  {
784  newRobot = robot_handler_.spawnNewRobot(
787 
788  my_robots_.insert(newRobot.name);
789  }
791  {
792  map_lock_ = false;
793  gui_connector_.raiseMessage("STDR Robot Spawn - Error", ex.what());
794  }
796  {
797  map_lock_ = false;
798  gui_connector_.raiseMessage("STDR Robot Spawn - Error", ex.what());
799  }
800  map_lock_ = false;
801  }
802 
810  {
811  if ( ! map_initialized_ )
812  {
813  return;
814  }
815 
816  QPoint pnew = map_connector_.getGlobalPoint(p);
817  QString name=QString("rfid_tag_") + QString().setNum(rfid_tags_.size());
818 
819  bool ok;
820  stdr_msgs::RfidTag new_tag;
821 
823  QString rfid_id = QInputDialog::getText(
824  &(info_connector_.loader), tr("QInputDialog::getText()"),
825  tr("RFID tag id:"), QLineEdit::Normal,
826  "", &ok);
827  if ( ok && !rfid_id.isEmpty() ) {
828  new_tag.tag_id = rfid_id.toStdString();
829  }
831  QString rfid_message = QInputDialog::getText(
832  &(info_connector_.loader), tr("QInputDialog::getText()"),
833  tr("RFID tag message (optional):"), QLineEdit::Normal,
834  "", &ok);
835  if ( ok && !rfid_message.isEmpty() ) {
836  new_tag.message = rfid_message.toStdString();
837  }
838 
839  new_tag.pose.x = pnew.x() * map_msg_.info.resolution ;
840  new_tag.pose.y = pnew.y() * map_msg_.info.resolution ;
841  new_tag.pose.theta = 0;
842 
843  stdr_msgs::AddRfidTag srv;
844  srv.request.newTag = new_tag;
845  if (new_rfid_tag_client_.call(srv))
846  {
848  "STDR robot - Error", QString(srv.response.message.c_str()));
849  }
850 
851  }
852 
860  {
861  if ( ! map_initialized_ )
862  {
863  return;
864  }
865 
866  QPoint pnew = map_connector_.getGlobalPoint(p);
867  QString name=QString("co2_source_") + QString().setNum(co2_sources_.size());
868 
869  bool ok;
870  stdr_msgs::CO2Source new_source;
871 
873  QString id = QInputDialog::getText(
874  &(info_connector_.loader), tr("QInputDialog::getText()"),
875  tr("CO2 Source id:"), QLineEdit::Normal,
876  "", &ok);
877  if ( ok && !id.isEmpty() ) {
878  new_source.id = id.toStdString();
879  }
881  QString ppms = QInputDialog::getText(
882  &(info_connector_.loader), tr("QInputDialog::getText()"),
883  tr("PPMs (Part Per Million):"), QLineEdit::Normal,
884  "", &ok);
885  if ( ok && !ppms.isEmpty() ) {
886  new_source.ppm = ppms.toFloat();
887  }
888 
889  new_source.pose.x = pnew.x() * map_msg_.info.resolution ;
890  new_source.pose.y = pnew.y() * map_msg_.info.resolution ;
891  new_source.pose.theta = 0;
892 
893  stdr_msgs::AddCO2Source srv;
894  srv.request.newSource = new_source;
895  if (new_co2_source_client_.call(srv))
896  {
898  "STDR robot - Error", QString(srv.response.message.c_str()));
899  }
900  }
901 
909  {
910  if ( ! map_initialized_ )
911  {
912  return;
913  }
914 
915  QPoint pnew = map_connector_.getGlobalPoint(p);
916  QString name=QString("thermal_source_") +
917  QString().setNum(thermal_sources_.size());
918 
919  bool ok;
920  stdr_msgs::ThermalSource new_source;
921 
923  QString id = QInputDialog::getText(
924  &(info_connector_.loader), tr("QInputDialog::getText()"),
925  tr("Thermal Source id:"), QLineEdit::Normal,
926  "", &ok);
927  if ( ok && !id.isEmpty() ) {
928  new_source.id = id.toStdString();
929  }
931  QString degrees = QInputDialog::getText(
932  &(info_connector_.loader), tr("QInputDialog::getText()"),
933  tr("Degrees:"), QLineEdit::Normal,
934  "", &ok);
935  if ( ok && !degrees.isEmpty() ) {
936  new_source.degrees = degrees.toFloat();
937  }
938 
939  new_source.pose.x = pnew.x() * map_msg_.info.resolution ;
940  new_source.pose.y = pnew.y() * map_msg_.info.resolution ;
941  new_source.pose.theta = 0;
942 
943  stdr_msgs::AddThermalSource srv;
944  srv.request.newSource = new_source;
946  {
948  "STDR robot - Error", QString(srv.response.message.c_str()));
949  }
950  }
951 
959  {
960  if ( ! map_initialized_ )
961  {
962  return;
963  }
964 
965  QPoint pnew = map_connector_.getGlobalPoint(p);
966  QString name=QString("sound_source_") +
967  QString().setNum(sound_sources_.size());
968 
969  bool ok;
970  stdr_msgs::SoundSource new_source;
971 
973  QString id = QInputDialog::getText(
974  &(info_connector_.loader), tr("QInputDialog::getText()"),
975  tr("Sound Source id:"), QLineEdit::Normal,
976  "", &ok);
977  if ( ok && !id.isEmpty() ) {
978  new_source.id = id.toStdString();
979  }
981  QString dbs = QInputDialog::getText(
982  &(info_connector_.loader), tr("QInputDialog::getText()"),
983  tr("DBs (Decibels):"), QLineEdit::Normal,
984  "", &ok);
985  if ( ok && !dbs.isEmpty() ) {
986  new_source.dbs = dbs.toFloat();
987  }
988 
989  new_source.pose.x = pnew.x() * map_msg_.info.resolution ;
990  new_source.pose.y = pnew.y() * map_msg_.info.resolution ;
991  new_source.pose.theta = 0;
992 
993  stdr_msgs::AddSoundSource srv;
994  srv.request.newSource = new_source;
996  {
998  "STDR robot - Error", QString(srv.response.message.c_str()));
999  }
1000  }
1001 
1007  {
1008  while(map_lock_)
1009  {
1010  usleep(100);
1011  }
1012  map_lock_ = true;
1014 
1016  map_connector_.drawGrid(&running_map_, map_msg_.info.resolution);
1017 
1018  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1019  {
1020  registered_robots_[i].draw(
1021  &running_map_,map_msg_.info.resolution,&listener_);
1022  }
1023  running_map_ = running_map_.mirrored(false,true);
1024  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1025  {
1026  if(registered_robots_[i].getShowLabel())
1027  registered_robots_[i].drawLabel(
1028  &running_map_,map_msg_.info.resolution);
1029  }
1030 
1031  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1032  {
1034  {
1036  registered_robots_[i].getCurrentPose());
1037  }
1038  }
1039 
1040  for(RfidTagIterator it = rfid_tags_.begin() ;
1041  it != rfid_tags_.end() ; it++)
1042  {
1043  it->second.draw(&running_map_);
1044  }
1045 
1046  for(Co2SourcesIterator it = co2_sources_.begin() ;
1047  it != co2_sources_.end() ; it++)
1048  {
1049  it->second.draw(&running_map_);
1050  }
1051 
1052  for(SoundSourcesIterator it = sound_sources_.begin() ;
1053  it != sound_sources_.end() ; it++)
1054  {
1055  it->second.draw(&running_map_);
1056  }
1057 
1058  for(ThermalSourcesIterator it = thermal_sources_.begin() ;
1059  it != thermal_sources_.end() ; it++)
1060  {
1061  it->second.draw(&running_map_);
1062  }
1063 
1065 
1067  QString("Time elapsed : ") +
1069  map_lock_ = false;
1070 
1072  std::vector<QString> toBeErased;
1073  for(LaserVisIterator it = laser_visualizers_.begin() ;
1074  it != laser_visualizers_.end() ; it++)
1075  {
1076  if( ! it->second->getActive())
1077  {
1078  toBeErased.push_back(it->first);
1079  }
1080  else
1081  {
1082  it->second->paint();
1083  }
1084  }
1085  for(unsigned int i = 0 ; i < toBeErased.size() ; i++)
1086  {
1087  laser_visualizers_.erase(toBeErased[i]);
1088  }
1089  toBeErased.clear();
1090  for(SonarVisIterator it = sonar_visualizers_.begin() ;
1091  it != sonar_visualizers_.end() ; it++)
1092  {
1093  if( ! it->second->getActive())
1094  {
1095  toBeErased.push_back(it->first);
1096  }
1097  else
1098  {
1099  it->second->paint();
1100  }
1101  }
1102  for(unsigned int i = 0 ; i < toBeErased.size() ; i++)
1103  {
1104  sonar_visualizers_.erase(toBeErased[i]);
1105  }
1106  toBeErased.clear();
1107  for(RobotVisIterator it = robot_visualizers_.begin() ;
1108  it != robot_visualizers_.end() ;
1109  it++)
1110  {
1111  if( ! it->second->getActive())
1112  {
1113  toBeErased.push_back(it->first);
1114  }
1115  else
1116  {
1117  QString robotName = it->first;
1118  for(unsigned int r = 0 ; r < registered_robots_.size() ; r++)
1119  {
1120  if(registered_robots_[r].getFrameId() == robotName.toStdString())
1121  {
1122  it->second->setImage(
1123  registered_robots_[r].
1124  getVisualization(map_msg_.info.resolution));
1125  it->second->setCurrentPose(registered_robots_[r].getCurrentPoseM());
1126 
1127  it->second->setCurrentSpeed(
1128  registered_robots_[r].getSpeeds());
1129  break;
1130  }
1131  }
1132  }
1133  }
1134  for(unsigned int i = 0 ; i < toBeErased.size() ; i++)
1135  {
1136  robot_visualizers_.erase(toBeErased[i]);
1137  }
1138 
1141  {
1142  QEvent *e = gui_connector_.getCloseEvent();
1143 
1144  this->exit();
1146  }
1147  }
1148 
1155  stdr_msgs::LaserSensorMsg CGuiController::getLaserDescription(
1156  QString robotName,
1157  QString laserName)
1158  {
1159  for(unsigned int i = 0 ; i < all_robots_.robots.size() ; i++)
1160  {
1161  if(all_robots_.robots[i].name == robotName.toStdString())
1162  {
1163  for(unsigned int j = 0 ;
1164  j < all_robots_.robots[i].robot.laserSensors.size() ;
1165  j++)
1166  {
1167  if(all_robots_.robots[i].robot.laserSensors[j].frame_id
1168  == laserName.toStdString())
1169  {
1170  return all_robots_.robots[i].robot.laserSensors[j];
1171  }
1172  }
1173  }
1174  }
1175  return stdr_msgs::LaserSensorMsg();
1176  }
1177 
1184  stdr_msgs::SonarSensorMsg CGuiController::getSonarDescription(
1185  QString robotName,
1186  QString sonarName)
1187  {
1188  for(unsigned int i = 0 ; i < all_robots_.robots.size() ; i++)
1189  {
1190  if(all_robots_.robots[i].name == robotName.toStdString())
1191  {
1192  for(unsigned int j = 0 ;
1193  j < all_robots_.robots[i].robot.sonarSensors.size() ;
1194  j++)
1195  {
1196  if(all_robots_.robots[i].robot.sonarSensors[j].frame_id
1197  == sonarName.toStdString())
1198  {
1199  return all_robots_.robots[i].robot.sonarSensors[j];
1200  }
1201  }
1202  }
1203  }
1204  return stdr_msgs::SonarSensorMsg();
1205  }
1206 
1214  QString robotName,
1215  QString laserName)
1216  {
1217  QString name = robotName + QString("/") + laserName;
1218  if(laser_visualizers_.find(name) != laser_visualizers_.end())
1219  {
1220  return;
1221  }
1222  CLaserVisualisation *lv;
1223  lv = new CLaserVisualisation(name,map_msg_.info.resolution);
1224  laser_visualizers_.insert(
1225  std::pair<QString,CLaserVisualisation *>(name,lv));
1226  lv->setWindowFlags(Qt::WindowStaysOnTopHint);
1227 
1228  lv->setLaser(getLaserDescription(robotName,laserName));
1229 
1230  lv->show();
1231  }
1232 
1240  QString robotName,
1241  QString sonarName)
1242  {
1243  QString name = robotName + QString("/") + sonarName;
1244  if(sonar_visualizers_.find(name) != sonar_visualizers_.end())
1245  {
1246  return;
1247  }
1248  CSonarVisualisation *sv;
1249  sv = new CSonarVisualisation(name,map_msg_.info.resolution);
1250  sonar_visualizers_.insert(
1251  std::pair<QString,CSonarVisualisation *>(name,sv));
1252  sv->setWindowFlags(Qt::WindowStaysOnTopHint);
1253 
1254  sv->setSonar(getSonarDescription(robotName,sonarName));
1255 
1256  sv->show();
1257  }
1258 
1265  {
1266  QString name = robotName;
1267  if(robot_visualizers_.find(name) != robot_visualizers_.end())
1268  {
1269  return;
1270  }
1271  CRobotVisualisation *sv;
1272  sv = new CRobotVisualisation(name,map_msg_.info.resolution);
1273  robot_visualizers_.insert(
1274  std::pair<QString,CRobotVisualisation *>(name,sv));
1275  sv->setWindowFlags(Qt::WindowStaysOnTopHint);
1276 
1277  sv->show();
1278  }
1279 
1286  void CGuiController::itemClicked(QPoint p,Qt::MouseButton b)
1287  {
1289  QPoint pointClicked = map_connector_.getGlobalPoint(p);
1290  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1291  {
1292  if(registered_robots_[i].checkEventProximity(pointClicked))
1293  {
1294  if(b == Qt::RightButton)
1295  {
1296  QMenu myMenu;
1297 
1298  QAction *nothing = myMenu.addAction(
1299  QString("Robot : ") +
1300  QString(registered_robots_[i].getFrameId().c_str()));
1301  nothing->setCheckable(false);
1302  nothing->setEnabled(false);
1303 
1304  QAction *deleteRobot = myMenu.addAction(icon_delete_,"Delete robot");
1305  QAction *moveRobot = myMenu.addAction(icon_move_,"Move robot");
1306  myMenu.addSeparator();
1307  QAction *showCircle = myMenu.addAction("Show proximity circles");
1308  QAction *followRobot = myMenu.addAction("Follow robot");
1309 
1310  QAction* selectedItem = myMenu.exec(map_connector_.mapToGlobal(p));
1311  if(selectedItem == showCircle)
1312  {
1313  registered_robots_[i].toggleShowCircles();
1314  }
1315  else if(selectedItem == deleteRobot)
1316  {
1319  }
1320  else if(selectedItem == moveRobot)
1321  {
1323  }
1324  else if(selectedItem == followRobot)
1325  {
1327  {
1328  robot_following_ = "";
1329  }
1330  else
1331  {
1332  robot_following_ = registered_robots_[i].getFrameId();
1333  }
1334  }
1335  }
1336  else if(b == Qt::LeftButton)
1337  {
1338  registered_robots_[i].toggleShowLabel();
1339  }
1340  }
1341  }
1342  for(RfidTagIterator i = rfid_tags_.begin() ; i != rfid_tags_.end() ; i++)
1343  {
1344  if(i->second.checkProximity(pointClicked))
1345  {
1346  if(b == Qt::RightButton)
1347  {
1348  QMenu myMenu;
1349 
1350  QAction *name = myMenu.addAction(
1351  QString("RFID tag : ") + QString(i->first)
1352  );
1353  name->setCheckable(false);
1354  name->setEnabled(false);
1355 
1356  QAction *message = myMenu.addAction(
1357  QString("Message : ") + QString(i->second.getMessage())
1358  );
1359  message->setCheckable(false);
1360  message->setEnabled(false);
1361 
1362  QAction *deleteTag = myMenu.addAction(icon_delete_,"Delete RFID tag");
1363 
1364  QAction* selectedItem = myMenu.exec(map_connector_.mapToGlobal(p));
1365  if(selectedItem == deleteTag)
1366  {
1367  stdr_msgs::DeleteRfidTag srv;
1368  srv.request.name = i->first.toStdString();
1370  break;
1371  }
1372  }
1373  }
1374  }
1375  for(Co2SourcesIterator i = co2_sources_.begin() ;
1376  i != co2_sources_.end() ; i++)
1377  {
1378  if(i->second.checkProximity(pointClicked))
1379  {
1380  if(b == Qt::RightButton)
1381  {
1382  QMenu myMenu;
1383 
1384  QAction *name = myMenu.addAction(
1385  QString("CO2 Source : ") + QString(i->first)
1386  );
1387  name->setCheckable(false);
1388  name->setEnabled(false);
1389 
1390  QAction *message = myMenu.addAction(
1391  QString("PPMs : ") + QString().setNum(i->second.getPpm())
1392  );
1393  message->setCheckable(false);
1394  message->setEnabled(false);
1395 
1396  QAction *deleteSource = myMenu.addAction(icon_delete_,
1397  "Delete CO2 Source");
1398 
1399  QAction* selectedItem = myMenu.exec(map_connector_.mapToGlobal(p));
1400  if(selectedItem == deleteSource)
1401  {
1402  stdr_msgs::DeleteCO2Source srv;
1403  srv.request.name = i->first.toStdString();
1405  break;
1406  }
1407  }
1408  }
1409  }
1410  for(ThermalSourcesIterator i = thermal_sources_.begin() ;
1411  i != thermal_sources_.end() ; i++)
1412  {
1413  if(i->second.checkProximity(pointClicked))
1414  {
1415  if(b == Qt::RightButton)
1416  {
1417  QMenu myMenu;
1418 
1419  QAction *name = myMenu.addAction(
1420  QString("Thermal Source : ") + QString(i->first)
1421  );
1422  name->setCheckable(false);
1423  name->setEnabled(false);
1424 
1425  QAction *message = myMenu.addAction(
1426  QString("Degrees : ") + QString().setNum(i->second.getDegrees())
1427  );
1428  message->setCheckable(false);
1429  message->setEnabled(false);
1430 
1431  QAction *deleteSource = myMenu.addAction(icon_delete_,
1432  "Delete Thermal Source");
1433 
1434  QAction* selectedItem = myMenu.exec(map_connector_.mapToGlobal(p));
1435  if(selectedItem == deleteSource)
1436  {
1437  stdr_msgs::DeleteThermalSource srv;
1438  srv.request.name = i->first.toStdString();
1440  break;
1441  }
1442  }
1443  }
1444  }
1445  for(SoundSourcesIterator i = sound_sources_.begin() ;
1446  i != sound_sources_.end() ; i++)
1447  {
1448  if(i->second.checkProximity(pointClicked))
1449  {
1450  if(b == Qt::RightButton)
1451  {
1452  QMenu myMenu;
1453 
1454  QAction *name = myMenu.addAction(
1455  QString("Sound Source : ") + QString(i->first)
1456  );
1457  name->setCheckable(false);
1458  name->setEnabled(false);
1459 
1460  QAction *message = myMenu.addAction(
1461  QString("DBs : ") + QString().setNum(i->second.getDb())
1462  );
1463  message->setCheckable(false);
1464  message->setEnabled(false);
1465 
1466  QAction *deleteSource = myMenu.addAction(icon_delete_,
1467  "Delete Sound Source");
1468 
1469  QAction* selectedItem = myMenu.exec(map_connector_.mapToGlobal(p));
1470  if(selectedItem == deleteSource)
1471  {
1472  stdr_msgs::DeleteSoundSource srv;
1473  srv.request.name = i->first.toStdString();
1475  break;
1476  }
1477  }
1478  }
1479  }
1480  }
1481 
1488  void CGuiController::robotReplaceSet(QPoint p,std::string robotName)
1489  {
1490  if ( ! map_initialized_ )
1491  {
1492  return;
1493  }
1494  QPoint pnew = map_connector_.getGlobalPoint(p);
1495 
1496  geometry_msgs::Pose2D newPose;
1497  newPose.x = pnew.x() * map_msg_.info.resolution;
1498  newPose.y = pnew.y() * map_msg_.info.resolution;
1499 
1500  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1501  {
1502  if(registered_robots_[i].getFrameId() == robotName)
1503  {
1504  newPose.theta = registered_robots_[i].getCurrentPoseM().theta;
1505  break;
1506  }
1507  }
1508 
1509  bool success = robot_handler_.moveRobot(robotName,newPose);
1510  if(!success)
1511  {
1513  "STDR robot - Error", "Unable to relocate the robot");
1514  }
1515  }
1516 
1524  QString robotName,QString laserName)
1525  {
1526  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1527  {
1528  if(registered_robots_[i].getFrameId() == robotName.toStdString())
1529  {
1530  char vs = registered_robots_[i].getLaserVisualizationStatus(
1531  laserName.toStdString());
1532  Q_EMIT setLaserVisibility(robotName,laserName,(vs + 1) % 3);
1533  registered_robots_[i].toggleLaserVisualizationStatus(
1534  laserName.toStdString());
1535  break;
1536  }
1537  }
1538  }
1539 
1547  QString robotName,QString sonarName)
1548  {
1549  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1550  {
1551  if(registered_robots_[i].getFrameId() == robotName.toStdString())
1552  {
1553  char vs = registered_robots_[i].getSonarVisualizationStatus(
1554  sonarName.toStdString());
1555  Q_EMIT setSonarVisibility(robotName,sonarName,(vs + 1) % 3);
1556  registered_robots_[i].toggleSonarVisualizationStatus(
1557  sonarName.toStdString());
1558  break;
1559  }
1560  }
1561  }
1562 
1569  (QString robotName,QString rfidReaderName)
1570  {
1571  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1572  {
1573  if(registered_robots_[i].getFrameId() == robotName.toStdString())
1574  {
1575  char vs = registered_robots_[i].getRfidReaderVisualizationStatus(
1576  rfidReaderName.toStdString());
1577  Q_EMIT setRfidReaderVisibility(robotName,rfidReaderName,(vs + 1) % 3);
1578  registered_robots_[i].toggleRfidReaderVisualizationStatus(
1579  rfidReaderName.toStdString());
1580  break;
1581  }
1582  }
1583  }
1590  (QString robotName,QString co2SensorName)
1591  {
1592  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1593  {
1594  if(registered_robots_[i].getFrameId() == robotName.toStdString())
1595  {
1596  char vs = registered_robots_[i].getCO2SensorVisualizationStatus(
1597  co2SensorName.toStdString());
1598  Q_EMIT setCO2SensorVisibility(robotName, co2SensorName, (vs + 1) % 3);
1599  registered_robots_[i].toggleCO2SensorVisualizationStatus(
1600  co2SensorName.toStdString());
1601  break;
1602  }
1603  }
1604  }
1611  (QString robotName,QString thermalSensorName)
1612  {
1613  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1614  {
1615  if(registered_robots_[i].getFrameId() == robotName.toStdString())
1616  {
1617  char vs = registered_robots_[i].getThermalSensorVisualizationStatus(
1618  thermalSensorName.toStdString());
1619  Q_EMIT setThermalSensorVisibility(robotName,
1620  thermalSensorName, (vs + 1) % 3);
1621  registered_robots_[i].toggleThermalSensorVisualizationStatus(
1622  thermalSensorName.toStdString());
1623  break;
1624  }
1625  }
1626  }
1633  (QString robotName,QString soundSensorName)
1634  {
1635  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1636  {
1637  if(registered_robots_[i].getFrameId() == robotName.toStdString())
1638  {
1639  char vs = registered_robots_[i].getSoundSensorVisualizationStatus(
1640  soundSensorName.toStdString());
1641  Q_EMIT setSoundSensorVisibility(robotName,
1642  soundSensorName, (vs + 1) % 3);
1643  registered_robots_[i].toggleSoundSensorVisualizationStatus(
1644  soundSensorName.toStdString());
1645  break;
1646  }
1647  }
1648  }
1649 
1656  {
1657  for(unsigned int i = 0 ; i < registered_robots_.size() ; i++)
1658  {
1659  if(registered_robots_[i].getFrameId() == robotName.toStdString())
1660  {
1661  char vs = registered_robots_[i].getVisualizationStatus();
1662  Q_EMIT setRobotVisibility(robotName,(vs + 1) % 3);
1663  registered_robots_[i].toggleVisualizationStatus();
1664  }
1665  }
1666  }
1667 }
1668 
1669 
void updateZoom(QPoint p, bool z)
Updates the map zoom. Wrapper for a loader function.
void thermalSensorVisibilityClicked(QString robotName, QString thermalSensorName)
Informs CGuiController that a Thermal Sensor visibility status has \ been clicked. Connects to the CInfoConnector::thermalSensorVisibilityClicked\ signal.
Implements the functionalities of the sonar visualization widget. Inherits form QWidget and Ui_sonarV...
d
void setLaserVisibility(QString robotName, QString laserName, char vs)
Is emitted when a laser&#39;s visibility status is going to be changed. Connects to the CInfoConnector::s...
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
CRobotCreatorConnector robotCreatorConn
< Serves the Qt events of the RobotCreator Widget
void saveRobotPressed(stdr_msgs::RobotMsg newRobotMsg, QString file_name)
Saves the robot in a yaml file. Connects to the CGuiConnector::CRobotCreatorConnector::saveRobotPress...
void sonarVisualizerClicked(QString robotName, QString sonarName)
Informs CGuiController that a sonar visualizer has been clicked. Connects to the CInfoConnector::sona...
void setGridColumnStretch(int cell, int stretch)
Wraps the Qt gridColumnStretch function.
const std::string & getFrameId(const T &t)
ROSCPP_DECL bool check()
std::string getRosPackagePath(std::string package)
Returns the global path of the ROS package provided.
Definition: stdr_tools.cpp:31
void setThermalSensorVisibility(QString robotName, QString thermalSensorName, char vs)
Is emitted when a thermal sensor&#39;s visibility status is going to be \ changed. Connects to the CInfoC...
void setMapInitialized(bool mi)
Sets the map_initialized_ private variable.
nav_msgs::OccupancyGrid map_msg_
Robot handler from stdr_robot.
Implements the functionalities of a sound source.
stdr_msgs::RobotIndexedMsg spawnNewRobot(const stdr_msgs::RobotMsg msg)
void thermalPlaceSet(QPoint p)
Gets the point at which the new thermal source is placed. Connects to the CMapConnector::thermalPlace...
void setRfidReaderVisibility(QString robotName, QString rfidReaderName, char vs)
Is emitted when a rfid sensor&#39;s visibility status is going to be \ changed. Connects to the CInfoConn...
void rfidPlaceSet(QPoint p)
Gets the point at which the new RFID tag is placed. Connects to the CMapConnector::robotPlaceSet sign...
void robotVisualizerClicked(QString robotName)
Informs CGuiController that a robot visualizer has been clicked. Connects to the CInfoConnector::robo...
void setSoundSensorVisibility(QString robotName, QString soundSensorName, char vs)
Is emitted when a sound sensor&#39;s visibility status is going to be \ changed. Connects to the CInfoCon...
std::map< QString, CSonarVisualisation * > sonar_visualizers_
Robot visualizers.
Implements the functionalities of the robot visualization widget. Inherits form QWidget and Ui_robotV...
void zoomOutPressed(QPoint p)
Performs zoom out when the button is pressed. Connects to the CMapConnector::zoomOutPressed signal...
void loadRfidPressed(void)
Informs CGuiController that an RFID is going to be placed in the environment. Connects to the CGuiCon...
QString getLiteralTime(int ms)
Transforms the milliseconds in literal representation.
Definition: stdr_tools.cpp:61
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
std::map< QString, CGuiSoundSource > sound_sources_
ROS subscriber for occupancy grid map.
stdr_msgs::RobotMsg fixRobotAnglesToDegrees(stdr_msgs::RobotMsg rmsg)
Takes a stdr_msgs::RobotMsg and converts its angles to degrees.
Definition: stdr_tools.cpp:206
void loadSoundPressed(void)
Informs CGuiController that a sound source is going to be placed in the environment. Connects to the CGuiConnector::loadSoundPressed signal.
std::map< QString, CLaserVisualisation * > laser_visualizers_
Sonar visualizers.
void show(void)
Shows the main window.
void initializeCommunications(void)
Initializes the Qt event connections and ROS subscribers and publishers.
void receiveRobots(const stdr_msgs::RobotIndexedVectorMsg &msg)
Receives the robots from stdr_server. Connects to "stdr_server/active_robots" ROS topic...
ros::NodeHandle n_
ROS tf transform listener.
void waitForRfidPose(void)
Is emitted when a new rfid tag is going to be placed. Connects to the CMapConnector::waitForRfidPose ...
XmlRpcServer s
void loadThermalPressed(void)
Informs CGuiController that a thermal source is going to be placed in the environment. Connects to the CGuiConnector::loadThermalPressed signal.
void waitForRobotPose(void)
Is emitted when a new robot is going to be placed. Connects to the CMapConnector::waitForPlace slot...
void rfidReaderVisibilityClicked(QString robotName, QString rfidReaderName)
Informs CGuiController that a rfidReader visibility status has \ been clicked. Connects to the CInfoC...
QWidget * getLoader(void)
Returns the CMapLoader object.
ros::ServiceClient new_thermal_source_client_
Service client for deleting a thermal source.
~CGuiController(void)
Default destructor.
QIcon icon_delete_
QImage created one time, containing the OGM.
bool call(MReq &req, MRes &res)
void shutdown(void)
Shuts down the main window.
QIcon icon_move_
QIcon for delete robot (pop-up menu)
QTime elapsed_time_
QIcon for move robot (pop-up menu)
void receiveMap(const nav_msgs::OccupancyGrid &msg)
Receives the occupancy grid map from stdr_server. Connects to "map" ROS topic.
ros::ServiceClient delete_thermal_source_client_
Service client for inserting a new sound source.
QWidget * getLoader(void)
Returns the CInfoLoader object.
Implements the functionalities of a thermal source.
std::map< QString, CGuiSoundSource >::iterator SoundSourcesIterator
void replaceRobot(std::string robotFrameId)
Is emitted when a robot is going to be re-placed. Connects to the CMapConnector::waitForReplace slot...
std::string getName(void)
Returns the "name" of the source.
ros::Subscriber rfids_subscriber_
ROS subscriber for co2 sources.
QImage running_map_
Object of CGuiConnector.
Implements the functionalities of an RFID tag.
ros::ServiceClient delete_rfid_tag_client_
Service client for inserting a new co2 source.
std::map< QString, CRobotVisualisation * >::iterator RobotVisIterator
stdr_msgs::SoundSourceVector sound_source_pure_
Sound sources in the environment.
ROSCPP_DECL void spin(Spinner &spinner)
Implements the functionalities for a robot.
void laserVisibilityClicked(QString robotName, QString laserName)
Informs CGuiController that a laser visibility status has been clicked. Connects to the CInfoConnecto...
ros::Subscriber sound_sources_subscriber_
The ROS node handle.
void updateCenter(QPoint p)
Updates the map center when a robot is followed.
std::map< QString, CLaserVisualisation * >::iterator LaserVisIterator
void raiseMessage(QString title, QString s)
Raises a message box with a specific message.
void updateTree(const stdr_msgs::RobotIndexedVectorMsg &msg)
Updates the information tree according to the ensemble of robots.
void addToGrid(QWidget *w, int row, int column)
Adds a widget to the main window Qt grid.
stdr_msgs::LaserSensorMsg getLaserDescription(QString robotName, QString laserName)
Returns a stdr_msgs::LaserSensorMsg message from robot and laser name.
void robotReplaceSet(QPoint p, std::string robotName)
Informs CGuiController about the new pose of a robot. Connects to the CMapConnector::robotReplaceSet ...
bool closeTriggered(void)
Returns the exit triggered status.
void waitForThermalPose(void)
Is emitted when a new thermal source is going to be placed. Connects to the CMapConnector::waitForThe...
QEvent * getCloseEvent(void)
Returns the exit event captured.
ros::Subscriber co2_sources_subscriber_
ROS subscriber for thermal sources.
void loadRobotFromFilePressed(stdr_msgs::RobotMsg newRobotMsg)
Informs CGuiController that a robot is loaded from a yaml file. Connects to the CGuiConnector::robotF...
void setInitialImageSize(QSize s)
Sets map initial size to the loader.
QTimer * timer_
Elapsed time from the experiment&#39;s start.
stdr_robot::HandleRobot robot_handler_
All robots in "raw" form.
void setLaser(stdr_msgs::LaserSensorMsg msg)
Sets the laser description message.
static void saveMessage(T msg, std::string file_name)
void setCO2SensorVisibility(QString robotName, QString co2SensorName, char vs)
Is emitted when a CO2 sensor&#39;s visibility status is going to be \ changed. Connects to the CInfoConne...
std::map< QString, CRobotVisualisation * > robot_visualizers_
RFID tags in the environment.
void updateMapInfo(float width, float height, float ocgd)
Updates the information tree according to the specific map.
void waitForCo2Pose(void)
Is emitted when a new CO2 source is going to be placed. Connects to the CMapConnector::waitForCo2Pose...
ros::ServiceClient new_sound_source_client_
Service client for deleting a sound source.
stdr_msgs::RobotMsg getNewRobot(void)
Returns the created robot.
void setMessage(QString msg)
Sets the tag message.
Implements the functionalities of a CO2 source.
void setMapInitialized(bool mi)
Sets the map initialization status.
void receiveRfids(const stdr_msgs::RfidTagVector &msg)
Receives the existent rfid tags.
void setPpm(float ppm)
Sets the tag message.
ros::ServiceClient delete_co2_source_client_
Service client for inserting a new thermal source.
stdr_msgs::RobotMsg fixRobotAnglesToRad(stdr_msgs::RobotMsg rmsg)
Takes a stdr_msgs::RobotMsg and converts its angles to rads.
Definition: stdr_tools.cpp:150
QImage initial_map_
QImage that initiates as initial_map and the elements are painted on it.
Implements the functionalities of the laser visualization widget. Inherits form QWidget and Ui_laserV...
std::map< QString, CSonarVisualisation * >::iterator SonarVisIterator
void drawGrid(QImage *img, float resolution)
Wrapper for the draw grid function of loader.
stdr_msgs::RfidTagVector rfid_tag_pure_
Thermal sources in the environment.
void spinThread()
std::map< QString, CGuiThermalSource >::iterator ThermalSourcesIterator
Number of input arguments.
CGuiConnector gui_connector_
Object of CInfoConnector.
void laserVisualizerClicked(QString robotName, QString laserName)
Informs CGuiController that a laser visualizer has been clicked. Connects to the CInfoConnector::lase...
void setStatusBarMessage(QString s)
Displays a message in the QMainWindow status bar.
void loadCo2Pressed(void)
Informs CGuiController that a CO2 source is going to be placed in the environment. Connects to the CGuiConnector::loadCo2Pressed signal.
CInfoLoader loader
< Object of CInfoLoader
QPoint getGlobalPoint(QPoint p)
Returns the point in the real map image. Wrapper for a loader function.
void receiveThermalSources(const stdr_msgs::ThermalSourceVector &msg)
Receives the existent thermal sources.
CInfoConnector info_connector_
Object of CMapConnector.
tf::TransformListener listener_
The occypancy grid map.
bool deleteRobot(const std::string &name)
void waitForSoundPose(void)
Is emitted when a new sound source is going to be placed. Connects to the CMapConnector::waitForSOund...
ros::ServiceClient delete_sound_source_client_
void updateImage(QImage *img)
Emits the signalUpdateImage signal.
void co2PlaceSet(QPoint p)
Gets the point at which the new CO2 source is placed. Connects to the CMapConnector::co2PlaceSet sign...
void zoomInPressed(QPoint p)
Performs zoom in when the button is pressed. Connects to the CMapConnector::zoomInPressed signal...
void receiveSoundSources(const stdr_msgs::SoundSourceVector &msg)
Receives the existent sound sources.
std::map< QString, CGuiRfidTag >::iterator RfidTagIterator
void sonarVisibilityClicked(QString robotName, QString sonarName)
Informs CGuiController that a sonar visibility status has been clicked. Connects to the CInfoConnecto...
void receiveCO2Sources(const stdr_msgs::CO2SourceVector &msg)
Receives the existent co2 sources.
void soundPlaceSet(QPoint p)
Gets the point at which the new sound source is placed. Connects to the CMapConnector::soundPlaceSet ...
The main namespace for STDR GUI.
void loadRobotPressed(stdr_msgs::RobotMsg newRobotMsg)
Loads a robot from robot creator into map. Connects to the CGuiConnector::CRobotCreatorConnector::loa...
void setSonar(stdr_msgs::SonarSensorMsg msg)
Sets the sonar description message.
ros::Subscriber robot_subscriber_
ROS subscriber for rfids.
void cleanupVisualizers(const stdr_msgs::RobotIndexedVectorMsg &msg)
Dumps all visualizers that connect to robots not existent in the input argument message.
void updateMapInternal(void)
Updates the map to be shown in GUI. Connects to the timeout signal of timer_.
stdr_msgs::RobotIndexedVectorMsg all_robots_
Timer for the drawing event.
void setNewRobot(stdr_msgs::RobotMsg msg)
Sets the created robot.
bool map_lock_
Prevents actions before map initializes.
std::map< QString, CGuiCo2Source > co2_sources_
Sound sources in the environment.
std::set< std::string > my_robots_
Laser visualizers.
bool init()
Initializes the ROS spin and Qt threads.
CGuiController(int argc, char **argv)
Default contructor.
std::string robot_following_
Service client for inserting a new rfid tag.
void setInitialPose(float x, float y)
Sets the robot&#39;s initial pose.
ros::Subscriber map_subscriber_
ROS subscriber to get all robots.
stdr_msgs::CO2SourceVector co2_source_pure_
CO2 sources in the environment.
std::vector< CGuiRobot > registered_robots_
Robots created from the specific GUI instance.
std::map< QString, CGuiThermalSource > thermal_sources_
The original vector.
void setupWidgets(void)
Sets up the main window widgets.
void robotPlaceSet(QPoint p)
Gets the point at which the new robot is placed. Connects to the CMapConnector::robotPlaceSet signal...
ros::ServiceClient new_rfid_tag_client_
Service client for deleting a rfid tag.
QPoint mapToGlobal(QPoint p)
Calls the Qt function that gets the real point that the event happened.
void setRobotVisibility(QString robotName, char vs)
Is emitted when a robot&#39;s visibility status is going to be changed. Connects to the CInfoConnector::s...
void setSonarVisibility(QString robotName, QString sonarName, char vs)
Is emitted when a sonar&#39;s visibility status is going to be changed. Connects to the CInfoConnector::s...
bool moveRobot(const std::string &name, const geometry_msgs::Pose2D newPose)
stdr_msgs::ThermalSourceVector thermal_source_pure_
CO2 sources in the environment.
void uncheckZoomButtons(void)
Unchecks the zoom in & out buttons when right click in map is pushed.
void co2SensorVisibilityClicked(QString robotName, QString co2SensorName)
Informs CGuiController that a CO2Sensor visibility status has \ been clicked. Connects to the CInfoCo...
void spinThreadFunction(void)
Thread that performs the ros::spin functionality.
stdr_msgs::SonarSensorMsg getSonarDescription(QString robotName, QString sonarName)
Returns a stdr_msgs::SonarSensorMsg message from robot and sonar name.
void itemClicked(QPoint p, Qt::MouseButton b)
Informs CGuiController that click has performed in the map. Connects to the CMapConnector::itemClicke...
void robotVisibilityClicked(QString robotName)
Informs CGuiController that a robot visibility status has been clicked. Connects to the CInfoConnecto...
ros::ServiceClient new_co2_source_client_
Service client for deleting a co2 source.
void setDegrees(float degrees)
Sets the tag message.
bool isGridEnabled(void)
Returns the grid enabled state.
std::map< QString, CGuiCo2Source >::iterator Co2SourcesIterator
std::map< QString, CGuiRfidTag > rfid_tags_
The original rfid vector.
bool map_initialized_
All the robots server has.
void soundSensorVisibilityClicked(QString robotName, QString soundSensorName)
Informs CGuiController that a sound Sensor visibility status has \ been clicked. Connects to the CInf...
ros::Subscriber thermal_sources_subscriber_
ROS subscriber for sound sources.


stdr_gui
Author(s): Manos Tsardoulias
autogenerated on Mon Jun 10 2019 15:15:16