class mrpt::hwdrivers::CPhidgetInterfaceKitProximitySensors
Overview
: An interface for the phidget Interface kit board (1018).
Adrien BARRAL - Robopec (aba@robopec.com).
An interface for the Phidgets Interface kit board (part number 1018) on which it could be plugged either an Sharp IR adaptater board (phidget’s part number : 1101),or a MaxBotix EZ-1 sonar (phidget’s part number : 1118). The configuration file describe what is plugged to this board, and the geometry of the sensors on the robots. See the example below.
[PhidgetInterfaceKitProximitySensors] sensorLabel = FrontProximitySensors process_rate = 100 // Integer value in Hz (common to all sensors), default value is 50Hz. displayRecapitulativeInformations = true // default value = false. serialNumber = 12345 // The interface kit serial number (Integer value), default value is -1. sensor1 = SHARP-30cm // sharp InfraRed sensor 30cm range (string value). capital to convert raw data to range data (in meters). pose1_x = 0 // position on the robot (float value in meters) pose1_y = 0 pose1_z = 0.5 pose1_yaw = -45.0 // Angles in degrees (float value). pose1_pitch = 0 pose1_roll = 0 //... sensorn = EZ1 // Maxbotix Ultrasound sonar posen_x = 0 // ...
- The maximum number of sensors on this board is 8. Sensor 1 is the first sensor. If you haven’t plugged any sensor on an entry of the board, you haven’t to specify anyithing about this sensor in the configuration file. The following table enumerate the different sensors supported by this class. begin{tabular}{|c|c|c}
hline Part Number & Config file indentifiant & IR or US hline MaxBotix EZ-1 Sonar Sensor & EZ1 & US \ GP2D12 & SHARP-30cm & IR \ GP2Y0A21** & SHARP-80cm & IR \ hline
end{tabular}
This isn’t an event based implementation of the phidget library. That means that when an instanciation of a CPhidgetInterfaceKitProximitySensors is done, the constructor will block during in the worst case 200ms, if the board isn’t found, an exception will be thrown. mrpt::obs::CObservation returned by this class is a CObservationRange. CObservationrange::minSensorDistance will be the minimum of the minimum of the sensor distances, e.g if you plug to the interface kit a GP2D12 (min range 4 cm) and a GP2Y0A21 (min range 8 cm), then CObservationrange::minSensorDistance = min(0.04,0.08) = 0.04. Respectively for the maximal range. {The Phidget library use udev. By default, udev require to be root to be launched, if you want to be able to run a program which use a phidget board without be root, you must modify files in /etc/udev/rules.d .}
#include <mrpt/hwdrivers/CPhidgetInterfaceKitProximitySensors.h> class CPhidgetInterfaceKitProximitySensors: public mrpt::system::COutputLogger, public mrpt::hwdrivers::CGenericSensor { public: // construction CPhidgetInterfaceKitProximitySensors(); // methods void getObservation(mrpt::obs::CObservationRange& outObservation); virtual void initialize(); virtual void doProcess(); };
Inherited Members
public: // structs struct TMsg; // methods CGenericSensor& operator = (const CGenericSensor&); virtual void doProcess() = 0;
Construction
CPhidgetInterfaceKitProximitySensors()
Constructor.
Parameters:
serialNumber |
The board’s serial number. Set -1 to choose the first available board |
Methods
void getObservation(mrpt::obs::CObservationRange& outObservation)
This method tries to get a set of range measurements from the IR sensors.
Parameters:
outThereIsObservation |
Will be true if an observation was sucessfully received. |
virtual void initialize()
Initialize the sensor according to the parameters previously read in the configuration file.
Parameters:
throw |
an exception if the board could not be found. |
throw |
an exception if the process rate can’t be set on one of the board channel. |
virtual void doProcess()
This method should be called periodically.
Period depend on the process_rate in the configuration file.