A class wrapping a PhyObject to add methods suitable for wheeled robots simulations. More...

Inheritance diagram for PhyObject2DWrapper:

Classes

class  AngularRangeAndColor
 The structure with angular range and color used by the computeLinearViewFieldOccupiedRange() function. More...
 

Public Types

enum  Type {
  Plane = 0, Wall, Box, RectangularTargetArea,
  Cylinder, SmallCylinder, BigCylinder, CircularTargetArea,
  LightBulb, WheeledRobot, NumberOfDifferentTypes
}
 The possible type of wrapped objects. More...
 

Public Member Functions

QColor color () const
 Returns the color to use when rendering this. More...
 
virtual bool computeDistanceAndOrientationFromRobot (const WheeledRobot2DWrapper &robot, double &distance, double &angle) const =0
 Computes the distance and orientation of this object respect to the given robot. More...
 
virtual void computeLinearViewFieldOccupiedRange (const wMatrix &mtr, QVector< AngularRangeAndColor > &rangesAndColors, double &distance, double maxDistance) const =0
 Computes the portion of a linear the view field occupied by this object. More...
 
bool getKinematic () const
 Returns true if the object has kinematic behaviour. More...
 
bool getStatic () const
 Returns true if the object is static. More...
 
virtual PhyObjectphyObject ()=0
 Returns a pointer to the wrapped PhyObject. More...
 
virtual const PhyObjectphyObject () const =0
 Returns a pointer to the wrapped PhyObject (const version) More...
 
wVector position () const
 Returns the position of the object. More...
 
const wMatrixpreviousMatrix () const
 Returns the transformation matrix of the previous time-step. More...
 
void setColor (QColor color)
 Sets the color to use when rendering this. More...
 
virtual void setKinematic (bool b, bool c=false)
 Sets whether the object is kinematic or not. More...
 
void setPosition (wVector pos)
 Sets the position of the object in the plane. More...
 
virtual void setPosition (real x, real y)=0
 Sets the position of the object in the plane. More...
 
virtual void setStatic (bool s)
 Sets whether the object is static or not. More...
 
void setTexture (QString textureName)
 Set the texture to use when rendering this. More...
 
void setUseColorTextureOfOwner (bool b)
 Sets whether this will be rendered with the color and texture of our owner (if we have one) More...
 
void storePreviousMatrix ()
 Stores the current matrix in the previousMatrix. More...
 
QString texture () const
 Returns the name of the texture. More...
 
virtual Type type () const =0
 Returns the type of this wrapper object. More...
 
bool useColorTextureOfOwner () const
 Returns whether this will be rendered with the color and texture of the owner (if we have one) More...
 
virtual WObjectwObject ()
 Returns a pointer to the wrapped object. More...
 
virtual const WObjectwObject () const
 Returns a pointer to the wrapped object (const version) More...
 

Protected Member Functions

 PhyObject2DWrapper (Arena *arena)
 Constructor. More...
 
virtual ~PhyObject2DWrapper ()
 Destructor. More...
 

Protected Attributes

Arena *const m_arena
 The pointer to the arena in which this object lives. More...
 

Friends

class Arena
 The Arena class is friend to be able to instantiate and delete this class. More...
 

Detailed Description

A class wrapping a PhyObject to add methods suitable for wheeled robots simulations.

This class wraps a PhyObject and adds methods which should be used when doing wheeled robots simulations to ensure everything works well. Objects cannot be instantiated directly, they are returned by functions of the Arena class

Definition at line 51 of file wheeledexperimenthelper.h.

Member Enumeration Documentation

enum Type

The possible type of wrapped objects.

Definition at line 57 of file wheeledexperimenthelper.h.

Constructor & Destructor Documentation

PhyObject2DWrapper ( Arena arena)
protected

Constructor.

Parameters
arenathe arena in which this object lives

Definition at line 392 of file wheeledexperimenthelper.cpp.

~PhyObject2DWrapper ( )
protectedvirtual

Destructor.

Definition at line 399 of file wheeledexperimenthelper.cpp.

Member Function Documentation

QColor color ( ) const

Returns the color to use when rendering this.

Returns
the color to use when rendering this

Definition at line 471 of file wheeledexperimenthelper.cpp.

References WObject::color(), and PhyObject2DWrapper::wObject().

Referenced by Box2DWrapper::computeLinearViewFieldOccupiedRange().

