Ejemplo n.º 1
0
void QtROS::run(){ 
  ros::Rate r(30);
  while(ros::ok() && !quitfromgui) {
    ros::spinOnce(); 
    r.sleep();}
  if (!quitfromgui) {
    emit rosQuits();
    ROS_INFO("ROS-Node Terminated\n"); }}
Ejemplo n.º 2
0
void QtROS::run(){ 
  ros::Rate r(30); // 30 hz. Kinect has 30hz and we are far from processing every frame anyhow.
  while(ros::ok() && !quitfromgui) {
    ros::spinOnce(); 
    r.sleep();}
  if (!quitfromgui) {
    Q_EMIT rosQuits();
    ROS_INFO("ROS-Node Terminated\n"); 
    ros::shutdown();//Not sure if necessary
  }
}
Ejemplo n.º 3
0
void RosComunication::run()
{
	ros::Rate rate(15);
	while (ros::ok() && !hasToQuit)
	{
		ros::spinOnce();
		rate.sleep();
	}
	if (!hasToQuit)
	{
		emit rosQuits();
	}
}
Ejemplo n.º 4
0
/** On program startup:
 * Create 
 * - a Qt Application 
 * - an Object representing the ROS Node and its callback loop, 
 * - an OpenNIListener, setting up subscribers and callbacks for various formats of RGBD data
 * - a GraphManager, getting Nodes constructed from the RGBD data
 * - A Class providing a service call interface for ROS
 * - If applicable also a GUI
 * - let the above communicate internally via QT Signals, where communcication needs to be across threads or if the communication is conditional on the ROS node's parameterization.
 */
int main(int argc, char** argv)
{
  setlocale(LC_NUMERIC,"C");//Avoid expecting german decimal separators in launch files

  //create thread object, to run the ros event processing loop in parallel to the qt loop
  QtROS qtRos(argc, argv, "rgbdslam"); //ros node name & namespace

  //Depending an use_gui on the Parameter Server, a gui- or a headless application is used
  QApplication app(argc, argv, ParameterServer::instance()->get<bool>("use_gui")); 

  GraphManager graph_mgr;
  //Instantiate the kinect image listener
  OpenNIListener listener(&graph_mgr);
  std::string bagfile_name = ParameterServer::instance()->get<std::string>("bagfile_name");
  if(!bagfile_name.empty()) 
  {
    QObject::connect(&listener, SIGNAL(bagFinished()), &app, SLOT(quit()));
    QObject::connect(&listener, SIGNAL(bagFinished()), &qtRos, SLOT(quitNow()));
    QtConcurrent::run(&listener, &OpenNIListener::loadBag, bagfile_name);
  }

  Graphical_UI* gui = NULL;
	if (app.type() == QApplication::GuiClient){
      gui = new Graphical_UI();
      gui->show();
      gui_connections(gui, &graph_mgr, &listener);
      ui_connections(gui, &graph_mgr, &listener);//common connections for the user interfaces
  } else {
      ROS_WARN("Running without graphical user interface! See README or wiki page for how to interact with RGBDSLAM.");
  }
  //Create Ros service interface with or without gui
  RosUi ui("rgbdslam"); //ui namespace for service calls
  ui_connections(&ui, &graph_mgr, &listener);//common connections for the user interfaces

  //If one thread receives a exit signal from the user, signal the other thread to quit too
  QObject::connect(&app, SIGNAL(aboutToQuit()), &qtRos, SLOT(quitNow()));
  QObject::connect(&qtRos, SIGNAL(rosQuits()), &app, SLOT(quit()));

  qtRos.start();// Run main loop.
  app.exec();
  //if(ros::ok()) ros::shutdown();//If not yet done through the qt connection
  //ros::waitForShutdown(); //not sure if necessary. 
}