Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
image_thread.h
1 
2 /***************************************************************************
3  * image_thread.cpp - Thread to exchange point clouds
4  *
5  * Created: Tue Apr 10 22:12:27 2012
6  * Copyright 2011-2012 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef __PLUGINS_ROS_IMAGE_THREAD_H_
23 #define __PLUGINS_ROS_IMAGE_THREAD_H_
24 
25 #include <core/threading/thread.h>
26 #include <aspect/blocked_timing.h>
27 #include <aspect/clock.h>
28 #include <aspect/configurable.h>
29 #include <aspect/logging.h>
30 #include <aspect/pointcloud.h>
31 #include <plugins/ros/aspect/ros.h>
32 #include <core/threading/mutex.h>
33 
34 #include <list>
35 #include <queue>
36 
37 #include <ros/node_handle.h>
38 #include <image_transport/image_transport.h>
39 #include <sensor_msgs/Image.h>
40 
41 namespace firevision {
42  class SharedMemoryImageBuffer;
43 }
44 
46 : public fawkes::Thread,
47  public fawkes::ClockAspect,
48  public fawkes::LoggingAspect,
51  public fawkes::ROSAspect
52 {
53  public:
55  virtual ~RosImagesThread();
56 
57  virtual void init();
58  virtual void loop();
59  virtual void finalize();
60 
61  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
62  protected: virtual void run() { Thread::run(); }
63 
64  private:
65  void update_images();
66  void get_sets(std::set<std::string> &missing_images,
67  std::set<std::string> &unbacked_images);
68 
69  private:
70  /// @cond INTERNALS
71  typedef struct {
72  image_transport::Publisher pub;
73  sensor_msgs::Image msg;
74  fawkes::Time last_sent;
76  } PublisherInfo;
77  /// @endcond
78  std::map<std::string, PublisherInfo> pubs_;
79 
80  image_transport::ImageTransport *it_;
81  fawkes::Time *last_update_;
82  fawkes::Time *now_;
83 
84 };
85 
86 #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
virtual ~RosImagesThread()
Destructor.
RosImagesThread()
Constructor.
A class for handling time.
Definition: time.h:91
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual void loop()
Code to execute in the thread.
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: image_thread.h:62
Thread aspect to use blocked timing.
virtual void init()
Initialize the thread.
virtual void finalize()
Finalize the thread.
Shared memory image buffer.
Definition: shm_image.h:135
Thread aspect to log output.
Definition: logging.h:35
Thread to export Fawkes images to ROS.
Definition: image_thread.h:45
Thread aspect to access configuration data.
Definition: configurable.h:35