Fawkes API  Fawkes Development Version
filter_thread.h
1 
2 /***************************************************************************
3  * filter_thread.h - Thread to filter laser data
4  *
5  * Created: Sun Mar 13 01:11:11 2011
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_LASER_FILTER_FILTER_THREAD_H_
24 #define __PLUGINS_LASER_FILTER_FILTER_THREAD_H_
25 
26 #include "filters/filter.h"
27 
28 #include <core/threading/thread.h>
29 #include <aspect/blocked_timing.h>
30 #include <aspect/logging.h>
31 #include <aspect/configurable.h>
32 #include <aspect/blackboard.h>
33 #ifdef HAVE_TF
34 # include <aspect/tf.h>
35 #endif
36 
37 #include <string>
38 #include <list>
39 #include <vector>
40 
41 namespace fawkes {
42  class Laser360Interface;
43  class Laser720Interface;
44  class Laser1080Interface;
45 }
46 
48 : public fawkes::Thread,
50  public fawkes::LoggingAspect,
52 #ifdef HAVE_TF
54 #endif
56 {
57  public:
58  LaserFilterThread(std::string &cfg_name, std::string &cfg_prefix);
59 
60  virtual void init();
61  virtual void finalize();
62  virtual void loop();
63 
64  void wait_done();
65 
66  void set_wait_threads(std::list<LaserFilterThread *> &threads);
67  void set_wait_barrier(fawkes::Barrier *barrier);
68 
69  private:
70  /// @cond INTERNALS
71  typedef struct {
72  std::string id;
73  unsigned int size;
74  union {
78  } interface_typed;
79  fawkes::Interface *interface;
80  } LaserInterface;
81  /// @endcond
82 
83  void open_interfaces(std::string prefix, std::vector<LaserInterface> &ifs,
84  std::vector<LaserDataFilter::Buffer *> &bufs, bool writing);
85 
86  LaserDataFilter * create_filter(std::string filter_name,
87  std::string filter_type, std::string prefix,
88  unsigned int in_data_size,
89  std::vector<LaserDataFilter::Buffer *> &inbufs);
90 
91 
92  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
93  protected: virtual void run() { Thread::run(); }
94 
95  private:
96  std::vector<LaserInterface> __in;
97  std::vector<LaserInterface> __out;
98 
99  std::vector<LaserDataFilter::Buffer *> __in_bufs;
100  std::vector<LaserDataFilter::Buffer *> __out_bufs;
101 
102  LaserDataFilter *__filter;
103 
104  std::string __cfg_name;
105  std::string __cfg_prefix;
106 
107  std::list<LaserFilterThread *> __wait_threads;
108  bool __wait_done;
109  fawkes::Mutex *__wait_mutex;
110  fawkes::WaitCondition *__wait_cond;
111  fawkes::Barrier *__wait_barrier;
112 };
113 
114 
115 #endif
Laser360Interface Fawkes BlackBoard Interface.
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: filter_thread.h:93
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Wait until a given condition holds.
Laser1080Interface Fawkes BlackBoard Interface.
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
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
Thread aspect to access the transform system.
Definition: tf.h:42
Thread aspect to use blocked timing.
Thread aspect to log output.
Definition: logging.h:35
Laser filter thread.
Definition: filter_thread.h:47
Thread aspect to access configuration data.
Definition: configurable.h:35
Mutex mutual exclusion lock.
Definition: mutex.h:32
Laser720Interface Fawkes BlackBoard Interface.
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...
Definition: barrier.h:32
Laser data filter.
Definition: filter.h:32