MRPT  1.9.9
CBoardENoses.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 CBoardENoses_H
11 #define CBoardENoses_H
12 
14 #include <mrpt/comms/CSerialPort.h>
16 
19 #include <memory> // unique_ptr
20 
21 namespace mrpt::hwdrivers
22 {
23 /** A class for interfacing an e-Noses via a FTDI USB link.
24  * Implemented for the board v1.0 designed by 2007 @ ISA (University of
25  * Malaga).
26  *
27  * \code
28  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
29  * -------------------------------------------------------
30  * [supplied_section_name]
31  * USB_serialname=ENOSE001 // USB FTDI pipe: will open only if COM_port_*
32  * are not set or empty
33  *
34  * COM_port_WIN = COM1 // Serial port to connect to.
35  * COM_port_LIN = ttyS0
36  *
37  * COM_baudRate = 115200
38  *
39  * ; 3D position (in meters) of the master +slave eNoses
40  * enose_poses_x=<MASTER X> <SLAVE#1 X> <SLAVE#2 X> <SLAVE#3 X>...
41  * enose_poses_y=<MASTER Y> <SLAVE#1 Y> <SLAVE#2 Y> <SLAVE#3 Y>...
42  * enose_poses_z=<MASTER Z> <SLAVE#1 Z> <SLAVE#2 Z> <SLAVE#3 Z>...
43  *
44  * ; 3D pose angles (in degrees) of the master +slave eNoses
45  * enose_poses_yaw=<MASTER YAW> <SLAVE#1 YAW> <SLAVE#2 YAW> <SLAVE#3 YAW>...
46  * enose_poses_pitch=<MASTER PITCH> <SLAVE#1 PITCH> <SLAVE#2 PITCH> <SLAVE#3
47  * PITCH>...
48  * enose_poses_roll=<MASTER ROLL> <SLAVE#1 ROLL> <SLAVE#2 ROLL> <SLAVE#3
49  * ROLL>...
50  *
51  * \endcode
52  *
53  * \ingroup mrpt_hwdrivers_grp
54  */
56 {
58 
59  protected:
60  /** A copy of the device serial number (to open the USB FTDI chip)
61  */
65 
66  /** If not an empty string (default), will open that serial port, otherwise
67  * will try to open USB FTDI device "m_usbSerialNumber" */
69  /** Default=115200 */
70  unsigned int m_COM_baud;
71 
72  // Only one of these two streams will be !=nullptr and open for each
73  // specific eNose board!
74  /** FTDI comms pipe (when not in serial port mode) */
75  std::unique_ptr<mrpt::comms::CInterfaceFTDI> m_stream_FTDI;
76  /** Serial port comms */
77  std::unique_ptr<mrpt::comms::CSerialPort> m_stream_SERIAL;
78 
79  /** The 3D pose of the master + N slave eNoses on the robot (meters &
80  * radians) */
83 
84  /** Tries to connect to the USB device (if disconnected).
85  * \return nullptr on error, otherwise a stream to be used for comms.
86  */
88 
89  /** See the class documentation at the top for expected parameters */
91  const mrpt::config::CConfigFileBase& configSource,
92  const std::string& section);
93 
94  public:
95  /** Constructor
96  * \param serialNumberUSBdevice The serial number (text) of the device to
97  * open.
98  * The constructor will try to open the device. You can check if it failed
99  * calling "isOpen()".
100  */
101  CBoardENoses();
102 
103  /** Set the active chamber (afected by poluted air) on the device
104  * \return true on success, false on communications errors or device not
105  * found.
106  */
107  bool setActiveChamber(unsigned char chamber);
108 
109  /** Query the firmware version on the device (can be used to test
110  * communications).
111  * \return true on success, false on communications errors or device not
112  * found.
113  */
114  bool queryFirmwareVersion(std::string& out_firmwareVersion);
115 
116  /** Request the master eNose the latest readings from all the eNoses.
117  * The output observation contains a valid timestamp and 3D positions if
118  * "loadConfig" has been called previously.
119  * \return true if OK, false if there were any error.
120  */
122 
123  // See docs in parent class
124  void doProcess();
125 
126  /** Tries to open the camera, after setting all the parameters with a call
127  * to loadConfig.
128  * \exception This method must throw an exception with a descriptive
129  * message if some critical error is found.
130  */
131  virtual void initialize();
132 
133  /** If not an empty string, will open that serial port, otherwise will try
134  * to open USB FTDI device "m_usbSerialNumber"
135  * The default is an empty string. Example strings: "COM1", "ttyUSB0", ...
136  */
137  inline void setSerialPort(const std::string& port) { m_COM_port = port; }
138  inline std::string getSerialPort() const { return m_COM_port; }
139  /** Set the serial port baud rate (default: 115200) */
140  inline void setSerialPortBaud(unsigned int baud) { m_COM_baud = baud; }
141  inline unsigned int getSerialPortBaud() const { return m_COM_baud; }
142 }; // end of class
143 } // namespace mrpt::hwdrivers
144 #endif
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
std::chrono::duration< rep, period > duration
Definition: Clock.h:25
std::vector< float > enose_poses_z
Definition: CBoardENoses.h:81
std::unique_ptr< mrpt::comms::CInterfaceFTDI > m_stream_FTDI
FTDI comms pipe (when not in serial port mode)
Definition: CBoardENoses.h:75
void setSerialPortBaud(unsigned int baud)
Set the serial port baud rate (default: 115200)
Definition: CBoardENoses.h:140
Contains classes for various device interfaces.
std::string getSerialPort() const
Definition: CBoardENoses.h:138
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: io/CStream.h:28
bool getObservation(mrpt::obs::CObservationGasSensors &outObservation)
Request the master eNose the latest readings from all the eNoses.
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: CBoardENoses.h:137
std::vector< float > enose_poses_yaw
Definition: CBoardENoses.h:81
This class allows loading and storing values and vectors of different types from a configuration text...
void doProcess()
This method should be called periodically (at least at 1Hz to capture ALL the real-time data) It is t...
A class for interfacing an e-Noses via a FTDI USB link.
Definition: CBoardENoses.h:55
std::unique_ptr< mrpt::comms::CSerialPort > m_stream_SERIAL
Serial port comms.
Definition: CBoardENoses.h:77
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::io::CStream * checkConnectionAndConnect()
Tries to connect to the USB device (if disconnected).
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &section)
See the class documentation at the top for expected parameters.
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
std::vector< float > enose_poses_y
Definition: CBoardENoses.h:81
std::string m_usbSerialNumber
A copy of the device serial number (to open the USB FTDI chip)
Definition: CBoardENoses.h:62
unsigned int getSerialPortBaud() const
Definition: CBoardENoses.h:141
mrpt::Clock::duration initial_timestamp
Definition: CBoardENoses.h:63
virtual void initialize()
Tries to open the camera, after setting all the parameters with a call to loadConfig.
std::vector< float > enose_poses_pitch
Definition: CBoardENoses.h:81
std::vector< float > enose_poses_roll
Definition: CBoardENoses.h:81
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: CBoardENoses.h:68
unsigned int m_COM_baud
Default=115200.
Definition: CBoardENoses.h:70
std::vector< float > enose_poses_x
The 3D pose of the master + N slave eNoses on the robot (meters & radians)
Definition: CBoardENoses.h:81
bool setActiveChamber(unsigned char chamber)
Set the active chamber (afected by poluted air) on the device.
bool queryFirmwareVersion(std::string &out_firmwareVersion)
Query the firmware version on the device (can be used to test communications).



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