Main MRPT website > C++ reference for MRPT 1.9.9
CBoardSonars.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 #ifndef CBoardSonars_H
10 #define CBoardSonars_H
11 
16 
17 namespace mrpt
18 {
19 namespace hwdrivers
20 {
21 /** This "software driver" implements the communication protocol for
22  * interfacing a Ultrasonic range finder SRF10 through a custom USB board.
23  *
24  * In this class the "bind" is ignored since it is designed for USB
25  * connections only, thus it internally generate the required object for
26  * simplicity of use.
27  * The serial number of the USB device is used to open it on the first call
28  * to "doProcess", thus you must call "loadConfig" before this, or manually
29  * call "setDeviceSerialNumber". The default serial number is "SONAR001"
30  *
31  * Warning: Avoid defining an object of this class in a global scope if you
32  * want to catch all potential
33  * exceptions during the constructors (like USB interface DLL not found,
34  * etc...)
35  *
36  * \code
37  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
38  * -------------------------------------------------------
39  * [supplied_section_name]
40  * USB_serialNumber=SONAR001
41  * gain=6 ; Value between 0 and 16, for analog gains between 40
42  * and 700.
43  * maxRange=4.0 ; In meters, used for device internal timer.
44  * minTimeBetweenPings=0.3 ; In seconds
45  *
46  * ; The order in which sonars will be fired, indexed by their I2C addresses
47  * [0,15]
48  * ; Up to 16 devices, but you can put any number of devices (from 1 to 16).
49  * firingOrder=0 1 2 3
50  *
51  *
52  * \endcode
53  *
54  * \ingroup mrpt_hwdrivers_grp
55  */
57 {
59 
60  public:
61  /** Constructor
62  */
63  CBoardSonars();
64 
65  /** Destructor
66  */
67  virtual ~CBoardSonars() {}
68  /** Query the firmware version on the device (can be used to test
69  * communications).
70  * \return true on success, false on communications errors or device not
71  * found.
72  */
73  bool queryFirmwareVersion(std::string& out_firmwareVersion);
74 
75  /** Request the latest range measurements.
76  * \return true on success, false on communications errors or device not
77  * found.
78  */
80 
81  /** Requests a command of "change address" for a given SRF10 device.
82  * currentAddress and newAddress are the I2C addresses in the range 0 to
83  * 15 (mapped to 0xE0 to 0xFE internally).
84  * \return true on success, false on communications errors or device not
85  * found.
86  */
87  bool programI2CAddress(uint8_t currentAddress, uint8_t newAddress);
88 
89  // See docs in parent class
90  void doProcess();
91 
92  protected:
93  /** A copy of the device serial number (to open the USB FTDI chip)
94  */
96 
97  /** A value between 0 and 16, for gains between 40 and 700 (not linear).
98  */
100 
101  /** The maximum range in meters, used for the internal device timer (value
102  * between 4cm and 11m).
103  */
104  float m_maxRange;
105 
106  /** The order in which sonars will be fired, indexed by their I2C addresses
107  * [0,15].
108  * Up to 16 devices, but you can put any number of devices (from 1 to 16).
109  */
110  std::vector<int32_t> m_firingOrder;
111 
112  /** The individual gains of the sonars, indexed by their I2C addresses
113  * [0,15].
114  * Up to 16 devices, but you can put any number of devices (from 1 to 16).
115  */
116  std::map<uint16_t, int32_t> m_sonarGains;
117 
118  /** The poses of the sonars: x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg]
119  * Up to 16 devices, but you can put any number of devices (from 1 to 16).
120  */
121  std::map<uint16_t, mrpt::math::TPose3D> m_sonarPoses;
122 
123  /** The minimum time between sonar pings (in seconds).
124  */
126 
127  /** Tries to connect to the USB device (if disconnected).
128  * \return True on connection OK, false on error.
129  */
131 
132  /** Sends the configuration (max range, gain,...) to the USB board. Used
133  * internally after a successfull connection.
134  * \return true on success, false on communications errors or device not
135  * found.
136  */
137  bool sendConfigCommands();
138 
139  /** Loads specific configuration for the device from a given source of
140  * configuration parameters, for example, an ".ini" file,
141  * loading from the section "[iniSection]" (see config::CConfigFileBase
142  * and
143  * derived classes)
144  * See hwdrivers::CBoardSonars for the possible parameters
145  */
147  const mrpt::config::CConfigFileBase& configSource,
148  const std::string& iniSection);
149 
150 }; // End of class
151 } // End of namespace
152 } // End of namespace
153 
154 #endif
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
std::map< uint16_t, int32_t > m_sonarGains
The individual gains of the sonars, indexed by their I2C addresses [0,15].
Definition: CBoardSonars.h:116
bool queryFirmwareVersion(std::string &out_firmwareVersion)
Query the firmware version on the device (can be used to test communications).
Declares a class derived from "CObservation" that encapsules a single range measurement, and associated parameters.
bool checkConnectionAndConnect()
Tries to connect to the USB device (if disconnected).
std::string m_usbSerialNumber
A copy of the device serial number (to open the USB FTDI chip)
Definition: CBoardSonars.h:95
void doProcess()
This method will be invoked at a minimum rate of "process_rate" (Hz)
std::vector< int32_t > m_firingOrder
The order in which sonars will be fired, indexed by their I2C addresses [0,15].
Definition: CBoardSonars.h:110
unsigned char uint8_t
Definition: rptypes.h:41
This class allows loading and storing values and vectors of different types from a configuration text...
float m_minTimeBetweenPings
The minimum time between sonar pings (in seconds).
Definition: CBoardSonars.h:125
virtual ~CBoardSonars()
Destructor.
Definition: CBoardSonars.h:67
This "software driver" implements the communication protocol for interfacing a Ultrasonic range finde...
Definition: CBoardSonars.h:56
uint8_t m_gain
A value between 0 and 16, for gains between 40 and 700 (not linear).
Definition: CBoardSonars.h:99
GLsizei const GLchar ** string
Definition: glext.h:4101
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection)
Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see config::CConfigFileBase and derived classes) See hwdrivers::CBoardSonars for the possible parameters.
#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.
A definition of a CStream actually representing a USB connection to a FTDI chip.
bool sendConfigCommands()
Sends the configuration (max range, gain,...) to the USB board.
std::map< uint16_t, mrpt::math::TPose3D > m_sonarPoses
The poses of the sonars: x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg] Up to 16 devices, but you can put any number of devices (from 1 to 16).
Definition: CBoardSonars.h:121
bool programI2CAddress(uint8_t currentAddress, uint8_t newAddress)
Requests a command of "change address" for a given SRF10 device.
float m_maxRange
The maximum range in meters, used for the internal device timer (value between 4cm and 11m)...
Definition: CBoardSonars.h:104
bool getObservation(mrpt::obs::CObservationRange &obs)
Request the latest range measurements.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019