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
NavGraphROSPubThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: rospub_thread.h:62
fawkes::NavGraph::ChangeListener
Definition: navgraph.h:181
NavGraphROSPubThread::graph_changed
virtual void graph_changed()
Definition: rospub_thread.cpp:83
NavGraphROSPubThread::loop
virtual void loop()
Code to execute in the thread.
Definition: rospub_thread.cpp:78
NavGraphROSPubThread::NavGraphROSPubThread
NavGraphROSPubThread()
Constructor.
Definition: rospub_thread.cpp:39
fawkes::LoggingAspect
Definition: logging.h:36
NavGraphROSPubThread
Definition: rospub_thread.h:36
fawkes::TransformAspect
Definition: tf.h:41
fawkes::ROSAspect
Definition: ros.h:37
fawkes::NavGraphAspect
Definition: navgraph.h:39
NavGraphROSPubThread::init
virtual void init()
Initialize the thread.
Definition: rospub_thread.cpp:50
fawkes::Thread
Definition: thread.h:44
fawkes::ConfigurableAspect
Definition: configurable.h:36
fawkes::ClockAspect
Definition: clock.h:38
NavGraphROSPubThread::~NavGraphROSPubThread
virtual ~NavGraphROSPubThread()
Destructor.
Definition: rospub_thread.cpp:45
NavGraphROSPubThread::finalize
virtual void finalize()
Finalize the thread.
Definition: rospub_thread.cpp:69