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, double maxDistance, QColor backgroundColor)
 Constructor. More...
 
virtual ~LinearCamera ()
 Destructor. More...
 
const QColor & colorForReceptor (int i) const
 Returns the color perceived by the i-th receptor. More...
 
void drawCamera (bool d)
 Sets whether to draw the linear camera or not. More...
 
double getAperture () const
 Returns the aperture of the sensor in radiants. More...
 
QColor getBackgroundColor () const
 Returns the background color. More...
 
unsigned int getNumReceptors () const
 Returns the number of receptors. More...
 
void ignoreWalls (bool ignore)
 Sets whether walls are ignored or not. More...
 
void setBackgroundColor (QColor color)
 Sets the background color. More...
 
void update ()
 Updates the sensor reading. More...
 
bool wallsIgnored () const
 Whether walls are ignored or not. More...
 
- 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 ResourcesUser
typedef Resource::ResourceChangeType ResourceChangeType
 
- Public Types inherited from Resource
enum  ResourceChangeType
 
- Protected Member Functions inherited from ConcurrentResourcesUser
T * getResource ()
 
- Protected Member Functions inherited from ResourcesUser
 ResourcesUser (const ResourcesUser &other)
 
virtual void notifyResourceChange (ResourceHandler *resource, ResourceChangeType changeType)=0
 
ResourcesUseroperator= (const ResourcesUser &other)
 
- Protected Attributes inherited from ResourcesUser
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. For this reason it is possible to ignore all walls using the ignoreWalls() function (this is usefult if e.g. you have only perimetral walls of the same color as the background)
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 232 of file sensors.h.

Constructor & Destructor Documentation

LinearCamera ( WObject obj,
wMatrix  mtr,
double  aperture,
unsigned int  numReceptors,
double  maxDistance,
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
maxDistancethe distance above which objects are not seen anymore
backgroundColorthe background color (used when no object is perceived by a given receptor)

Definition at line 490 of file sensors.cpp.

References ConcurrentResourcesUser::addUsableResource().

~LinearCamera ( )
virtual

Destructor.

Definition at line 512 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 268 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 704 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 278 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 299 of file sensors.h.

unsigned int getNumReceptors ( ) const
inline

Returns the number of receptors.

Returns
the number of receptors

Definition at line 288 of file sensors.h.

void ignoreWalls ( bool  ignore)
inline

Sets whether walls are ignored or not.

See the note in the class description

Parameters
ignorewhether to ignore walls or not

Definition at line 328 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 310 of file sensors.h.

bool wallsIgnored ( ) const
inline

Whether walls are ignored or not.

See the note in the class description

Returns
true if walls are ignored, false otherwise

Definition at line 339 of file sensors.h.


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