32 void CRaePID::loadConfig_sensorSpecific(
36 #ifdef MRPT_OS_WINDOWS 38 configSource.
read_string(iniSection,
"COM_port_PID",
"COM1",
true);
41 configSource.
read_string(iniSection,
"COM_port_PID",
"/dev/tty0",
true);
44 com_bauds = configSource.
read_int(iniSection,
"baudRate", 9600,
false);
46 pose_x = configSource.
read_float(iniSection,
"pose_x", 0,
true);
47 pose_y = configSource.
read_float(iniSection,
"pose_y", 0,
true);
48 pose_z = configSource.
read_float(iniSection,
"pose_z", 0,
true);
49 pose_roll = configSource.
read_float(iniSection,
"pose_roll", 0,
true);
50 pose_pitch = configSource.
read_float(iniSection,
"pose_pitch", 0,
true);
51 pose_yaw = configSource.
read_float(iniSection,
"pose_yaw", 0,
true);
57 bool CRaePID::tryToOpenTheCOM()
59 if (COM.isOpen())
return true;
62 cout <<
"[CRaePID] Opening " << com_port <<
" @ " << com_bauds << endl;
68 COM.setConfig(com_bauds, 0, 8, 1);
70 COM.setTimeouts(50, 1, 100, 1, 20);
77 catch (std::exception& e)
79 std::cerr <<
"[CRaePID::tryToOpenTheCOM] Error opening or configuring " 88 std::cerr <<
"[CRaePID::tryToOpenTheCOM] Error opening or configuring " 99 void CRaePID::doProcess()
102 if (!tryToOpenTheCOM())
108 bool have_reading =
false;
110 bool time_out =
false;
112 while (!have_reading)
119 power_reading = COM.ReadString(500, &time_out);
124 std::this_thread::sleep_for(10ms);
134 const float readnum = atof(power_reading.c_str());
135 const float val_ppm = readnum / 1000;
155 cout <<
"Firmware version: " << endl;
157 size_t B_written = COM.Write(
"F", 1);
161 bool time_out =
false;
162 std::string s_read = COM.ReadString(2000, &time_out);
163 if (time_out) s_read =
"Time_out";
174 return COM.ReadString();
184 return COM.ReadString();
194 return COM.ReadString();
197 bool CRaePID::switchPower()
205 reading = COM.ReadString();
207 if (strcmp(reading.c_str(),
"Sleep...") == 0)
221 reading = COM.ReadString();
226 std::stringstream readings_str(reading);
230 std::istream_iterator<std::string> it(readings_str);
231 std::istream_iterator<std::string> endit;
232 std::vector<std::string> measurements_text(it, endit);
238 for (
size_t k = 0; k < measurements_text.size(); k++)
240 const float readnum = atof(measurements_text[k].c_str());
241 const float val_ppm = readnum / 1000.f;
262 reading = COM.ReadString();
267 std::stringstream readings_str(reading);
271 std::istream_iterator<std::string> it(readings_str);
272 std::istream_iterator<std::string> endit;
273 std::vector<std::string> errors_text(it, endit);
276 if ((strcmp(errors_text[0].c_str(),
"0") == 0) &&
277 (strcmp(errors_text[1].c_str(),
"0") == 0))
286 errorString = reading;
291 void CRaePID::getLimits(
float&
min,
float& max)
299 reading = COM.ReadString();
304 std::stringstream readings_str(reading);
308 std::istream_iterator<std::string> it(readings_str);
309 std::istream_iterator<std::string> endit;
310 std::vector<std::string> readings_text(it, endit);
313 max = atof(readings_text[0].c_str());
314 min = atof(readings_text[1].c_str());
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
#define THROW_EXCEPTION(msg)
This class implements a driver for the RAE Systems gas PhotoIonization Detector (PID) (Tested on a Mi...
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Contains classes for various device interfaces.
vector_int sensorTypes
The kind of sensors in the array (size of "sensorTypes" is the same that the size of "readingsVoltage...
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
The structure for each e-nose.
This class allows loading and storing values and vectors of different types from a configuration text...
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
std::shared_ptr< CObservationGasSensors > Ptr
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
GLsizei const GLchar ** string
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
std::vector< TObservationENose > m_readings
One entry per e-nose on the robot.
std::vector< float > readingsVoltage
The set of readings (in volts) from the array of sensors (size of "sensorTypes" is the same that the ...