$search
00001 00002 /*************************************************************************** 00003 * presenter.cpp - ROS slide presenter 00004 * 00005 * Created: Fri Sep 3 10:39:50 2010 00006 * Copyright 2010 Tim Niemueller [www.niemueller.de] 00007 * 2010 Carnegie Mellon University 00008 * 2010 Intel Labs Pittsburgh, Intel Research 00009 * 00010 ****************************************************************************/ 00011 00012 /* This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU Library General Public License for more details. 00021 * 00022 * Read the full text in the LICENSE.GPL file in the doc directory. 00023 */ 00024 00025 #include "xpdfctrl.h" 00026 00027 #include <ros/ros.h> 00028 #include <std_srvs/Empty.h> 00029 #include <presenter/GotoPage.h> 00030 #include <presenter/Load.h> 00031 00032 00036 class Presenter 00037 { 00038 public: 00040 Presenter() 00041 : __xpdfctrl("ROS_XPDF") 00042 { 00043 std::string name = ros::this_node::getName(); 00044 __srv_load = __node_handle.advertiseService(name + "/load", &Presenter::load, this); 00045 __srv_next_page = __node_handle.advertiseService(name + "/page/next", &Presenter::next_page, this); 00046 __srv_prev_page = __node_handle.advertiseService(name + "/page/prev", &Presenter::prev_page, this); 00047 __srv_goto_page = __node_handle.advertiseService(name + "/page/goto", &Presenter::goto_page, this); 00048 __srv_hide = __node_handle.advertiseService(name + "/hide", &Presenter::hide, this); 00049 } 00050 00051 // Service callbacks 00052 00053 bool next_page(std_srvs::Empty::Request &req, 00054 std_srvs::Empty::Response &resp) 00055 { 00056 __xpdfctrl.next_page(); 00057 return true; 00058 } 00059 00060 bool prev_page(std_srvs::Empty::Request &req, 00061 std_srvs::Empty::Response &resp) 00062 { 00063 __xpdfctrl.prev_page(); 00064 return true; 00065 } 00066 00067 bool hide(std_srvs::Empty::Request &req, 00068 std_srvs::Empty::Response &resp) 00069 { 00070 __xpdfctrl.hide(); 00071 return true; 00072 } 00073 00074 bool goto_page(presenter::GotoPage::Request &req, 00075 presenter::GotoPage::Response &resp) 00076 { 00077 __xpdfctrl.goto_page(req.page); 00078 return true; 00079 } 00080 00081 bool load(presenter::Load::Request &req, 00082 presenter::Load::Response &resp) 00083 { 00084 // check file name 00085 std::string filename = req.filename; 00086 __xpdfctrl.load_file(filename.c_str()); 00087 return true; 00088 } 00089 00090 private: 00091 ros::NodeHandle __node_handle; 00092 ros::ServiceServer __srv_load; 00093 ros::ServiceServer __srv_next_page; 00094 ros::ServiceServer __srv_prev_page; 00095 ros::ServiceServer __srv_hide; 00096 ros::ServiceServer __srv_goto_page; 00097 00098 XpdfControl __xpdfctrl; 00099 }; 00100 00101 int 00102 main(int argc, char **argv) 00103 { 00104 ros::init(argc, argv, "presenter"); 00105 Presenter presenter; 00106 ros::spin(); 00107 return 0; 00108 }