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 <aspect/blackboard.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/clock.h>
29 #include <aspect/configurable.h>
30 #include <aspect/logging.h>
31 #include <core/threading/thread.h>
32 
33 #include <string>
34 #include <vector>
35 
36 class RobotinoComThread;
37 class RobotinoActThread;
38 
39 namespace fawkes {
40 class BatteryInterface;
41 class RobotinoSensorInterface;
42 class IMUInterface;
43 } // namespace fawkes
44 
47  public fawkes::LoggingAspect,
48  public fawkes::ClockAspect,
51 {
52  friend RobotinoActThread;
53 
54 public:
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:
63  virtual void
64  run()
65  {
66  Thread::run();
67  }
68 
69 private: // methods
70  void process_sensor_msgs();
71  void update_distances(float *voltages);
72 
73  // Voltage to distance data points
74  static const std::vector<std::pair<double, double>> voltage_to_dist_dps_;
75 
76 private: // members
77  RobotinoComThread *com_;
78 
79  bool cfg_enable_gyro_;
80  std::string cfg_imu_iface_id_;
81 
82  fawkes::BatteryInterface * batt_if_;
84  fawkes::IMUInterface * imu_if_;
85 };
86 
87 #endif
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: sensor_thread.h:64
Thread aspect to access to BlackBoard.
Definition: blackboard.h:33
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:33
RobotinoSensorThread(RobotinoComThread *com_thread)
Constructor.
Fawkes library namespace.
virtual void finalize()
Finalize the thread.
BatteryInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
Definition: thread.h:45
RobotinoSensorInterface Fawkes BlackBoard Interface.
Thread aspect to use blocked timing.
virtual void init()
Initialize the thread.
Robotino act hook integration thread.
Definition: act_thread.h:48
Virtual base class for thread that communicates with a Robotino.
Definition: com_thread.h:38
Thread aspect to log output.
Definition: logging.h:32
Robotino sensor hook integration thread.
Definition: sensor_thread.h:45
Thread aspect to access configuration data.
Definition: configurable.h:32
IMUInterface Fawkes BlackBoard Interface.
Definition: IMUInterface.h:33
virtual void loop()
Code to execute in the thread.