virtual bool computeDistanceAndOrientationFromRobot ( const WheeledRobot2DWrapper robot,
double &  distance,
double &  angle 
) const
pure virtual

Computes the distance and orientation of this object respect to the given robot.

This function computes the distance of this object from the given robot. The distance is computed between the nearest points of the two objects. The robot is always modelled as a vertical cylindrical object. The function returns false if it makes no sense to compute the distance

Parameters
robotthe robot from which the distance should be computed
distancethe computed distance
anglethe computed orientation
Returns
false if the distance couldn't be computed

Implemented in WheeledRobot2DWrapper, Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

Referenced by KheperaSampledProximityIRSensor::update(), KheperaSampledLightSensor::update(), EpuckSampledProximityIRSensor::update(), and MarXbotSampledProximityIRSensor::update().

virtual void computeLinearViewFieldOccupiedRange ( const wMatrix mtr,
QVector< AngularRangeAndColor > &  rangesAndColors,
double &  distance,
double  maxDistance 
) const
pure virtual

Computes the portion of a linear the view field occupied by this object.

This function must be implemented in subclasses to return the angular range occupied by the object on a linear camera described by the given matrix. Each of the range in the list has its own color. The Z axis of the matrix is the upvector, the camera lies on the XY plane and points towars the X axis (i.e. angles start from the X axis). If the object is not visible by the camera, this function returns a negative distance. The min angle can be greater than the max angle in a range if the object is behind the camera.

Parameters
mtrthe matrix describing the camera (see function description)
rangesAndColorsthe list of occupied ranges and their color
distancethis is set to the distance of the object from the camera. It is negative if the object is not visible by the camera
maxDistancethis is the maximum distance the camera can see. If the object is farther than this distance the function can safely return a negative distance (i.e. the object is not seen) and stop any other computation

Implemented in WheeledRobot2DWrapper, Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

bool getKinematic ( ) const

Returns true if the object has kinematic behaviour.

This function returns always true if the wrapped object is not a PhyObject (i.e. phyObject() returns NULL)

Returns
true if the object has kinematic behaviour

Definition at line 437 of file wheeledexperimenthelper.cpp.

References PhyObject::getKinematic(), and PhyObject2DWrapper::phyObject().

bool getStatic ( ) const

Returns true if the object is static.

This function returns always true if the wrapped object is not a PhyObject (i.e. phyObject() returns NULL)

Returns
true if the object is static (or if the wrapped object is not a phyObject)

Definition at line 421 of file wheeledexperimenthelper.cpp.

References PhyObject::getStatic(), and PhyObject2DWrapper::phyObject().

virtual PhyObject* phyObject ( )
pure virtual

Returns a pointer to the wrapped PhyObject.

You should avoid changing the PhyObject directly, use the methods of this class, instead. The returned pointer can be NULL if the wrapped object is not a phyObject

Returns
a pointer to the wrapped PhyObject

Implemented in WheeledRobot2DWrapper, Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

Referenced by Arena::delete2DObject(), PhyObject2DWrapper::getKinematic(), PhyObject2DWrapper::getStatic(), PhyObject2DWrapper::setKinematic(), PhyObject2DWrapper::setStatic(), and PhyObject2DWrapper::wObject().

virtual const PhyObject* phyObject ( ) const
pure virtual

Returns a pointer to the wrapped PhyObject (const version)

The returned pointer can be NULL if the wrapped object is not a phyObject

Returns
a const pointer to the wrapped PhyObject

Implemented in WheeledRobot2DWrapper, Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

const wMatrix& previousMatrix ( ) const
inline

Returns the transformation matrix of the previous time-step.

Returns
the transformation matrix of the previous time-step

Definition at line 334 of file wheeledexperimenthelper.h.

void setColor ( QColor  color)

Sets the color to use when rendering this.

Parameters
colorthe color to use when rendering this

Definition at line 466 of file wheeledexperimenthelper.cpp.

References WObject::setColor(), and PhyObject2DWrapper::wObject().

void setKinematic ( bool  b,
bool  c = false 
)
virtual

Sets whether the object is kinematic or not.

A kinematic object is not simulated by the physics simulator, but it can be taken into account in collisions by the arena. Not all type of objects can change between kinematic and dynamic

Parameters
bif true the object is set to kinematic behaviour
cif true the object collides with other objects even in kinematic mode, influencing them without being influenced (technically, we set its mass to 0 in Newton Game Dynamics engine)

