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