48 out <<
CPose3D(m_readings[i].eNosePoseOnTheRobot);
49 out << m_readings[i].readingsVoltage;
50 out << m_readings[i].sensorTypes;
51 out << m_readings[i].hasTemperature;
52 if (m_readings[i].hasTemperature)
53 out << m_readings[i].temperature;
85 in >> aux; m_readings[i].eNosePoseOnTheRobot = aux;
86 in >> m_readings[i].readingsVoltage;
87 in >> m_readings[i].sensorTypes;
90 in >> m_readings[i].hasTemperature;
91 if (m_readings[i].hasTemperature)
92 in >> m_readings[i].temperature;
96 m_readings[i].hasTemperature=
false;
97 m_readings[i].temperature=0;
103 else sensorLabel =
"";
136 m_readings.push_back(eNose);
148 m_readings.push_back(eNose);
164 if (!m_readings.empty())
165 out_sensorPose =
CPose3D(m_readings[0].eNosePoseOnTheRobot);
166 else out_sensorPose =
CPose3D(0,0,0);
174 size_t i,
n = m_readings.size();
206 first_iteration(true)
225 if ( decimate_count != decimate_value ){
231 inverse_MOSmodeling( m_antiNoise_window[winNoise_size/2].reading_filtered, m_antiNoise_window[winNoise_size/2].
timestamp);
235 reading = last_Obs.estimation;
240 save_log_map(last_Obs.timestamp, last_Obs.reading, last_Obs.estimation, last_Obs.tau );
245 cout <<
"Error when decimating \n" ;
258 temporal_Obs.reading = reading;
262 if ( m_antiNoise_window.empty() )
265 temporal_Obs.reading_filtered = reading;
268 m_antiNoise_window.assign( winNoise_size, temporal_Obs );
272 m_antiNoise_window.erase( m_antiNoise_window.begin() );
273 m_antiNoise_window.push_back(temporal_Obs);
277 float partial_sum = 0;
278 for (
size_t i=0; i<m_antiNoise_window.size(); i++)
279 partial_sum += m_antiNoise_window.at(i).reading;
281 m_antiNoise_window.at(winNoise_size/2).reading_filtered = partial_sum / winNoise_size;
284 cout <<
"Error when filtering noise from readings \n" ;
299 if (reading < min_reading)
300 min_reading = reading;
303 if ( !first_iteration)
308 if ( (incT >0) & (!first_incT) ){
313 if (fabs(incT - fixed_incT) > (
double)(0.05))
314 cout <<
"IncT is not constant by HW." << endl;
324 if ( reading < last_Obs.reading )
326 last_Obs.tau = a_decay * abs(reading-min_reading) + b_decay;
330 last_Obs.tau = a_rise * abs(reading-min_reading) + b_rise;
336 last_Obs.estimation = ( (reading -last_Obs.reading)*last_Obs.tau/incT) + reading;
338 last_Obs.estimation = reading;
343 last_Obs.reading = reading;
347 last_Obs.tau = b_rise;
348 last_Obs.reading = reading;
350 last_Obs.estimation = reading;
351 first_iteration =
false;
356 cerr <<
"**Exception in CObservationGasSensors::CMOSmodel::inverse_MOSmodeling** " << e.what() << endl;
365 const float &reading,
366 const float &estimation,
378 m_debug_dump =
new ofstream(
buffer);
380 if (m_debug_dump->is_open())
382 *m_debug_dump <<
format(
"%f \t", time );
383 *m_debug_dump <<
format(
"%f \t", reading );
384 *m_debug_dump <<
format(
"%f \t", estimation );
385 *m_debug_dump <<
format(
"%f \t", tau );
386 *m_debug_dump <<
"\n";
388 else cout <<
"Unable to open file";
398 o <<
format(
"e-nose #%u:\n",(
unsigned)j);
406 o <<
format(
"%04X: %.03f ", *itKind, *it);
410 o <<
format(
" Sensor pose on robot: (x,y,z)=(%.02f,%.02f,%.02f)\n",
415 o <<
"Measured temperature: ";
419 o <<
"NOT AVAILABLE\n";
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void noise_filtering(const float &reading, const mrpt::system::TTimeStamp ×tamp)
Reduce noise by averaging with a mobile window of specific size (winNoise_size)
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void BASE_IMPEXP pause(const std::string &msg=std::string("Press any key to continue...")) MRPT_NO_THROWS
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
vector_int sensorTypes
The kind of sensors in the array (size of "sensorTypes" is the same that the size of "readingsVoltage...
The structure for each e-nose.
const Scalar * const_iterator
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
This base provides a set of functions for maths stuff.
math::TPose3D eNosePoseOnTheRobot
The pose of the sensors on the robot.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This namespace contains representation of robot actions and observations.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void getDescriptionAsText(std::ostream &o) const MRPT_OVERRIDE
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp. Where available, this should contain the accurate satellite-based time...
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const MRPT_OVERRIDE
A general method to retrieve the sensor pose on the robot.
void save_log_map(const mrpt::system::TTimeStamp ×tamp, const float &reading, const float &estimation, const float &tau)
Save the gas distribution estiamtion into a log file for offline representation.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Declares a class that represents any robot's observation.
std::vector< TObservationENose > m_readings
One entry per e-nose on the robot.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
void inverse_MOSmodeling(const float &reading, const mrpt::system::TTimeStamp ×tamp)
Estimates the gas concentration based on readings and sensor model.
int BASE_IMPEXP sprintf(char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
double BASE_IMPEXP timeDifference(const mrpt::system::TTimeStamp t_first, const mrpt::system::TTimeStamp t_later)
Returns the time difference from t1 to t2 (positive if t2 is posterior to t1), in seconds...
std::vector< float > readingsVoltage
The set of readings (in volts) from the array of sensors (size of "sensorTypes" is the same that the ...
unsigned __int32 uint32_t
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) MRPT_OVERRIDE
A general method to change the sensor pose on the robot.
double BASE_IMPEXP timestampTotime_t(const mrpt::system::TTimeStamp t)
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
bool get_GasDistribution_estimation(float &reading, mrpt::system::TTimeStamp ×tamp)
Obtain an estimation of the gas distribution based on raw sensor readings.