Fawkes API  Fawkes Development Version
ros_thread.h
1 /***************************************************************************
2  * ros_thread.cpp - Thread to interact with ROS for amcl plugin
3  *
4  * Created: Mon Jun 22 17:46:40 2015
5  * Copyright 2012 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_AMCL_ROS_THREAD_H_
22 #define __PLUGINS_AMCL_ROS_THREAD_H_
23 
24 #ifndef HAVE_ROS
25 # error "ROS integration requires ROS support of system"
26 #endif
27 
28 #include "amcl_thread.h"
29 
30 #include "map/map.h"
31 #include "pf/pf.h"
32 
33 #include <core/threading/thread.h>
34 #include <aspect/configurable.h>
35 #include <aspect/blackboard.h>
36 #include <aspect/logging.h>
37 
38 #include <interfaces/LocalizationInterface.h>
39 
40 #include <plugins/ros/aspect/ros.h>
41 #include <ros/publisher.h>
42 #include <ros/subscriber.h>
43 #include <geometry_msgs/PoseWithCovarianceStamped.h>
44 
45 namespace fawkes {
46  class Mutex;
47 }
48 
49 class AmclThread;
50 
52 : public fawkes::Thread,
53  public fawkes::LoggingAspect,
56  public fawkes::ROSAspect
57 {
58 public:
59  AmclROSThread();
60  virtual ~AmclROSThread();
61 
62  virtual void init();
63  virtual void loop();
64  virtual void finalize();
65 
66  void publish_pose_array(const std::string &global_frame_id,
67  const pf_sample_set_t* set);
68  void publish_pose(const std::string &global_frame_id,
69  const amcl_hyp_t &amcl_hyp,
70  const double last_covariance[36]);
71  void publish_map(const std::string &global_frame_id,
72  const map_t *map);
73 
74 
75  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
76  protected: virtual void run() { Thread::run();}
77 
78  private:
79  void initial_pose_received(const geometry_msgs::PoseWithCovarianceStampedConstPtr& msg);
80 
81 private:
82  std::string cfg_pose_ifname_;
83 
85 
86  ros::Publisher pose_pub_;
87  ros::Publisher particlecloud_pub_;
88  ros::Subscriber initial_pose_sub_;
89  ros::Publisher map_pub_;
90 };
91 
92 #endif
LocalizationInterface Fawkes BlackBoard Interface.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to get access to a ROS node handle.
Definition: ros.h:39
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: ros_thread.h:76
Thread to perform Adaptive Monte Carlo Localization.
Definition: amcl_thread.h:68
Pose hypothesis.
Definition: amcl_thread.h:51
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
Thread for ROS integration of the Adaptive Monte Carlo Localization.
Definition: ros_thread.h:51