MRPT logo

mrpt::hwdrivers::CBoardSonars Class Reference

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

#include <mrpt/hwdrivers/CBoardSonars.h>

Inheritance diagram for mrpt::hwdrivers::CBoardSonars:

mrpt::hwdrivers::CInterfaceFTDIMessages mrpt::hwdrivers::CInterfaceFTDI mrpt::utils::CStream

List of all members.

Public Member Functions

 CBoardSonars ()
 Constructor.
 ~CBoardSonars ()
 Destructor.
void loadConfig (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.
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.

Protected Member Functions

bool checkConnectionAndConnect ()
 Tries to connect to the USB device (if disconnected).
bool sendConfigCommands ()
 Sends the configuration (max range, gain,.

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].
float m_minTimeBetweenPings
 The minimum time between sonar pings (in seconds).


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


                ¡¡¡FALTA PONER UNA ESTRUCTURILLA PARA ALMACENAR LA POSE3D DE LOS 16 SONARES SOBRE EL ROBOT!!!

Definition at line 69 of file CBoardSonars.h.


Constructor & Destructor Documentation

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

Constructor.

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

Destructor.

Definition at line 110 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.

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 ( 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.

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 87 of file CBoardSonars.h.

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

Definition at line 78 of file CBoardSonars.h.

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

Definition at line 82 of file CBoardSonars.h.

The minimum time between sonar pings (in seconds).

Definition at line 91 of file CBoardSonars.h.

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

Definition at line 74 of file CBoardSonars.h.




Page generated by Doxygen 1.5.7.1 for MRPT 0.6.5 SVN: at Mon Feb 23 13:25:04 EST 2009