Fawkes API  Fawkes Development Version
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 <aspect/blocked_timing.h>
26 #include <aspect/clock.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <core/threading/mutex.h>
30 #include <core/threading/thread.h>
31 #include <image_transport/image_transport.h>
32 #include <plugins/ros/aspect/ros.h>
33 #include <ros/node_handle.h>
34 #include <sensor_msgs/Image.h>
35 
36 #include <list>
37 #include <queue>
38 
39 namespace firevision {
40 class SharedMemoryImageBuffer;
41 }
42 
44  public fawkes::ClockAspect,
45  public fawkes::LoggingAspect,
48  public fawkes::ROSAspect
49 {
50 public:
52  virtual ~RosImagesThread();
53 
54  virtual void init();
55  virtual void loop();
56  virtual void finalize();
57 
58  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
59 protected:
60  virtual void
61  run()
62  {
63  Thread::run();
64  }
65 
66 private:
67  void update_images();
68  void get_sets(std::set<std::string> &missing_images, std::set<std::string> &unbacked_images);
69 
70 private:
71  /// @cond INTERNALS
72  typedef struct
73  {
74  image_transport::Publisher pub;
75  sensor_msgs::Image msg;
76  fawkes::Time last_sent;
78  } PublisherInfo;
79  /// @endcond
80  std::map<std::string, PublisherInfo> pubs_;
81 
82  image_transport::ImageTransport *it_;
83  fawkes::Time * last_update_;
84  fawkes::Time * now_;
85 };
86 
87 #endif
Thread to export Fawkes images to ROS.
Definition: image_thread.h:49
virtual void init()
Initialize the thread.
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:61
virtual ~RosImagesThread()
Destructor.
RosImagesThread()
Constructor.
virtual void finalize()
Finalize the thread.
Thread aspect to use blocked timing.
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 get access to a ROS node handle.
Definition: ros.h:39
Thread class encapsulation of pthreads.
Definition: thread.h:46
A class for handling time.
Definition: time.h:93
Shared memory image buffer.
Definition: shm_image.h:184