QtRosNode.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  TalkingHead - A talking head for robots
00003  *  Copyright (C) 2012 AG Aktives Sehen <agas@uni-koblenz.de>
00004  *                     Universitaet Koblenz-Landau
00005  *
00006  *  This program is free software: you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation, either version 3 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00019  *  MA 02110-1301  USA or see <http://www.gnu.org/licenses/>.
00020  *******************************************************************************/
00021 
00022 #include "MainWindow.h"
00023 #include "QtRosNode.h"
00024 
00025 QtRosNode::QtRosNode(int argc, char *argv[], const char* node_name, MainWindow* main_window, QApplication* app)
00026 {
00027   ros::init(argc, argv, node_name);
00028 
00029   node_handle_ = new ros::NodeHandle;
00030   main_window_ = main_window;
00031   application_ = app;
00032 
00033   quit_from_gui = false;
00034 }
00035 
00036 void QtRosNode::quitNow()
00037 {
00038   quit_from_gui = true;
00039 }
00040 
00041 void QtRosNode::run()
00042 {
00043     ros::Rate loop_rate(10);
00044 
00045     while (ros::ok() && !quit_from_gui)
00046     {
00047 
00048       main_window_->updateGeometry();
00049 
00050       ros::spinOnce();
00051       loop_rate.sleep();
00052     }
00053 
00054   if (!ros::ok())
00055   {
00056     application_->exit();
00057     emit rosQuits();
00058     ROS_INFO("ROS-Node Terminated\n");
00059   }
00060 }


robot_face
Author(s): AGAS, Julian Giesen, David Gossow
autogenerated on Mon Oct 6 2014 04:10:26