Main MRPT website > C++ reference
MRPT logo
Public Member Functions | Protected Member Functions | Protected Attributes

mrpt::hwdrivers::CBoardSonars Class Reference


Detailed Description

This "software driver" implements the communication protocol for interfacing a Ultrasonic range finder SRF10 through a custom USB board.

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. 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 call "setDeviceSerialNumber". The default serial number is "SONAR001"

Warning: Avoid defining an object of this class in a global scope if you want to catch all potential exceptions during the constructors (like USB interface DLL not found, etc...)

  PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
 -------------------------------------------------------
   [supplied_section_name]
   USB_serialNumber=SONAR001
   gain=6                       ; Value between 0 and 16, for analog gains between 40 and 700.
   maxRange=4.0         ; In meters, used for device internal timer.
   minTimeBetweenPings=0.3  ; In seconds

   ; The order in which sonars will be fired, indexed by their I2C addresses [0,15]
   ;  Up to 16 devices, but you can put any number of devices (from 1 to 16).
   firingOrder=0 1 2 3

Definition at line 68 of file CBoardSonars.h.

#include <mrpt/hwdrivers/CBoardSonars.h>

Inheritance diagram for mrpt::hwdrivers::CBoardSonars:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CBoardSonars ()
 Constructor.
virtual ~CBoardSonars ()
 Destructor.
bool queryFirmwareVersion (std::string &out_firmwareVersion)
 Query the firmware version on the device (can be used to test communications).
bool getObservation (mrpt::slam::CObservationRange &obs)
 Request the latest range measurements.
bool programI2CAddress (uint8_t currentAddress, uint8_t newAddress)
 Requests a command of "change address" for a given SRF10 device.
void doProcess ()
 This method should be called periodically (at least at 1Hz to capture ALL the real-time data) It is thread safe, i.e.

Protected Member Functions

bool checkConnectionAndConnect ()
 Tries to connect to the USB device (if disconnected).
bool sendConfigCommands ()
 Sends the configuration (max range, gain,...) to the USB board.
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, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) See hwdrivers::CBoardSonars for the possible parameters.

Protected Attributes

std::string m_usbSerialNumber
 A copy of the device serial number (to open the USB FTDI chip)
uint8_t m_gain
 A value between 0 and 16, for gains between 40 and 700 (not linear).
float m_maxRange
 The maximum range in meters, used for the internal device timer (value between 4cm and 11m).
std::vector< int32_t > m_firingOrder
 The order in which sonars will be fired, indexed by their I2C addresses [0,15].
std::map< uint16_t, int32_t > m_sonarGains
 The individual gains of the sonars, indexed by their I2C addresses [0,15].
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).
float m_minTimeBetweenPings
 The minimum time between sonar pings (in seconds).

Constructor & Destructor Documentation

mrpt::hwdrivers::CBoardSonars::CBoardSonars ( )

Constructor.

virtual mrpt::hwdrivers::CBoardSonars::~CBoardSonars ( ) [inline, virtual]

Destructor.

Definition at line 79 of file CBoardSonars.h.


Member Function Documentation

bool mrpt::hwdrivers::CBoardSonars::checkConnectionAndConnect ( ) [protected]

Tries to connect to the USB device (if disconnected).

Returns:
True on connection OK, false on error.
void mrpt::hwdrivers::CBoardSonars::doProcess ( ) [virtual]

This method should be called periodically (at least at 1Hz to capture ALL the real-time data) It is thread safe, i.e.

you can call this from one thread, then to other methods from other threads.rip

Implements mrpt::hwdrivers::CGenericSensor.

bool mrpt::hwdrivers::CBoardSonars::getObservation ( mrpt::slam::CObservationRange obs)

Request the latest range measurements.

Returns:
true on success, false on communications errors or device not found.
void mrpt::hwdrivers::CBoardSonars::loadConfig_sensorSpecific ( const mrpt::utils::CConfigFileBase configSource,
const std::string &  iniSection 
) [protected, virtual]

Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) See hwdrivers::CBoardSonars for the possible parameters.

Implements mrpt::hwdrivers::CGenericSensor.

bool mrpt::hwdrivers::CBoardSonars::programI2CAddress ( uint8_t  currentAddress,
uint8_t  newAddress 
)

Requests a command of "change address" for a given SRF10 device.

currentAddress and newAddress are the I2C addresses in the range 0 to 15 (mapped to 0xE0 to 0xFE internally).

Returns:
true on success, false on communications errors or device not found.
bool mrpt::hwdrivers::CBoardSonars::queryFirmwareVersion ( std::string &  out_firmwareVersion)

Query the firmware version on the device (can be used to test communications).

Returns:
true on success, false on communications errors or device not found.
bool mrpt::hwdrivers::CBoardSonars::sendConfigCommands ( ) [protected]

Sends the configuration (max range, gain,...) to the USB board.

Used internally after a successfull connection.

Returns:
true on success, false on communications errors or device not found.

Member Data Documentation

std::vector<int32_t> mrpt::hwdrivers::CBoardSonars::m_firingOrder [protected]

The order in which sonars will be fired, indexed by their I2C addresses [0,15].

Up to 16 devices, but you can put any number of devices (from 1 to 16).

Definition at line 118 of file CBoardSonars.h.

A value between 0 and 16, for gains between 40 and 700 (not linear).

Definition at line 109 of file CBoardSonars.h.

The maximum range in meters, used for the internal device timer (value between 4cm and 11m).

Definition at line 113 of file CBoardSonars.h.

The minimum time between sonar pings (in seconds).

Definition at line 132 of file CBoardSonars.h.

std::map<uint16_t,int32_t> mrpt::hwdrivers::CBoardSonars::m_sonarGains [protected]

The individual gains of the sonars, indexed by their I2C addresses [0,15].

Up to 16 devices, but you can put any number of devices (from 1 to 16).

Definition at line 123 of file CBoardSonars.h.

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 at line 128 of file CBoardSonars.h.

A copy of the device serial number (to open the USB FTDI chip)

Definition at line 105 of file CBoardSonars.h.




Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:16:28 UTC 2011