MRPT  1.9.9
CEnoseModular.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef CEnoseModular_H
11 #define CEnoseModular_H
12 
14 #include <mrpt/comms/CSerialPort.h>
18 #include <memory> // unique_ptr
19 
20 namespace mrpt::hwdrivers
21 {
22 /** A class for interfacing an e-NoseModular via a FTDI USB link.
23  * Implemented for the Mdular board v1.0 designed by 2013 @ MAPIR (University
24  * of Malaga).
25  *
26  * \code
27  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
28  * -------------------------------------------------------
29  * [supplied_section_name]
30  * USB_serialname=ENOSE001 // USB FTDI pipe: will open only if COM_port_*
31  * are not set or empty
32  *
33  * COM_port_WIN = COM1 // Serial port to connect to.
34  * COM_port_LIN = ttyS0
35  *
36  * COM_baudRate = 115200
37  *
38  * ; 3D position (in meters) of the master +slave eNoses
39  * enose_poses_x=<MASTER X> <SLAVE#1 X> <SLAVE#2 X> <SLAVE#3 X>...
40  * enose_poses_y=<MASTER Y> <SLAVE#1 Y> <SLAVE#2 Y> <SLAVE#3 Y>...
41  * enose_poses_z=<MASTER Z> <SLAVE#1 Z> <SLAVE#2 Z> <SLAVE#3 Z>...
42  *
43  * ; 3D pose angles (in degrees) of the master +slave eNoses
44  * enose_poses_yaw=<MASTER YAW> <SLAVE#1 YAW> <SLAVE#2 YAW> <SLAVE#3 YAW>...
45  * enose_poses_pitch=<MASTER PITCH> <SLAVE#1 PITCH> <SLAVE#2 PITCH> <SLAVE#3
46  * PITCH>...
47  * enose_poses_roll=<MASTER ROLL> <SLAVE#1 ROLL> <SLAVE#2 ROLL> <SLAVE#3
48  * ROLL>...
49  *
50  * \endcode
51  *
52  * \ingroup mrpt_hwdrivers_grp
53  */
55 {
57 
58  protected:
59  /** A copy of the device serial number (to open the USB FTDI chip)
60  */
64 
65  /** If not an empty string (default), will open that serial port, otherwise
66  * will try to open USB FTDI device "m_usbSerialNumber" */
68  /** Default=115200 */
69  unsigned int m_COM_baud;
70 
71  // Only one of these two streams will be !=nullptr and open for each
72  // specific eNose board!
73  /** FTDI comms pipe (when not in serial port mode) */
74  std::unique_ptr<mrpt::comms::CInterfaceFTDI> m_stream_FTDI;
75  /** Serial port comms */
76  std::unique_ptr<mrpt::comms::CSerialPort> m_stream_SERIAL;
77 
78  /** The 3D pose of the master + N slave eNoses on the robot (meters &
79  * radians) */
82 
83  /** Tries to connect to the USB device (if disconnected).
84  * \return nullptr on error, otherwise a stream to be used for comms.
85  */
87 
88  /** See the class documentation at the top for expected parameters */
90  const mrpt::config::CConfigFileBase& configSource,
91  const std::string& section);
92 
93  /** Purge the Serial/FTDI buffer */
94  void purgeBuffers();
95 
96  public:
97  /** Constructor
98  * \param serialNumberUSBdevice The serial number (text) of the device to
99  * open.
100  * The constructor will try to open the device. You can check if it failed
101  * calling "isOpen()".
102  */
103  CEnoseModular();
104 
105  /** Request the master eNose the latest readings from all the eNoses.
106  * The output observation contains a valid timestamp and 3D positions if
107  * "loadConfig" has been called previously.
108  * \return true if OK, false if there were any error.
109  */
111 
112  // See docs in parent class
113  void doProcess();
114 
115  /** If not an empty string, will open that serial port, otherwise will try
116  * to open USB FTDI device "m_usbSerialNumber"
117  * The default is an empty string. Example strings: "COM1", "ttyUSB0", ...
118  */
119  inline void setSerialPort(const std::string& port) { m_COM_port = port; }
120  inline std::string getSerialPort() const { return m_COM_port; }
121  /** Set the serial port baud rate (default: 115200) */
122  inline void setSerialPortBaud(unsigned int baud) { m_COM_baud = baud; }
123  inline unsigned int getSerialPortBaud() const { return m_COM_baud; }
124 }; // end of class
125 }
126 #endif
127 
128 
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
std::vector< float > enose_poses_z
Definition: CEnoseModular.h:80
void doProcess()
This method should be called periodically (at least at 1Hz to capture ALL the real-time data) It is t...
std::vector< float > enose_poses_roll
Definition: CEnoseModular.h:80
void purgeBuffers()
Purge the Serial/FTDI buffer.
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_usb...
std::string getSerialPort() const
Contains classes for various device interfaces.
std::vector< float > enose_poses_yaw
Definition: CEnoseModular.h:80
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: io/CStream.h:28
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &section)
See the class documentation at the top for expected parameters.
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
This class allows loading and storing values and vectors of different types from a configuration text...
std::vector< float > enose_poses_pitch
Definition: CEnoseModular.h:80
void setSerialPortBaud(unsigned int baud)
Set the serial port baud rate (default: 115200)
mrpt::system::TTimeStamp initial_timestamp
Definition: CEnoseModular.h:62
std::string m_usbSerialNumber
A copy of the device serial number (to open the USB FTDI chip)
Definition: CEnoseModular.h:61
std::vector< float > enose_poses_x
The 3D pose of the master + N slave eNoses on the robot (meters & radians)
Definition: CEnoseModular.h:80
std::unique_ptr< mrpt::comms::CSerialPort > m_stream_SERIAL
Serial port comms.
Definition: CEnoseModular.h:76
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
std::string m_COM_port
If not an empty string (default), will open that serial port, otherwise will try to open USB FTDI dev...
Definition: CEnoseModular.h:67
GLsizei const GLchar ** string
Definition: glext.h:4101
std::vector< float > enose_poses_y
Definition: CEnoseModular.h:80
mrpt::io::CStream * checkConnectionAndConnect()
Tries to connect to the USB device (if disconnected).
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
unsigned int getSerialPortBaud() const
bool getObservation(mrpt::obs::CObservationGasSensors &outObservation)
Request the master eNose the latest readings from all the eNoses.
unsigned int m_COM_baud
Default=115200.
Definition: CEnoseModular.h:69
std::unique_ptr< mrpt::comms::CInterfaceFTDI > m_stream_FTDI
FTDI comms pipe (when not in serial port mode)
Definition: CEnoseModular.h:74
A class for interfacing an e-NoseModular via a FTDI USB link.
Definition: CEnoseModular.h:54



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020