Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * sensor_thread.h - Robotino sensor thread 00004 * 00005 * Created: Sun Nov 13 15:33:04 2011 00006 * Copyright 2011-2012 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __PLUGINS_ROBOTINO_SENSOR_THREAD_H_ 00024 #define __PLUGINS_ROBOTINO_SENSOR_THREAD_H_ 00025 00026 #include <core/threading/thread.h> 00027 #include <aspect/blocked_timing.h> 00028 #include <aspect/logging.h> 00029 #include <aspect/configurable.h> 00030 #include <aspect/blackboard.h> 00031 00032 #include <string> 00033 #include <vector> 00034 00035 #define NUM_IR_SENSORS 9 00036 00037 namespace rec { 00038 namespace robotino { 00039 namespace com { 00040 class Com; 00041 } 00042 } 00043 namespace sharedmemory { 00044 template<typename SharedType> class SharedMemory; 00045 } 00046 namespace iocontrol { 00047 namespace robotstate { 00048 class State; 00049 } 00050 } 00051 } 00052 00053 namespace fawkes { 00054 class BatteryInterface; 00055 class RobotinoSensorInterface; 00056 } 00057 00058 class RobotinoSensorThread 00059 : public fawkes::Thread, 00060 public fawkes::BlockedTimingAspect, 00061 public fawkes::LoggingAspect, 00062 public fawkes::ConfigurableAspect, 00063 public fawkes::BlackBoardAspect 00064 { 00065 friend class RobotinoActThread; 00066 public: 00067 RobotinoSensorThread(); 00068 00069 virtual void init(); 00070 virtual void loop(); 00071 virtual void finalize(); 00072 00073 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */ 00074 protected: virtual void run() { Thread::run(); } 00075 00076 private: // methods 00077 void update_distances(float *distances); 00078 00079 private: // members 00080 std::string cfg_hostname_; 00081 bool cfg_quit_on_disconnect_; 00082 rec::robotino::com::Com *com_; 00083 unsigned int last_seqnum_; 00084 rec::sharedmemory::SharedMemory<rec::iocontrol::robotstate::State> *statemem_; 00085 rec::iocontrol::robotstate::State *state_; 00086 00087 fawkes::BatteryInterface *batt_if_; 00088 fawkes::RobotinoSensorInterface *sens_if_; 00089 00090 // Voltage to distance data points 00091 std::vector<std::pair<double, double> > voltage_to_dist_dps_; 00092 }; 00093 00094 00095 #endif