An helper class for linear camera sensors of various robots. More...
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 |
ResourcesUser & | operator= (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.
Constructor & Destructor Documentation
LinearCamera | ( | WObject * | obj, |
wMatrix | mtr, | ||
double | aperture, | ||
unsigned int | numReceptors, | ||
double | maxDistance, | ||
QColor | backgroundColor | ||
) |
Constructor.
- Parameters
-
obj the object to which the sensor is attached. This cannot be NULL mtr the 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. aperture the aperture of the sensor in radiants numReceptors the number of receptors maxDistance the distance above which objects are not seen anymore backgroundColor the background color (used when no object is perceived by a given receptor)
Definition at line 490 of file sensors.cpp.
References ConcurrentResourcesUser::addUsableResource().
|
virtual |
Destructor.
Definition at line 512 of file sensors.cpp.
Member Function Documentation
|
inline |
Returns the color perceived by the i-th receptor.
- Parameters
-
i the 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
-
d if true the camera is drawn, if false it is not
Definition at line 704 of file sensors.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void update | ( | ) |
Updates the sensor reading.
Definition at line 579 of file sensors.cpp.
References Arena::getObjects(), WObject::matrix(), farsa::max(), farsa::min(), farsa::normalizeRad(), and LinearCameraGraphic::setPerceivedColors().
Referenced by EpuckLinearCameraSensor::update(), and MarXbotLinearCameraSensor::update().
|
inline |
The documentation for this class was generated from the following files:
- experiments/include/sensors.h
- experiments/src/sensors.cpp