41 for (i = 0; i <
n; i++)
43 out <<
CPose3D(m_readings[i].eNosePoseOnTheRobot);
44 out << m_readings[i].readingsVoltage;
45 out << m_readings[i].sensorTypes;
46 out << m_readings[i].hasTemperature;
47 if (m_readings[i].hasTemperature) out << m_readings[i].temperature;
50 out << sensorLabel << timestamp;
75 for (i = 0; i <
n; i++)
78 m_readings[i].eNosePoseOnTheRobot = aux;
79 in >> m_readings[i].readingsVoltage;
80 in >> m_readings[i].sensorTypes;
83 in >> m_readings[i].hasTemperature;
84 if (m_readings[i].hasTemperature)
85 in >> m_readings[i].temperature;
89 m_readings[i].hasTemperature =
false;
90 m_readings[i].temperature = 0;
116 ASSERT_(readings.size() == 16);
130 m_readings.push_back(eNose);
143 m_readings.push_back(eNose);
156 if (!m_readings.empty())
157 out_sensorPose =
CPose3D(m_readings[0].eNosePoseOnTheRobot);
159 out_sensorPose =
CPose3D(0, 0, 0);
167 size_t i,
n = m_readings.size();
169 for (i = 0; i <
n; i++)
170 m_readings[i].eNosePoseOnTheRobot =
190 m_debug_dump(nullptr),
195 first_iteration(true)
212 if (decimate_count != decimate_value)
221 m_antiNoise_window[winNoise_size / 2].reading_filtered,
222 m_antiNoise_window[winNoise_size / 2].
timestamp);
226 reading = last_Obs.estimation;
232 last_Obs.timestamp, last_Obs.reading, last_Obs.estimation,
239 cout <<
"Error when decimating \n";
254 temporal_Obs.reading = reading;
258 if (m_antiNoise_window.empty())
261 temporal_Obs.reading_filtered = reading;
264 m_antiNoise_window.assign(winNoise_size, temporal_Obs);
269 m_antiNoise_window.erase(m_antiNoise_window.begin());
270 m_antiNoise_window.push_back(temporal_Obs);
274 float partial_sum = 0;
275 for (
size_t i = 0; i < m_antiNoise_window.size(); i++)
276 partial_sum += m_antiNoise_window.at(i).reading;
278 m_antiNoise_window.at(winNoise_size / 2).reading_filtered =
279 partial_sum / winNoise_size;
283 cout <<
"Error when filtering noise from readings \n";
298 if (reading < min_reading) min_reading = reading;
301 if (!first_iteration)
308 if ((incT > 0) & (!first_incT))
314 if (fabs(incT - fixed_incT) > (
double)(0.05))
315 cout <<
"IncT is not constant by HW." << endl;
319 if (incT > 0) first_incT =
false;
323 if (reading < last_Obs.reading)
325 last_Obs.tau = a_decay * abs(reading - min_reading) + b_decay;
329 last_Obs.tau = a_rise * abs(reading - min_reading) + b_rise;
336 last_Obs.estimation =
337 ((reading - last_Obs.reading) * last_Obs.tau / incT) +
340 last_Obs.estimation = reading;
344 last_Obs.reading = reading;
349 last_Obs.tau = b_rise;
350 last_Obs.reading = reading;
352 last_Obs.estimation =
354 first_iteration =
false;
359 cerr <<
"**Exception in " 360 "CObservationGasSensors::CMOSmodel::inverse_MOSmodeling** " 370 const float& estimation,
const float& tau)
379 if (!m_debug_dump) m_debug_dump =
new ofstream(
buffer);
381 if (m_debug_dump->is_open())
383 *m_debug_dump <<
format(
"%f \t", time);
384 *m_debug_dump <<
format(
"%f \t", reading);
385 *m_debug_dump <<
format(
"%f \t", estimation);
386 *m_debug_dump <<
format(
"%f \t", tau);
387 *m_debug_dump <<
"\n";
390 cout <<
"Unable to open file";
398 for (
size_t j = 0; j <
m_readings.size(); j++)
400 o <<
format(
"e-nose #%u:\n", (
unsigned)j);
409 for (it =
m_readings[j].readingsVoltage.begin(),
411 it !=
m_readings[j].readingsVoltage.end(); it++, itKind++)
412 o <<
format(
"%04X: %.03f ", *itKind, *it);
417 " Sensor pose on robot: (x,y,z)=(%.02f,%.02f,%.02f)\n",
422 o <<
"Measured temperature: ";
426 o <<
"NOT AVAILABLE\n";
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
void noise_filtering(const float &reading, const mrpt::system::TTimeStamp ×tamp)
Reduce noise by averaging with a mobile window of specific size (winNoise_size)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
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
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
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 format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
void pause(const std::string &msg=std::string("Press any key to continue...")) noexcept
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
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.
double 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 ...
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
unsigned __int32 uint32_t
double timestampTotime_t(const mrpt::system::TTimeStamp t)
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
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.