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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST