Fawkes API  Fawkes Development Version
webview_thread.h
1 
2 /***************************************************************************
3  * webview_thread.h - Webview ROS integration thread
4  *
5  * Created: Fri May 06 10:46:57 2011
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_ROS_WEBVIEW_THREAD_H_
24 #define __PLUGINS_ROS_WEBVIEW_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <core/utils/lockptr.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/clock.h>
31 #include <aspect/webview.h>
32 #include <plugins/ros/aspect/ros.h>
33 
34 #include <ros/service_server.h>
35 #include <fawkes_msgs/WebviewUrlRegistration.h>
36 #include <fawkes_msgs/WebviewNavRegistration.h>
37 
38 #include <map>
39 #include <string>
40 
42 
44 : public fawkes::Thread,
45  public fawkes::LoggingAspect,
47  public fawkes::ClockAspect,
48  public fawkes::ROSAspect,
50 {
51  public:
53  virtual ~ROSWebviewThread();
54 
55  virtual void init();
56  virtual void loop();
57  virtual void finalize();
58 
59  private:
60  bool srv_register_cb(fawkes_msgs::WebviewUrlRegistration::Request &req,
61  fawkes_msgs::WebviewUrlRegistration::Response &resp);
62 
63  bool srv_unregister_cb(fawkes_msgs::WebviewUrlRegistration::Request &req,
64  fawkes_msgs::WebviewUrlRegistration::Response &resp);
65 
66  bool srv_add_nav_cb(fawkes_msgs::WebviewNavRegistration::Request &req,
67  fawkes_msgs::WebviewNavRegistration::Response &resp);
68 
69  bool srv_remove_nav_cb(fawkes_msgs::WebviewNavRegistration::Request &req,
70  fawkes_msgs::WebviewNavRegistration::Response &resp);
71 
72  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
73  protected: virtual void run() { Thread::run(); }
74 
75  private:
76  ros::ServiceServer __srv_register;
77  ros::ServiceServer __srv_unregister;
78  ros::ServiceServer __srv_add_nav;
79  ros::ServiceServer __srv_remove_nav;
80 
81  std::map<std::string, ROSWebviewRequestProcessor *> __procs;
82  std::map<std::string, std::string> __nav_entries;
83 };
84 
85 #endif
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Thread aspect to get access to a ROS node handle.
Definition: ros.h:39
ROSWebviewThread()
Constructor.
virtual void finalize()
Finalize the thread.
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual void init()
Initialize the thread.
virtual ~ROSWebviewThread()
Destructor.
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
Convert webview requests to ROS service calls.
Thread aspect to provide web pages via Webview.
Definition: webview.h:38
Provide webview to ROS.
virtual void loop()
Code to execute in the thread.