Main MRPT website > C++ reference for MRPT 1.5.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-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 CEnoseModular_H
11 #define CEnoseModular_H
12 
18 
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 of 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_* 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 PITCH>...
46  * enose_poses_roll=<MASTER ROLL> <SLAVE#1 ROLL> <SLAVE#2 ROLL> <SLAVE#3 ROLL>...
47  *
48  * \endcode
49  *
50  * \ingroup mrpt_hwdrivers_grp
51  */
53  {
55 
56  protected:
57  /** A copy of the device serial number (to open the USB FTDI chip)
58  */
62 
63  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"
64  unsigned int m_COM_baud; //!< Default=115200
65 
66 
67  // Only one of these two streams will be !=NULL and open for each specific eNose board!
68  /** FTDI comms pipe (when not in serial port mode) */
70  /** Serial port comms */
72 
73  /** The 3D pose of the master + N slave eNoses on the robot (meters & radians) */
74  std::vector<float> enose_poses_x,enose_poses_y,enose_poses_z,enose_poses_yaw,enose_poses_pitch,enose_poses_roll;
75 
76  /** Tries to connect to the USB device (if disconnected).
77  * \return NULL on error, otherwise a stream to be used for comms.
78  */
79  mrpt::utils::CStream* checkConnectionAndConnect();
80 
81  /** See the class documentation at the top for expected parameters */
82  void loadConfig_sensorSpecific(
83  const mrpt::utils::CConfigFileBase &configSource,
84  const std::string &section );
85 
86  /** Purge the Serial/FTDI buffer */
87  void purgeBuffers();
88 
89  public:
90  /** Constructor
91  * \param serialNumberUSBdevice The serial number (text) of the device to open.
92  * The constructor will try to open the device. You can check if it failed calling "isOpen()".
93  */
94  CEnoseModular( );
95 
96  /** Destructor
97  */
98  virtual ~CEnoseModular();
99 
100  /** Request the master eNose the latest readings from all the eNoses.
101  * The output observation contains a valid timestamp and 3D positions if "loadConfig" has been called previously.
102  * \return true if OK, false if there were any error.
103  */
104  bool getObservation( mrpt::obs::CObservationGasSensors &outObservation );
105 
106 
107  // See docs in parent class
108  void doProcess();
109 
110 
111 
112  /** If not an empty string, will open that serial port, otherwise will try to open USB FTDI device "m_usbSerialNumber"
113  * The default is an empty string. Example strings: "COM1", "ttyUSB0", ...
114  */
115  inline void setSerialPort(const std::string &port) { m_COM_port = port; }
116  inline std::string getSerialPort() const { return m_COM_port; }
117 
118  /** Set the serial port baud rate (default: 115200) */
119  inline void setSerialPortBaud(unsigned int baud) { m_COM_baud=baud; }
120  inline unsigned int getSerialPortBaud() const { return m_COM_baud; }
121 
122 
123  }; // end of class
124  } // end of namespace
125 } // end of namespace
126 
127 
128 #endif
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
CInterfaceFTDI * m_stream_FTDI
FTDI comms pipe (when not in serial port mode)
Definition: CEnoseModular.h:69
std::vector< float > enose_poses_z
Definition: CEnoseModular.h:74
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 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
CSerialPort * m_stream_SERIAL
Serial port comms.
Definition: CEnoseModular.h:71
This class allows loading and storing values and vectors of different types from a configuration text...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
void setSerialPortBaud(unsigned int baud)
Set the serial port baud rate (default: 115200)
mrpt::system::TTimeStamp initial_timestamp
Definition: CEnoseModular.h:60
std::string m_usbSerialNumber
A copy of the device serial number (to open the USB FTDI chip)
Definition: CEnoseModular.h:59
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:63
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.
unsigned int getSerialPortBaud() const
unsigned int m_COM_baud
Default=115200.
Definition: CEnoseModular.h:64
A definition of a CStream actually representing a USB connection to a FTDI chip.
A class for interfacing an e-NoseModular via a FTDI USB link.
Definition: CEnoseModular.h:52



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020