A single proximity IR sensor. More...
Public Member Functions | |
SingleIR () | |
Constructor. More... | |
SingleIR (WObject *obj, wMatrix mtr, double minDist, double maxDist, double aperture, unsigned int numRays) | |
Constructor. More... | |
SingleIR (const SingleIR &other) | |
Copy constructor. More... | |
~SingleIR () | |
Destructor. More... | |
double | getAperture () const |
Returns the aperture of the sensor in degrees. More... | |
double | getMaxDistance () const |
Returns the distance above which collision are not reported. More... | |
double | getMinDistance () const |
Returns the distance below which collisions are not reported. More... | |
unsigned int | getNumRays () const |
Returns the number of rays used to simulate the sensor. More... | |
const WObject * | getObject () const |
Returns the object to which the sensor is attached. More... | |
const wVectorT< true > & | getPosition () const |
Returns the position relative to the object to which the sensor is attached. More... | |
const RayCastHit & | getRayCastHit () const |
Returns information about the last ray cast hit. More... | |
const wMatrix & | getTransformation () const |
Returns the transformation matrix relative to the object to which the sensor is attached. More... | |
bool | isValid () const |
Returns true if the sensor is valid. More... | |
SingleIR & | operator= (const SingleIR &other) |
Copy operator. More... | |
void | set (WObject *obj, wMatrix mtr, double minDist, double maxDist, double aperture, unsigned int numRays) |
Configures the sensor. More... | |
void | setGraphicalProperties (bool drawSensor, bool drawRay=false, bool drawRealRay=false) |
Sets graphical properties, i.e. whether sensors are drawn and how. More... | |
void | update () |
Updates sensor reading. More... | |
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
-
obj the object to which the sensor is attached. This cannot be NULL (otherwise an invalid sensor is created) mtr the transformation matrix relative to the object to which the sensor is attached minDist the distance below which collisions are not reported maxDist the distance above which collision are not reported aperture the aperture of the sensor in degrees numRays the 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.
Copy constructor.
- Parameters
-
other the object to copy
Definition at line 344 of file sensorcontrollers.cpp.
~SingleIR | ( | ) |
Destructor.
Definition at line 387 of file sensorcontrollers.cpp.
Member Function Documentation
|
inline |
Returns the aperture of the sensor in degrees.
- Returns
- the aperture of the sensor in degrees
Definition at line 379 of file sensorcontrollers.h.
|
inline |
Returns the distance above which collision are not reported.
- Returns
- the distance above which collision are not reported
Definition at line 369 of file sensorcontrollers.h.
|
inline |
Returns the distance below which collisions are not reported.
- Returns
- the distance below which collisions are not reported
Definition at line 359 of file sensorcontrollers.h.
|
inline |
Returns the number of rays used to simulate the sensor.
- Returns
- the number of rays used to simulate the sensor
Definition at line 389 of file sensorcontrollers.h.
|
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.
|
inline |
Returns the position relative to the object to which the sensor is attached.
- Returns
- the position relative to the object to which the sensor is attached
Definition at line 349 of file sensorcontrollers.h.
|
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.
|
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.
|
inline |
Returns true if the sensor is valid.
- Returns
- true if the sensor is valid
Definition at line 399 of file sensorcontrollers.h.
Referenced by SingleIR::update().
Copy operator.
- Parameters
-
other the 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
-
obj the object to which the sensor is attached. This cannot be NULL (otherwise an invalid sensor is created) mtr the transformation matrix relative to the object to which the sensor is attached minDist the distance below which collisions are not reported maxDist the distance above which collision are not reported aperture the aperture of the sensor in degrees numRays the 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
-
drawSensor if true the sensor is drawn drawRay if true sensor rays are drawn drawRealRay if 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:
- worldsim/include/sensorcontrollers.h
- worldsim/src/sensorcontrollers.cpp