Reimplemented in Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

Definition at line 430 of file wheeledexperimenthelper.cpp.

References PhyObject2DWrapper::phyObject(), and PhyObject::setKinematic().

Referenced by Box2DWrapper::setKinematic().

void setPosition ( wVector  pos)

Sets the position of the object in the plane.

The Z coordinate is discarded. Not all type of objects can be moved

Parameters
posthe new position (the z coordinate is discarded)

Definition at line 446 of file wheeledexperimenthelper.cpp.

virtual void setPosition ( real  x,
real  y 
)
pure virtual

Sets the position of the object in the plane.

Not all type of objects can be moved

Parameters
xthe new x coordinate
ythe new y coordinate

Implemented in WheeledRobot2DWrapper, Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

void setStatic ( bool  s)
virtual

Sets whether the object is static or not.

Not all type of objects can change between static and dynamic. This function does nothing if the wrapped object is not a PhyObject (i.e. phyObject() returns NULL)

Parameters
sif true the object will be static

Reimplemented in Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

Definition at line 414 of file wheeledexperimenthelper.cpp.

References PhyObject2DWrapper::phyObject(), and PhyObject::setStatic().

void setTexture ( QString  textureName)

Set the texture to use when rendering this.

Parameters
textureNamethe name of the texture

Definition at line 456 of file wheeledexperimenthelper.cpp.

References WObject::setTexture(), and PhyObject2DWrapper::wObject().

Referenced by Arena::createWall().

void setUseColorTextureOfOwner ( bool  b)

Sets whether this will be rendered with the color and texture of our owner (if we have one)

Parameters
bif true we will use the color and texture of our owner (if we have one

Definition at line 476 of file wheeledexperimenthelper.cpp.

References WObject::setUseColorTextureOfOwner(), and PhyObject2DWrapper::wObject().

void storePreviousMatrix ( )
inline

Stores the current matrix in the previousMatrix.

Call this to update the value of m_previousMatrix

Definition at line 324 of file wheeledexperimenthelper.h.

QString texture ( ) const

Returns the name of the texture.

Returns
the name of the texture

Definition at line 461 of file wheeledexperimenthelper.cpp.

References WObject::texture(), and PhyObject2DWrapper::wObject().

virtual Type type ( ) const
pure virtual

Returns the type of this wrapper object.

The type is used by e.g. sensors

Returns
the type of this wrapper object

Implemented in WheeledRobot2DWrapper, Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

Referenced by KheperaSampledProximityIRSensor::update(), KheperaSampledLightSensor::update(), EpuckSampledProximityIRSensor::update(), and MarXbotSampledProximityIRSensor::update().

bool useColorTextureOfOwner ( ) const

Returns whether this will be rendered with the color and texture of the owner (if we have one)

Returns
true if this will be rendered using the color and texture of our owner

Definition at line 481 of file wheeledexperimenthelper.cpp.

References WObject::useColorTextureOfOwner(), and PhyObject2DWrapper::wObject().

WObject * wObject ( )
virtual

Returns a pointer to the wrapped object.

You should avoid changing the wrapped directly, use the methods of this class, instead. The default implementation of this function simply calls phyObject()

Returns
a pointer to the wrapped object

Reimplemented in WheeledRobot2DWrapper.

Definition at line 404 of file wheeledexperimenthelper.cpp.

References PhyObject2DWrapper::phyObject().

Referenced by PhyObject2DWrapper::color(), PhyObject2DWrapper::position(), PhyObject2DWrapper::setColor(), PhyObject2DWrapper::setTexture(), PhyObject2DWrapper::setUseColorTextureOfOwner(), PhyObject2DWrapper::texture(), and PhyObject2DWrapper::useColorTextureOfOwner().

const WObject * wObject ( ) const
virtual

Returns a pointer to the wrapped object (const version)

The default implementation of this function simply calls phyObject()

Returns
a const pointer to the wrapped object

Reimplemented in WheeledRobot2DWrapper.

Definition at line 409 of file wheeledexperimenthelper.cpp.

References PhyObject2DWrapper::phyObject().

Friends And Related Function Documentation

friend class Arena
friend

The Arena class is friend to be able to instantiate and delete this class.

Definition at line 384 of file wheeledexperimenthelper.h.

Member Data Documentation


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