ChirpSim
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Private Attributes | List of all members
ChirpIrSensor Class Reference

The ChirpIrSensor class represents the distance sensors on the Chirp robot. More...

#include <irsensor.h>

Inheritance diagram for ChirpIrSensor:
Inheritance graph

Public Member Functions

 ChirpIrSensor (PhysicalObject *robot, QPointF position, float rotationAngle, float reach, float maxValue, float sensorWidth, uint rays)
 
unsigned value ()
 Gets the distance value of the sensor. More...
 
PhysicalObjectobjectHit ()
 Gets the closest object hit by the ray. More...
 
void update ()
 Called by the parent robot each step to update the value of the sensor. More...
 

Private Attributes

PhysicalObject_parentBody
 
QPointF _position
 
float _maxDistance
 
float _maxValue
 
QVector< float > _fractions
 
float _baseAngle
 
float _sensorWidth
 
uint _rays
 
IrSensorRayCastCallback _callback
 

Detailed Description

The ChirpIrSensor class represents the distance sensors on the Chirp robot.

These are infrared LEDs with a phototransistor to measure reflected light from the LEDs. It gives a measure of distance from an object, but requires close proximity before the value changes much.

Constructor & Destructor Documentation

ChirpIrSensor::ChirpIrSensor ( PhysicalObject robot,
QPointF  position,
float  rotationAngle,
float  reach,
float  maxValue,
float  sensorWidth,
uint  rays 
)
explicit

Member Function Documentation

PhysicalObject * ChirpIrSensor::objectHit ( )
virtual

Gets the closest object hit by the ray.

Returns
The closest object hit by the ray.

Implements Sensor.

References _callback, and IrSensorRayCastCallback::objectHit().

Here is the call graph for this function:

void ChirpIrSensor::update ( )
virtual

Called by the parent robot each step to update the value of the sensor.

Implements Sensor.

References _baseAngle, _callback, _fractions, _maxDistance, _parentBody, _position, _rays, _sensorWidth, PhysicalObject::body(), IrSensorRayCastCallback::fraction(), and IrSensorRayCastCallback::reset().

Here is the call graph for this function:

unsigned ChirpIrSensor::value ( )
virtual

Gets the distance value of the sensor.

Returns
The distance value of the sensor.

Implements Sensor.

References _fractions, _maxValue, clamp(), and max().

Here is the call graph for this function:

Member Data Documentation

float ChirpIrSensor::_baseAngle
private

Referenced by ChirpIrSensor(), and update().

IrSensorRayCastCallback ChirpIrSensor::_callback
private

Referenced by objectHit(), and update().

QVector<float> ChirpIrSensor::_fractions
private

Referenced by ChirpIrSensor(), update(), and value().

float ChirpIrSensor::_maxDistance
private

Referenced by ChirpIrSensor(), and update().

float ChirpIrSensor::_maxValue
private

Referenced by ChirpIrSensor(), and value().

PhysicalObject* ChirpIrSensor::_parentBody
private

Referenced by ChirpIrSensor(), and update().

QPointF ChirpIrSensor::_position
private

Referenced by ChirpIrSensor(), and update().

uint ChirpIrSensor::_rays
private

Referenced by ChirpIrSensor(), and update().

float ChirpIrSensor::_sensorWidth
private

Referenced by ChirpIrSensor(), and update().


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