Fawkes API  Fawkes Development Version
rospub_thread.h
1 /***************************************************************************
2  * navgraph_rospub_thread.h - Publish navgraph to ROS
3  *
4  * Created: Wed Jun 08 20:16:31 2016
5  * Copyright 2016 Tim Niemueller [www.niemueller.de]
6  ****************************************************************************/
7 
8 /* This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Library General Public License for more details.
17  *
18  * Read the full text in the LICENSE.GPL file in the doc directory.
19  */
20 
21 #ifndef _PLUGINS_NAVGRAPH_NAVGRAPH_ROSPUB_THREAD_H_
22 #define _PLUGINS_NAVGRAPH_NAVGRAPH_ROSPUB_THREAD_H_
23 
24 #include <aspect/clock.h>
25 #include <aspect/configurable.h>
26 #include <aspect/logging.h>
27 #include <aspect/tf.h>
28 #include <core/threading/thread.h>
29 #include <fawkes_msgs/NavGraphGetPairwiseCosts.h>
30 #include <fawkes_msgs/NavGraphSearchPath.h>
31 #include <navgraph/aspect/navgraph.h>
32 #include <navgraph/navgraph.h>
33 #include <plugins/ros/aspect/ros.h>
34 #include <ros/publisher.h>
35 #include <ros/service_server.h>
36 
38  public fawkes::ClockAspect,
39  public fawkes::LoggingAspect,
42  public fawkes::ROSAspect,
45 {
46 public:
48  virtual ~NavGraphROSPubThread();
49 
50  virtual void init();
51  virtual void loop();
52  virtual void finalize();
53 
54  virtual void graph_changed() throw();
55 
56  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
57 protected:
58  virtual void
59  run()
60  {
61  Thread::run();
62  }
63 
64 private:
65  void publish_graph();
66  void convert_nodes(const std::vector<fawkes::NavGraphNode> &nodes,
67  std::vector<fawkes_msgs::NavGraphNode> & out);
68 
69  bool svs_search_path_cb(fawkes_msgs::NavGraphSearchPath::Request & req,
70  fawkes_msgs::NavGraphSearchPath::Response &res);
71  bool svs_get_pwcosts_cb(fawkes_msgs::NavGraphGetPairwiseCosts::Request & req,
72  fawkes_msgs::NavGraphGetPairwiseCosts::Response &res);
73 
74 private:
75  std::string cfg_base_frame_;
76  std::string cfg_global_frame_;
77 
78  ros::Publisher pub_;
79  ros::ServiceServer svs_search_path_;
80  ros::ServiceServer svs_get_pwcosts_;
81 };
82 
83 #endif
Publish navgaraph to ROS.
Definition: rospub_thread.h:45
NavGraphROSPubThread()
Constructor.
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: rospub_thread.h:59
virtual void init()
Initialize the thread.
virtual ~NavGraphROSPubThread()
Destructor.
virtual void graph_changed()
Function called if the graph has been changed.
virtual void loop()
Code to execute in the thread.
virtual void finalize()
Finalize the thread.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
Thread aspect to access NavGraph.
Definition: navgraph.h:36
Topological graph change listener.
Definition: navgraph.h:179
Thread aspect to get access to a ROS node handle.
Definition: ros.h:39
Thread class encapsulation of pthreads.
Definition: thread.h:46
Thread aspect to access the transform system.
Definition: tf.h:39