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
RobotinoSensorThread::finalize
virtual void finalize()
Finalize the thread.
Definition: sensor_thread.cpp:83
fawkes::IMUInterface
Definition: IMUInterface.h:37
RobotinoSensorThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: sensor_thread.h:63
fawkes::BlockedTimingAspect
Definition: blocked_timing.h:54
RobotinoSensorThread::init
virtual void init()
Initialize the thread.
Definition: sensor_thread.cpp:65
RobotinoSensorThread::loop
virtual void loop()
Code to execute in the thread.
Definition: sensor_thread.cpp:91
fawkes::BlackBoardAspect
Definition: blackboard.h:36
fawkes
fawkes::LoggingAspect
Definition: logging.h:36
RobotinoActThread
Definition: act_thread.h:47
fawkes::RobotinoSensorInterface
Definition: RobotinoSensorInterface.h:37
RobotinoComThread
Definition: com_thread.h:37
fawkes::BatteryInterface
Definition: BatteryInterface.h:37
RobotinoSensorThread
Definition: sensor_thread.h:44
fawkes::Thread
Definition: thread.h:44
fawkes::ConfigurableAspect
Definition: configurable.h:36
fawkes::ClockAspect
Definition: clock.h:38
RobotinoSensorThread::RobotinoSensorThread
RobotinoSensorThread(RobotinoComThread *com_thread)
Constructor.
Definition: sensor_thread.cpp:57