29 m_usbSerialNumber ("ENOSE002"),
33 m_stream_SERIAL (NULL)
35 m_sensorLabel =
"EnoseModular";
39 CEnoseModular::~CEnoseModular( )
48 void CEnoseModular::loadConfig_sensorSpecific(
54 m_usbSerialNumber = configSource.
read_string(iniSection,
"USB_serialname",
"",
false);
56 #ifdef MRPT_OS_WINDOWS 57 m_COM_port = configSource.
read_string(iniSection,
"COM_port_WIN",
"COM1");
59 m_COM_port = configSource.
read_string(iniSection,
"COM_port_LIN",m_COM_port);
61 m_COM_baud = configSource.
read_uint64_t(iniSection,
"COM_baudRate",m_COM_baud);
72 CStream *CEnoseModular::checkConnectionAndConnect()
75 if (!m_stream_FTDI && !m_stream_SERIAL)
77 if (!m_COM_port.empty())
85 if (m_stream_FTDI->isOpen())
89 m_stream_FTDI->OpenBySerialNumber( m_usbSerialNumber );
91 m_stream_FTDI->Purge();
93 m_stream_FTDI->SetLatencyTimer(1);
94 m_stream_FTDI->SetTimeouts(10,100);
99 m_stream_FTDI->Close();
106 if (m_stream_SERIAL->isOpen())
107 return m_stream_SERIAL;
110 m_stream_SERIAL->open(m_COM_port);
111 m_stream_SERIAL->setConfig(m_COM_baud);
113 m_stream_SERIAL->setTimeouts(50,1,100, 1,20);
115 m_stream_SERIAL->purgeBuffers();
117 return m_stream_SERIAL;
121 m_stream_SERIAL->close();
136 CStream *comms = checkConnectionAndConnect();
140 cout <<
"ERORR: Problem connecting to Device." << endl;
154 bool time_out =
false;
156 double time_out_val = 1;
166 cout <<
"[CEnoseModular - getObservation] measurement Timed-Out" << endl;
174 size_t numSensors = (msg.
content.size()-1)/3;
183 if (enose_poses_x.size() != 0)
190 enose_poses_pitch[0],
191 enose_poses_roll[0]);
200 for (
size_t idx=0 ; idx<numSensors ; idx++)
203 int sensorType_temp = 0;
206 int sensorType = sensorType_temp << (8) ;
229 cout <<
"Message was empty" << endl;
236 cerr <<
"[CEnoseModular::getObservation] Returning false due to exception: " << endl;
237 cerr << e.what() << endl;
254 void CEnoseModular::doProcess()
256 CObservationGasSensorsPtr obs= CObservationGasSensors::Create();
261 appendObservation( obs );
266 cout <<
"No observation received from the USB board!" << endl;
274 void CEnoseModular::purgeBuffers()
276 if (!checkConnectionAndConnect())
281 m_stream_FTDI->Purge();
285 m_stream_SERIAL->purgeBuffers();
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
void BASE_IMPEXP memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS
An OS and compiler independent version of "memcpy".
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
OBSERVATION_T::Ptr getObservation(mrpt::obs::CSensoryFramePtr &observations, mrpt::obs::CObservationPtr &observation, bool priority_to_sf=true)
Given an mrpt::obs::CSensoryFrame and a mrpt::obs::CObservation pointer if a OBSERVATION_T type obser...
A communications serial port built as an implementation of a utils::CStream.
mrpt::system::TTimeStamp BASE_IMPEXP getCurrentTime()
Returns the current (UTC) system time.
float temperature
Sensed temperature in Celcius (valid if hasTemperature=true only)
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.
mrpt::system::TTimeStamp BASE_IMPEXP getCurrentLocalTime()
Returns the current (local) time.
This class allows loading and storing values and vectors of different types from a configuration text...
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.
void delete_safe(T *&ptr)
Calls "delete" to free an object only if the pointer is not NULL, then set the pointer to NULL...
math::TPose3D eNosePoseOnTheRobot
The pose of the sensors on the robot.
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...
bool hasTemperature
Must be true for "temperature" to contain a valid measurement.
This namespace contains representation of robot actions and observations.
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:
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
bool isActive
True if the input to this chamber/enose is poluted air, False if clean air.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp. Where available, this should contain the accurate satellite-based time...
bool receiveMessage(utils::CMessage &msg)
Tries to receive a message from the device.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::vector< TObservationENose > m_readings
One entry per e-nose on the robot.
uint64_t read_uint64_t(const std::string §ion, const std::string &name, uint64_t defaultValue, bool failIfNotFound=false) const
std::vector< uint8_t > content
The contents of the message (memory is automatically handled by the std::vector object) ...
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 ...
A definition of a CStream actually representing a USB connection to a FTDI chip.
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object...
A class for interfacing an e-NoseModular via a FTDI USB link.