Class CEnoseModular

Inheritance Relationships

Base Type

Class Documentation

class CEnoseModular : public mrpt::hwdrivers::CGenericSensor

A class for interfacing an e-NoseModular via a FTDI USB link. Implemented for the Mdular board v1.0 designed by 2013 @ MAPIR (University of Malaga).

 PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
-------------------------------------------------------
  [supplied_section_name]
   USB_serialname=ENOSE001   // USB FTDI pipe: will open only if COM_port_*
are not set or empty

   COM_port_WIN = COM1       // Serial port to connect to.
   COM_port_LIN = ttyS0

   COM_baudRate = 115200

   ; 3D position (in meters) of the master +slave eNoses
   enose_poses_x=<MASTER X> <SLAVE#1 X> <SLAVE#2 X> <SLAVE#3 X>...
   enose_poses_y=<MASTER Y> <SLAVE#1 Y> <SLAVE#2 Y> <SLAVE#3 Y>...
   enose_poses_z=<MASTER Z> <SLAVE#1 Z> <SLAVE#2 Z> <SLAVE#3 Z>...

   ; 3D pose angles (in degrees) of the master +slave eNoses
   enose_poses_yaw=<MASTER YAW> <SLAVE#1 YAW> <SLAVE#2 YAW> <SLAVE#3 YAW>...
   enose_poses_pitch=<MASTER PITCH> <SLAVE#1 PITCH> <SLAVE#2 PITCH> <SLAVE#3
PITCH>...
   enose_poses_roll=<MASTER ROLL> <SLAVE#1 ROLL> <SLAVE#2 ROLL> <SLAVE#3
ROLL>...

Public Functions

CEnoseModular()

Constructor

Parameters:

serialNumberUSBdevice – The serial number (text) of the device to open. The constructor will try to open the device. You can check if it failed calling “isOpen()”.

bool getObservation(mrpt::obs::CObservationGasSensors &outObservation)

Request the master eNose the latest readings from all the eNoses. The output observation contains a valid timestamp and 3D positions if “loadConfig” has been called previously.

Returns:

true if OK, false if there were any error.

virtual void doProcess() override

This method will be invoked at a minimum rate of “process_rate” (Hz)

Throws:

This – method must throw an exception with a descriptive message if some critical error is found.

inline void setSerialPort(const std::string &port)

If not an empty string, will open that serial port, otherwise will try to open USB FTDI device “m_usbSerialNumber” The default is an empty string. Example strings: “COM1”, “ttyUSB0”, …

inline std::string getSerialPort() const
inline void setSerialPortBaud(unsigned int baud)

Set the serial port baud rate (default: 115200)

inline unsigned int getSerialPortBaud() const

Protected Functions

mrpt::io::CStream *checkConnectionAndConnect()

Tries to connect to the USB device (if disconnected).

Returns:

nullptr on error, otherwise a stream to be used for comms.

virtual void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &section) override

See the class documentation at the top for expected parameters

void purgeBuffers()

Purge the Serial/FTDI buffer

Protected Attributes

std::string m_usbSerialNumber

A copy of the device serial number (to open the USB FTDI chip)

mrpt::system::TTimeStamp initial_timestamp
bool first_reading
std::string m_COM_port

If not an empty string (default), will open that serial port, otherwise will try to open USB FTDI device “m_usbSerialNumber”

unsigned int m_COM_baud = {115200}

Default=115200

std::unique_ptr<mrpt::comms::CInterfaceFTDI> m_stream_FTDI

FTDI comms pipe (when not in serial port mode)

std::unique_ptr<mrpt::comms::CSerialPort> m_stream_SERIAL

Serial port comms

std::vector<float> enose_poses_x

The 3D pose of the master + N slave eNoses on the robot (meters & radians)

std::vector<float> enose_poses_y
std::vector<float> enose_poses_z
std::vector<float> enose_poses_yaw
std::vector<float> enose_poses_pitch
std::vector<float> enose_poses_roll