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



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019