Fawkes API  Fawkes Development Version
sensor_thread.h
1 
2 /***************************************************************************
3  * sensor_thread.h - Robotino sensor thread
4  *
5  * Created: Sun Nov 13 15:33:04 2011
6  * Copyright 2011-2012 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_ROBOTINO_SENSOR_THREAD_H_
24 #define __PLUGINS_ROBOTINO_SENSOR_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/blackboard.h>
31 
32 #include <string>
33 #include <vector>
34 
35 #define NUM_IR_SENSORS 9
36 
37 namespace rec {
38  namespace robotino {
39  namespace com {
40  class Com;
41  }
42  }
43  namespace sharedmemory {
44  template<typename SharedType> class SharedMemory;
45  }
46  namespace iocontrol {
47  namespace robotstate {
48  class State;
49  }
50  }
51 }
52 
53 namespace fawkes {
54  class BatteryInterface;
55  class RobotinoSensorInterface;
56 }
57 
59 : public fawkes::Thread,
61  public fawkes::LoggingAspect,
64 {
65  friend class RobotinoActThread;
66  public:
68 
69  virtual void init();
70  virtual void loop();
71  virtual void finalize();
72 
73  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
74  protected: virtual void run() { Thread::run(); }
75 
76  private: // methods
77  void update_distances(float *distances);
78 
79  private: // members
80  std::string cfg_hostname_;
81  bool cfg_quit_on_disconnect_;
82  rec::robotino::com::Com *com_;
83  unsigned int last_seqnum_;
85  rec::iocontrol::robotstate::State *state_;
86 
87  fawkes::BatteryInterface *batt_if_;
89 
90  // Voltage to distance data points
91  std::vector<std::pair<double, double> > voltage_to_dist_dps_;
92 };
93 
94 
95 #endif
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: sensor_thread.h:74
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Fawkes library namespace.
BatteryInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
Definition: thread.h:42
RobotinoSensorInterface Fawkes BlackBoard Interface.
Thread aspect to use blocked timing.
Robotino act hook integration thread.
Definition: act_thread.h:53
Definition: act_thread.h:38
Thread aspect to log output.
Definition: logging.h:35
Robotino sensor hook integration thread.
Definition: sensor_thread.h:58
virtual void init()
Initialize the thread.
Definition: act_thread.cpp:58
Thread aspect to access configuration data.
Definition: configurable.h:35
virtual void loop()
Code to execute in the thread.
Definition: act_thread.cpp:92
virtual void finalize()
Finalize the thread.
Definition: act_thread.cpp:76