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

Inheritance diagram for PhyObject2DWrapper:

Public Types

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

Public Member Functions

QColor color () const
 Returns the color to use when rendering this.
 
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.
 
virtual void computeLinearViewFieldOccupiedRange (const wMatrix &mtr, double &minAngle, double &maxAngle, double &distance) const =0
 Computes the portion of a linear the view field occupied by this object.
 
bool getStatic () const
 Returns true if the object is static.
 
virtual PhyObjectphyObject ()=0
 Returns a pointer to the wrapped PhyObject.
 
virtual const PhyObjectphyObject () const =0
 Returns a pointer to the wrapped PhyObject (const version)
 
wVector position () const
 Returns the position of the object.
 
void setColor (QColor color)
 Sets the color to use when rendering this.
 
void setPosition (wVector pos)
 Sets the position of the object in the plane.
 
virtual void setPosition (real x, real y)=0
 Sets the position of the object in the plane.
 
virtual void setStatic (bool s)
 Sets whether the object is static or not.
 
void setTexture (QString textureName)
 Set the texture to use when rendering this.
 
void setUseColorTextureOfOwner (bool b)
 Sets whether this will be rendered with the color and texture of our owner (if we have one)
 
QString texture () const
 Returns the name of the texture.
 
virtual Type type () const =0
 Returns the type of this wrapper object.
 
bool useColorTextureOfOwner () const
 Returns whether this will be rendered with the color and texture of the owner (if we have one)
 
virtual WObjectwObject ()
 Returns a pointer to the wrapped object.
 
virtual const WObjectwObject () const
 Returns a pointer to the wrapped object (const version)
 

Protected Member Functions

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

Protected Attributes

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

Friends

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

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 50 of file wheeledexperimenthelper.h.

Member Enumeration Documentation

enum Type

The possible type of wrapped objects.

Definition at line 56 of file wheeledexperimenthelper.h.

Constructor & Destructor Documentation

PhyObject2DWrapper ( Arena arena)
protected

Constructor.

Parameters
arenathe arena in which this object lives

Definition at line 198 of file wheeledexperimenthelper.cpp.

~PhyObject2DWrapper ( )
protectedvirtual

Destructor.

Definition at line 204 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 260 of file wheeledexperimenthelper.cpp.

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

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, Cylinder2DWrapper, and Box2DWrapper.

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

virtual void computeLinearViewFieldOccupiedRange ( const wMatrix mtr,
double &  minAngle,
double &  maxAngle,
double &  distance 
) 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. 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 if the object is behind the camera.

Parameters
mtrthe matrix describing the camera (see function description)
minAnglethis is set to the minimum angle of the view field occupied by the object
maxAnglethis is set to the maximum angle of the view field occupied by the object
distancethis is set to the distance of the object from the camera. It is negative if the object is not visible by the camera

Implemented in WheeledRobot2DWrapper, Cylinder2DWrapper, and Box2DWrapper.

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 226 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, Cylinder2DWrapper, and Box2DWrapper.

Referenced by Arena::delete2DObject(), PhyObject2DWrapper::getStatic(), 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, Cylinder2DWrapper, and Box2DWrapper.

void setColor ( QColor  color)

Sets the color to use when rendering this.

Parameters
colorthe color to use when rendering this

Definition at line 255 of file wheeledexperimenthelper.cpp.

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

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 235 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, 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 Cylinder2DWrapper, and Box2DWrapper.

Definition at line 219 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 245 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 265 of file wheeledexperimenthelper.cpp.

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

QString texture ( ) const

Returns the name of the texture.

Returns
the name of the texture

Definition at line 250 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, Cylinder2DWrapper, and Box2DWrapper.

Referenced by KheperaSampledProximityIRSensor::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 270 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 209 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 214 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 281 of file wheeledexperimenthelper.h.

Member Data Documentation


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