SingleIR Class Reference

A single proximity IR sensor. More...

Public Member Functions

 SingleIR ()
 Constructor.
 
 SingleIR (WObject *obj, wMatrix mtr, double minDist, double maxDist, double aperture, unsigned int numRays)
 Constructor.
 
 SingleIR (const SingleIR &other)
 Copy constructor.
 
 ~SingleIR ()
 Destructor.
 
double getAperture () const
 Returns the aperture of the sensor in degrees.
 
double getMaxDistance () const
 Returns the distance above which collision are not reported.
 
double getMinDistance () const
 Returns the distance below which collisions are not reported.
 
unsigned int getNumRays () const
 Returns the number of rays used to simulate the sensor.
 
const WObjectgetObject () const
 Returns the object to which the sensor is attached.
 
const RayCastHitgetRayCastHit () const
 Returns information about the last ray cast hit.
 
const wMatrixgetTransformation () const
 Returns the transformation matrix relative to the object to which the sensor is attached.
 
bool isValid () const
 Returns true if the sensor is valid.
 
SingleIRoperator= (const SingleIR &other)
 Copy operator.
 
void set (WObject *obj, wMatrix mtr, double minDist, double maxDist, double aperture, unsigned int numRays)
 Configures the sensor.
 
void setGraphicalProperties (bool drawSensor, bool drawRay=false, bool drawRealRay=false)
 Sets graphical properties, i.e. whether sensors are drawn and how.
 
void update ()
 Updates sensor reading.
 

Detailed Description

A single proximity IR sensor.

This class models a single IR sensor. The sensor is attached to a WObject and its position and orientation is given by the transformation matrix relative to the WObject. The sensor has an aperture (given in degrees) and all the rays lie on the local XZ plane. The center of the aperture is in the direction of the positive Z axis. The sensor is simulated using ray casts. It is possible to specify the number of rays to use to simulate the sensor. Of course more rays give a more accurate response but are more computationally expensive. Using a single ray implies a zero aperture. The upper part of the sensor is towards positive Y

Definition at line 222 of file sensorcontrollers.h.

Constructor & Destructor Documentation

SingleIR ( )

Constructor.

This creates an invalid sensor. You must call the set() function to configure the sensors

Definition at line 297 of file sensorcontrollers.cpp.

References RayCastHit::distance, and RayCastHit::object.

SingleIR ( WObject obj,
wMatrix  mtr,
double  minDist,
double  maxDist,
double  aperture,
unsigned int  numRays 
)

Constructor.

Parameters
objthe object to which the sensor is attached. This cannot be NULL (otherwise an invalid sensor is created)
mtrthe transformation matrix relative to the object to which the sensor is attached
minDistthe distance below which collisions are not reported
maxDistthe distance above which collision are not reported
aperturethe aperture of the sensor in degrees
numRaysthe number of rays used to simulate the sensor. If set to 0, creates an invalid sensor

Definition at line 316 of file sensorcontrollers.cpp.

References RayCastHit::distance, and RayCastHit::object.

SingleIR ( const SingleIR other)

Copy constructor.

Parameters
otherthe object to copy

Definition at line 344 of file sensorcontrollers.cpp.

~SingleIR ( )

Destructor.

Definition at line 387 of file sensorcontrollers.cpp.

Member Function Documentation

double getAperture ( ) const
inline

Returns the aperture of the sensor in degrees.

Returns
the aperture of the sensor in degrees

Definition at line 367 of file sensorcontrollers.h.

double getMaxDistance ( ) const
inline

Returns the distance above which collision are not reported.

Returns
the distance above which collision are not reported

Definition at line 357 of file sensorcontrollers.h.

double getMinDistance ( ) const
inline

Returns the distance below which collisions are not reported.

Returns
the distance below which collisions are not reported

Definition at line 347 of file sensorcontrollers.h.

unsigned int getNumRays ( ) const
inline

Returns the number of rays used to simulate the sensor.

Returns
the number of rays used to simulate the sensor

Definition at line 377 of file sensorcontrollers.h.

const WObject* getObject ( ) const
inline

Returns the object to which the sensor is attached.

Returns
the object to which the sensor is attached

Definition at line 325 of file sensorcontrollers.h.

const RayCastHit& getRayCastHit ( ) const
inline

Returns information about the last ray cast hit.

This function returns a const reference to the structure with information about the ray cast hit that was used to compute the activation (i.e. the ray cast hit with minimal distance). The reference is valid for the whole lifetime of this object (although the values can change after calls to update()). Use the update() function to perform a sensor reading prior to calling this function.

Returns
the activation of the sensor (valid for the whole lifetime of this object)

Definition at line 288 of file sensorcontrollers.h.

const wMatrix& getTransformation ( ) const
inline

Returns the transformation matrix relative to the object to which the sensor is attached.

Returns
the transformation matrix relative to the object to which the sensor is attached

Definition at line 337 of file sensorcontrollers.h.

bool isValid ( ) const
inline

Returns true if the sensor is valid.

Returns
true if the sensor is valid

Definition at line 387 of file sensorcontrollers.h.

Referenced by SingleIR::update().

SingleIR & operator= ( const SingleIR other)

Copy operator.

Parameters
otherthe object to copy
Returns
a reference to this object

Definition at line 362 of file sensorcontrollers.cpp.

void set ( WObject obj,
wMatrix  mtr,
double  minDist,
double  maxDist,
double  aperture,
unsigned int  numRays 
)

Configures the sensor.

Parameters
objthe object to which the sensor is attached. This cannot be NULL (otherwise an invalid sensor is created)
mtrthe transformation matrix relative to the object to which the sensor is attached
minDistthe distance below which collisions are not reported
maxDistthe distance above which collision are not reported
aperturethe aperture of the sensor in degrees
numRaysthe number of rays used to simulate the sensor. If set to 0, creates an invalid sensor

Definition at line 429 of file sensorcontrollers.cpp.

References RayCastHit::distance, and RayCastHit::object.

void setGraphicalProperties ( bool  drawSensor,
bool  drawRay = false,
bool  drawRealRay = false 
)

Sets graphical properties, i.e. whether sensors are drawn and how.

By default the sensor is not drawn

Parameters
drawSensorif true the sensor is drawn
drawRayif true sensor rays are drawn
drawRealRayif true the actual ray range is drawn, otherwise only the direction of the rays is given

Definition at line 452 of file sensorcontrollers.cpp.

void update ( )

Updates sensor reading.

This function effectively executes the ray casts and store the sensor activation and the structure with information about the ray cast hit

Definition at line 392 of file sensorcontrollers.cpp.

References RayCastHit::distance, SingleIR::isValid(), WObject::matrix(), RayCastHit::object, wMatrix::transformVector(), WObject::world(), and World::worldRayCast().


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