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



Page generated by Doxygen 1.9.8 for MRPT 1.4.0 SVN: at Wed Dec 6 15:06:50 UTC 2023