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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020