Public Member Functions | Protected Member Functions | Protected Attributes
iri_base_driver::IriBaseDriver Class Reference

IRI ROS Base Driver Class. More...

#include <iri_base_driver.h>

Inheritance diagram for iri_base_driver::IriBaseDriver:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual bool closeDriver (void)=0
 User Close Driver.
void doClose (void)
 Generic Close Driver.
void doOpen (void)
 Generic Open Driver.
void doStart (void)
 Generic Start Driver.
void doStop (void)
 Generic Stop Driver.
std::string getID (void)
 Get Driver Id.
 IriBaseDriver ()
 Constructor.
void lock (void)
 Lock Driver.
virtual bool openDriver (void)=0
 User Open Driver.
void setPreCloseHook (hookFunction f)
virtual bool startDriver (void)=0
 User Start Driver.
virtual bool stopDriver (void)=0
 User Stop Driver.
bool try_enter (void)
 Tries Access to Driver.
void unlock (void)
 Unlock Driver.
 ~IriBaseDriver ()
 Destructor.

Protected Member Functions

void setDriverId (const std::string &id)
 Set Driver Id.

Protected Attributes

pthread_mutex_t access_
 variable to handle the mutual exclusion mechanism
std::string driver_id_
 driver unique identifier
hookFunction preCloseHook

Detailed Description

IRI ROS Base Driver Class.

This class inherits from the ROS class driver_base::Driver, which provides the guidelines for any driver kind. The IriBaseDriver class offers an easy framework to integrate functional drivers implemented in C++ with the ROS driver structure. A shared library is generated together with IriBaseNodeDriver class to force implementation of virtual methods to final user. Common use functions to open, close, start and stop a driver need to be filled up when instantiating this class. ROS provides state transition methods to change from one state to another.

This class is used as an intermediate level between ROS basic classes and the user final driver implementation. Methods to manage drivers are implemented to provide common features to all driver-type objects. New methods are provided to the user for the specific driver needs.

Instances of both IriBaseDriver and IriBaseNodeDriver can be easly generated with the iri_ros_scripts package. Similarly, data can be sent and read through ROS topics by using those scripts. The scripts can be downloaded from the iri_stack SVN.

Definition at line 51 of file iri_base_driver.h.


Constructor & Destructor Documentation

Constructor.

The constructor calls the base class constructor from driver_base::Driver. Main driver's parameters can be initialized here or in the doOpen() method.

Definition at line 6 of file iri_base_driver.cpp.

Destructor.

This destructor is called when the object is about to be destroyed.

Definition at line 65 of file iri_base_driver.cpp.


Member Function Documentation

virtual bool iri_base_driver::IriBaseDriver::closeDriver ( void  ) [pure virtual]

User Close Driver.

An abstract method to be implemented in the inherit classes. Is called by doClose() method. Updates necessary driver variables according to the state.

Returns:
bool successful
void iri_base_driver::IriBaseDriver::doClose ( void  ) [virtual]

Generic Close Driver.

Currently only changes the ROS driver state to close and calls the abstract function closeDriver(). Common actions required for opening any kind of drivers should be added here.

Implements driver_base::Driver.

Definition at line 39 of file iri_base_driver.cpp.

void iri_base_driver::IriBaseDriver::doOpen ( void  ) [virtual]

Generic Open Driver.

Currently only changes the ROS driver state to open and calls the abstract function openDriver(). Common actions required for opening any kind of drivers should be added here.

Implements driver_base::Driver.

Definition at line 34 of file iri_base_driver.cpp.

void iri_base_driver::IriBaseDriver::doStart ( void  ) [virtual]

Generic Start Driver.

Currently only changes the ROS driver state to start and calls the abstract function startDriver().Common actions required for opening any kind of drivers should be added here.

Implements driver_base::Driver.

Definition at line 45 of file iri_base_driver.cpp.

void iri_base_driver::IriBaseDriver::doStop ( void  ) [virtual]

Generic Stop Driver.

Currently only changes the ROS driver state to stop and calls the abstract function stopDriver(). Common actions required for opening any kind of drivers should be added here.

Implements driver_base::Driver.

Definition at line 50 of file iri_base_driver.cpp.

std::string iri_base_driver::IriBaseDriver::getID ( void  ) [virtual]

Get Driver Id.

A method to get the unique driver identifier, such as serial number or driver name + id. If no id is provided in the inherit class, then string "none" is assigned.

Returns:
string driver id

Implements driver_base::Driver.

Definition at line 55 of file iri_base_driver.cpp.

Lock Driver.

Locks access to the driver class

Definition at line 11 of file iri_base_driver.cpp.

virtual bool iri_base_driver::IriBaseDriver::openDriver ( void  ) [pure virtual]

User Open Driver.

An abstract method to be implemented in the inherit classes. Is called by doOpen() method. Parameters necessary to be initialized when openning the driver need to be filled up here.

Returns:
bool successful
void iri_base_driver::IriBaseDriver::setDriverId ( const std::string &  id) [protected]

Set Driver Id.

A private method to set the unique driver identifier. Must be set before changing the driver_base::state=run in either the specific node constructor or in the doOpen() function.

Parameters:
idstring driver id

Definition at line 29 of file iri_base_driver.cpp.

Definition at line 60 of file iri_base_driver.cpp.

virtual bool iri_base_driver::IriBaseDriver::startDriver ( void  ) [pure virtual]

User Start Driver.

An abstract method to be implemented in the inherit classes. Is called by doStart() method. Parameters and comprovations before running the driver may be initialized and checked.

Returns:
bool successful
virtual bool iri_base_driver::IriBaseDriver::stopDriver ( void  ) [pure virtual]

User Stop Driver.

An abstract method to be implemented in the inherit classes. Is called by doStop() method. Updates necessary driver variables according to the state.

Returns:
bool successful

Tries Access to Driver.

Tries access to driver

Returns:
true if the lock was adquired, false otherwise

Definition at line 21 of file iri_base_driver.cpp.

Unlock Driver.

Unlocks access to the driver class

Definition at line 16 of file iri_base_driver.cpp.


Member Data Documentation

pthread_mutex_t iri_base_driver::IriBaseDriver::access_ [protected]

variable to handle the mutual exclusion mechanism

this variable is automatically initialized when an object of this class or any inherited class is created and holds all the necessary information to handle any shared resource.

Definition at line 70 of file iri_base_driver.h.

driver unique identifier

This value is used to identify each driver. Must be set before changing the driver_base::state=run. Use the abstract function setDriverId().

Definition at line 60 of file iri_base_driver.h.

Definition at line 84 of file iri_base_driver.h.


The documentation for this class was generated from the following files:


iri_base_driver
Author(s): Joan Perez, jnperez at iri.upc.edu
autogenerated on Fri Dec 6 2013 19:58:57