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
mrpt::hwdrivers::CBoardSonars::m_minTimeBetweenPings
float m_minTimeBetweenPings
The minimum time between sonar pings (in seconds).
Definition: CBoardSonars.h:125
mrpt::hwdrivers::CBoardSonars::m_usbSerialNumber
std::string m_usbSerialNumber
A copy of the device serial number (to open the USB FTDI chip)
Definition: CBoardSonars.h:95
mrpt::hwdrivers::CBoardSonars::doProcess
void doProcess()
This method will be invoked at a minimum rate of "process_rate" (Hz)
Definition: CBoardSonars.cpp:325
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
DEFINE_GENERIC_SENSOR
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
Definition: CGenericSensor.h:314
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
mrpt::hwdrivers::CBoardSonars::loadConfig_sensorSpecific
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,...
Definition: CBoardSonars.cpp:44
mrpt::hwdrivers::CBoardSonars::CBoardSonars
CBoardSonars()
Constructor.
Definition: CBoardSonars.cpp:28
CConfigFileBase.h
mrpt::hwdrivers::CBoardSonars
This "software driver" implements the communication protocol for interfacing a Ultrasonic range finde...
Definition: CBoardSonars.h:56
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::comms::CInterfaceFTDI
A definition of a CStream actually representing a USB connection to a FTDI chip.
Definition: CInterfaceFTDI.h:75
mrpt::hwdrivers::CBoardSonars::queryFirmwareVersion
bool queryFirmwareVersion(std::string &out_firmwareVersion)
Query the firmware version on the device (can be used to test communications).
Definition: CBoardSonars.cpp:102
CGenericSensor.h
CInterfaceFTDI.h
mrpt::hwdrivers::CBoardSonars::programI2CAddress
bool programI2CAddress(uint8_t currentAddress, uint8_t newAddress)
Requests a command of "change address" for a given SRF10 device.
Definition: CBoardSonars.cpp:269
mrpt::hwdrivers::CGenericSensor
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
Definition: CGenericSensor.h:70
mrpt::hwdrivers::CBoardSonars::m_sonarPoses
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,...
Definition: CBoardSonars.h:121
mrpt::obs::CObservationRange
Declares a class derived from "CObservation" that encapsules a single range measurement,...
Definition: CObservationRange.h:30
mrpt::hwdrivers::CBoardSonars::~CBoardSonars
virtual ~CBoardSonars()
Destructor.
Definition: CBoardSonars.h:67
CObservationRange.h
mrpt::hwdrivers::CBoardSonars::sendConfigCommands
bool sendConfigCommands()
Sends the configuration (max range, gain,...) to the USB board.
Definition: CBoardSonars.cpp:133
mrpt::hwdrivers::CBoardSonars::m_firingOrder
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
mrpt::hwdrivers::CBoardSonars::m_gain
uint8_t m_gain
A value between 0 and 16, for gains between 40 and 700 (not linear).
Definition: CBoardSonars.h:99
mrpt::hwdrivers::CBoardSonars::getObservation
bool getObservation(mrpt::obs::CObservationRange &obs)
Request the latest range measurements.
Definition: CBoardSonars.cpp:209
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::hwdrivers::CBoardSonars::m_maxRange
float m_maxRange
The maximum range in meters, used for the internal device timer (value between 4cm and 11m).
Definition: CBoardSonars.h:104
mrpt::hwdrivers::CBoardSonars::checkConnectionAndConnect
bool checkConnectionAndConnect()
Tries to connect to the USB device (if disconnected).
Definition: CBoardSonars.cpp:299
mrpt::hwdrivers::CBoardSonars::m_sonarGains
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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST