Main MRPT website > C++ reference for MRPT 1.5.7
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-2017, 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 
16 
19 
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 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_* 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 PITCH>...
47  * enose_poses_roll=<MASTER ROLL> <SLAVE#1 ROLL> <SLAVE#2 ROLL> <SLAVE#3 ROLL>...
48  *
49  * \endcode
50  *
51  * \ingroup mrpt_hwdrivers_grp
52  */
54  {
56 
57  protected:
58  /** A copy of the device serial number (to open the USB FTDI chip)
59  */
63 
64  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"
65  unsigned int m_COM_baud; //!< Default=115200
66 
67 
68  // Only one of these two streams will be !=NULL and open for each specific eNose board!
69  /** FTDI comms pipe (when not in serial port mode) */
71  /** Serial port comms */
73 
74  /** The 3D pose of the master + N slave eNoses on the robot (meters & radians) */
75  std::vector<float> enose_poses_x,enose_poses_y,enose_poses_z,enose_poses_yaw,enose_poses_pitch,enose_poses_roll;
76 
77  /** Tries to connect to the USB device (if disconnected).
78  * \return NULL on error, otherwise a stream to be used for comms.
79  */
80  mrpt::utils::CStream* checkConnectionAndConnect();
81 
82  /** See the class documentation at the top for expected parameters */
83  void loadConfig_sensorSpecific(
84  const mrpt::utils::CConfigFileBase &configSource,
85  const std::string &section );
86 
87  public:
88  /** Constructor
89  * \param serialNumberUSBdevice The serial number (text) of the device to open.
90  * The constructor will try to open the device. You can check if it failed calling "isOpen()".
91  */
92  CBoardENoses( );
93 
94  /** Destructor
95  */
96  virtual ~CBoardENoses();
97 
98  /** Set the active chamber (afected by poluted air) on the device
99  * \return true on success, false on communications errors or device not found.
100  */
101  bool setActiveChamber( unsigned char chamber );
102 
103  /** Query the firmware version on the device (can be used to test communications).
104  * \return true on success, false on communications errors or device not found.
105  */
106  bool queryFirmwareVersion( std::string &out_firmwareVersion );
107 
108  /** Request the master eNose the latest readings from all the eNoses.
109  * The output observation contains a valid timestamp and 3D positions if "loadConfig" has been called previously.
110  * \return true if OK, false if there were any error.
111  */
112  bool getObservation( mrpt::obs::CObservationGasSensors &outObservation );
113 
114 
115  // See docs in parent class
116  void doProcess();
117 
118  /** Tries to open the camera, after setting all the parameters with a call to loadConfig.
119  * \exception This method must throw an exception with a descriptive message if some critical error is found.
120  */
121  virtual void initialize();
122 
123 
124 
125  /** If not an empty string, will open that serial port, otherwise will try to open USB FTDI device "m_usbSerialNumber"
126  * The default is an empty string. Example strings: "COM1", "ttyUSB0", ...
127  */
128  inline void setSerialPort(const std::string &port) { m_COM_port = port; }
129  inline std::string getSerialPort() const { return m_COM_port; }
130 
131  /** Set the serial port baud rate (default: 115200) */
132  inline void setSerialPortBaud(unsigned int baud) { m_COM_baud=baud; }
133  inline unsigned int getSerialPortBaud() const { return m_COM_baud; }
134 
135 
136  }; // end of class
137  } // end of namespace
138 } // end of namespace
139 
140 
141 #endif
142 
143 
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:30
std::vector< float > enose_poses_z
Definition: CBoardENoses.h:75
OBSERVATION_T::Ptr getObservation(mrpt::obs::CSensoryFramePtr &observations, mrpt::obs::CObservationPtr &observation, bool priority_to_sf=true)
Given an mrpt::obs::CSensoryFrame and a mrpt::obs::CObservation pointer if a OBSERVATION_T type obser...
Definition: obs_utils.h:32
A communications serial port built as an implementation of a utils::CStream.
Definition: CSerialPort.h:43
void setSerialPortBaud(unsigned int baud)
Set the serial port baud rate (default: 115200)
Definition: CBoardENoses.h:132
CInterfaceFTDI * m_stream_FTDI
FTDI comms pipe (when not in serial port mode)
Definition: CBoardENoses.h:70
std::string getSerialPort() const
Definition: CBoardENoses.h:129
This class allows loading and storing values and vectors of different types from a configuration text...
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:128
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
A class for interfacing an e-Noses via a FTDI USB link.
Definition: CBoardENoses.h:53
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
GLsizei const GLchar ** string
Definition: glext.h:3919
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string m_usbSerialNumber
A copy of the device serial number (to open the USB FTDI chip)
Definition: CBoardENoses.h:60
unsigned int getSerialPortBaud() const
Definition: CBoardENoses.h:133
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:64
A definition of a CStream actually representing a USB connection to a FTDI chip.
mrpt::system::TTimeStamp initial_timestamp
Definition: CBoardENoses.h:61
unsigned int m_COM_baud
Default=115200.
Definition: CBoardENoses.h:65
CSerialPort * m_stream_SERIAL
Serial port comms.
Definition: CBoardENoses.h:72



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019