33 m_sensorLabel =
"RAE_PID";
40 void CRaePID::loadConfig_sensorSpecific(
44 #ifdef MRPT_OS_WINDOWS 45 com_port = configSource.
read_string(iniSection,
"COM_port_PID",
"COM1",
true ) ;
47 com_port = configSource.
read_string(iniSection,
"COM_port_PID",
"/dev/tty0",
true );
50 com_bauds = configSource.
read_int( iniSection,
"baudRate",9600,
false );
52 pose_x = configSource.
read_float(iniSection,
"pose_x",0,
true);
53 pose_y = configSource.
read_float(iniSection,
"pose_y",0,
true);
54 pose_z = configSource.
read_float(iniSection,
"pose_z",0,
true);
55 pose_roll = configSource.
read_float(iniSection,
"pose_roll",0,
true);
56 pose_pitch = configSource.
read_float(iniSection,
"pose_pitch",0,
true);
57 pose_yaw = configSource.
read_float(iniSection,
"pose_yaw",0,
true);
64 bool CRaePID::tryToOpenTheCOM()
69 if (m_verbose) cout <<
"[CRaePID] Opening " << com_port <<
" @ " <<com_bauds << endl;
75 COM.setConfig( com_bauds, 0, 8, 1 );
77 COM.setTimeouts(50,1,100, 1,20);
84 catch (std::exception &e)
86 std::cerr <<
"[CRaePID::tryToOpenTheCOM] Error opening or configuring the serial port:" << std::endl << e.what();
92 std::cerr <<
"[CRaePID::tryToOpenTheCOM] Error opening or configuring the serial port." << std::endl;
101 void CRaePID::doProcess()
104 if (!tryToOpenTheCOM())
110 bool have_reading =
false;
112 bool time_out =
false;
114 while (!have_reading)
121 power_reading = COM.ReadString(500,&time_out);
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);
175 return COM.ReadString();
186 return COM.ReadString();
196 return COM.ReadString();
200 bool CRaePID::switchPower()
208 reading = COM.ReadString();
210 if (strcmp(reading.c_str(),
"Sleep...")==0)
224 reading = COM.ReadString();
228 std::stringstream readings_str(reading);
231 std::istream_iterator<std::string> it(readings_str);
232 std::istream_iterator<std::string> endit;
233 std::vector<std::string> measurements_text(it, endit);
239 for (
size_t k=0; k < measurements_text.size(); k++)
241 const float readnum = atof(measurements_text[k].c_str());
242 const float val_ppm = readnum/1000.f;
264 reading = COM.ReadString();
268 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) && (strcmp(errors_text[1].c_str(),
"0")==0))
283 errorString = reading;
288 void CRaePID::getLimits(
float &
min,
float &max)
296 reading = COM.ReadString();
300 std::stringstream readings_str(reading);
303 std::istream_iterator<std::string> it(readings_str);
304 std::istream_iterator<std::string> endit;
305 std::vector<std::string> readings_text(it, endit);
308 max = atof(readings_text[0].c_str());
309 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
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time...
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. Where available, this should contain the accurate satellite-based time...
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 ...