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