Go to the documentation of this file.00001
00012 #ifndef HARDWARE_SENSOR_EXTERNALLOC_HPP_
00013 #define HARDWARE_SENSOR_EXTERNALLOC_HPP_
00014
00015 #include <stdlib.h>
00016 #include <unistd.h>
00017
00018 #include <jafarConfig.h>
00019 #include "kernel/jafarMacro.hpp"
00020 #include "rtslam/hardwareSensorAbstract.hpp"
00021
00022 #ifdef HAVE_POSTERLIB
00023 #include "posterLib.h"
00024 #endif
00025
00026
00027 namespace jafar {
00028 namespace rtslam {
00029 namespace hardware {
00030
00031
00040 enum ExtLocType { elCameraBundle = 0, elCameraFullPose, elNExtLocType };
00041 inline size_t ExtLocSizes(ExtLocType t)
00042 {
00043 static size_t ExtLocSizes[elNExtLocType] = { 67, 98 };
00044 return ExtLocSizes[t];
00045 }
00046 struct ExtLoc
00047 {
00048 double date;
00049 ExtLocType type;
00050 double meta_x[15];
00051 double meta_P[15];
00052 double obs_x[14];
00053 double obs_P[56];
00054 };
00055
00056
00057 class HardwareSensorExternalLoc: public HardwareSensorProprioAbstract
00058 {
00059 private:
00060 boost::thread *preloadTask_thread;
00061 void preloadTask(void);
00062 void dropline(std::fstream & file) const
00063 {
00064 std::string line;
00065 std::getline(file,line);
00066 }
00067 bool readline(std::fstream & file, jblas::vec & v) const
00068 {
00069 std::string line;
00070 std::getline(file,line);
00071 std::istringstream iss(line);
00072 unsigned i = 0;
00073 char tmpc;
00074 double tmpd;
00075 bool finished = true;
00076 for(i = 0; ; ++i)
00077 {
00078 iss >> tmpd >> tmpc;
00079 if (!checkStream(iss, "HardwareSensorExternalLoc")) { finished = false; break; }
00080 if (iss.eof()) break; else
00081 {
00082 if (i >= v.size()) v.resize(i+1);
00083 v(i) = tmpd;
00084 }
00085 }
00086 if (finished && i != v.size()) v.resize(i);
00087 if (!finished) readline(file, v);
00088 return file.eof();
00089
00090
00091
00092
00093
00094 }
00095 void fillReading(jblas::vec const & datavec);
00096
00097 #ifdef HAVE_POSTERLIB
00098 POSTER_ID posterId;
00099 #endif
00100 ExtLocType data_type;
00101 int source;
00102 std::string dump_path;
00103 double last_timestamp;
00104 kernel::LoggerTask *loggerTask;
00105 std::fstream f;
00106
00107 public:
00108 HardwareSensorExternalLoc(kernel::VariableCondition<int> *condition, unsigned bufferSize, ExtLocType data_type, int source, Mode mode = mOnline, std::string dump_path = ".", kernel::LoggerTask *loggerTask = NULL);
00109
00110 virtual void start();
00111 virtual void stop();
00112 virtual bool join(int timed_ms = -1);
00113 virtual double getLastTimestamp() { boost::unique_lock<boost::mutex> l(mutex_data); return last_timestamp; }
00114
00115 jblas::ind_array instantValues() { return jmath::ublasExtra::ia_set(1,6); }
00116 jblas::ind_array incrementValues() { return jmath::ublasExtra::ia_set(1,1); }
00122 void loadACTION(std::string config_file, std::string state_file, std::string detect_file, std::string uncert_filename);
00123
00124 };
00125
00126
00127 }}}
00128
00129 #endif // HARDWARE_SENSOR_GPSGENOM_HPP_