LinearCamera Class Reference

An helper class for linear camera sensors of various robots. More...

Inheritance diagram for LinearCamera:

Public Member Functions

 LinearCamera (WObject *obj, wMatrix mtr, double aperture, unsigned int numReceptors, QColor backgroundColor)
 Constructor.
 
virtual ~LinearCamera ()
 Destructor.
 
const QColor & colorForReceptor (int i) const
 Returns the color perceived by the i-th receptor.
 
void drawCamera (bool d)
 Sets whether to draw the linear camera or not.
 
double getAperture () const
 Returns the aperture of the sensor in radiants.
 
QColor getBackgroundColor () const
 Returns the background color.
 
unsigned int getNumReceptors () const
 Returns the number of receptors.
 
void setBackgroundColor (QColor color)
 Sets the background color.
 
void update ()
 Updates the sensor reading.
 
- Public Member Functions inherited from ConcurrentResourcesUser
void addUsableResource (QString resource)
 
void addUsableResources (QStringList resources)
 
void declareResource (QString name, T *resource, QString lockBuddy="")
 
void deleteResource (QString name)
 
T * getResource (QString name, bool *resourceExists=NULL)
 
bool hasResource (QString name) const
 
void removeAllUsableResources ()
 
void removeUsableResource (QString resource)
 
void removeUsableResources (QStringList resources)
 
virtual void shareResourcesWith (ResourcesUser *buddy)
 
void usableResources (QStringList resources)
 
bool usedResourcesExist (QStringList *nonExistingResources=NULL) const
 

Additional Inherited Members

- Public Types inherited from ConcurrentResourcesUser
typedef
Resource::ResourceChangeType 
ResourceChangeType
 
- Protected Member Functions inherited from ConcurrentResourcesUser
T * getResource ()
 
ResourcesUseroperator= (const ResourcesUser &other)
 
 ResourcesUser ()
 
 ResourcesUser (const ResourcesUser &other)
 
- Protected Attributes inherited from ConcurrentResourcesUser
ResourceCollectionHolder m_resources
 

Detailed Description

An helper class for linear camera sensors of various robots.

This class has all that is needed to implement a linear camera sensor. It is fully parametrized, so to implement an actual sensor one just needs to instantiate it with the correct set of parameters. The camera is attached to an object and its transformation matrix is relative to the object to which it is attached. The up vector is the local Z axis, the camera points towards X and is on the XY plane. The camera only takes into account the objects in the "2dobjects" resource (a list of PhyObject2DWrapper objects). The aperture and the number of receptors can be specified at construction time. Moreover the sensor takes into account visual occlusion. To work, this class need to access the arena object, so a resource named "arena" which points to the instance of the arena should be present.

Note
The current implementation of the camera doesn't work well with occluding objects. In fact the occlusion is only computed on the basis of the distance between the object center and the camera. If however you have e.g. a cylinder in front of big wall, the cylinder can be more distant than the wall and so being considered behind the wall.
When more than one object of different colors hits a single receptor, here we take the average of the colors (weighted by the percentage of the receptor occupied by each object). This is not physically correct, so please be careful when using big receptors with a lot of objects of different colors.

Definition at line 223 of file sensors.h.

Constructor & Destructor Documentation

LinearCamera ( WObject obj,
wMatrix  mtr,
double  aperture,
unsigned int  numReceptors,
QColor  backgroundColor 
)

Constructor.

Parameters
objthe object to which the sensor is attached. This cannot be NULL
mtrthe transformation matrix relative to the object to which the sensor is attached. The up vector is the local Z axis, the camera points towards X and is on the XY plane.
aperturethe aperture of the sensor in radiants
numReceptorsthe number of receptors
backgroundColorthe background color (used when no object is perceived by a given receptor)

Definition at line 488 of file sensors.cpp.

References ConcurrentResourcesUser::addUsableResource().

~LinearCamera ( )
virtual

Destructor.

Definition at line 508 of file sensors.cpp.

Member Function Documentation

const QColor& colorForReceptor ( int  i) const
inline

Returns the color perceived by the i-th receptor.

Parameters
ithe index of the photoreceptor to return
Returns
the color perceived by the receptor

Definition at line 257 of file sensors.h.

Referenced by EpuckLinearCameraSensor::update(), and MarXbotLinearCameraSensor::update().

void drawCamera ( bool  d)

Sets whether to draw the linear camera or not.

Parameters
dif true the camera is drawn, if false it is not

Definition at line 776 of file sensors.cpp.

double getAperture ( ) const
inline

Returns the aperture of the sensor in radiants.

Returns
the aperture of the sensor in radiants

Definition at line 267 of file sensors.h.

QColor getBackgroundColor ( ) const
inline

Returns the background color.

Returns
the background color (i.e. the color used when no object is perceived by a given receptor)

Definition at line 288 of file sensors.h.

unsigned int getNumReceptors ( ) const
inline

Returns the number of receptors.

Returns
the number of receptors

Definition at line 277 of file sensors.h.

void setBackgroundColor ( QColor  color)
inline

Sets the background color.

Parameters
colorthe background color (i.e. the color used when no object is perceived by a given receptor)

Definition at line 299 of file sensors.h.

void update ( )

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