A class wrapping a PhyObject to add methods suitable for wheeled robots simulations. More...
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 PhyObject * | phyObject ()=0 |
Returns a pointer to the wrapped PhyObject. More... | |
virtual const PhyObject * | phyObject () const =0 |
Returns a pointer to the wrapped PhyObject (const version) More... | |
wVector | position () const |
Returns the position of the object. More... | |
const wMatrix & | previousMatrix () 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 WObject * | wObject () |
Returns a pointer to the wrapped object. More... | |
virtual const WObject * | wObject () 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
|
protected |
Constructor.
- Parameters
-
arena the arena in which this object lives
Definition at line 392 of file wheeledexperimenthelper.cpp.
|
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().
|
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
-
robot the robot from which the distance should be computed distance the computed distance angle the 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().
|
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
-
mtr the matrix describing the camera (see function description) rangesAndColors the list of occupied ranges and their color distance this is set to the distance of the object from the camera. It is negative if the object is not visible by the camera maxDistance this 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().
|
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().
|
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.
wVector position | ( | ) | const |
Returns the position of the object.
- Returns
- the position of the object
Definition at line 451 of file wheeledexperimenthelper.cpp.
References WObject::matrix(), and PhyObject2DWrapper::wObject().
Referenced by Box2DWrapper::computeDistanceAndOrientationFromRobot(), Cylinder2DWrapper::computeDistanceAndOrientationFromRobot(), Sphere2DWrapper::computeDistanceAndOrientationFromRobot(), and WheeledRobot2DWrapper::computeDistanceAndOrientationFromRobot().
|
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
-
color the color to use when rendering this
Definition at line 466 of file wheeledexperimenthelper.cpp.
References WObject::setColor(), and PhyObject2DWrapper::wObject().
|
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
-
b if true the object is set to kinematic behaviour c if 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
-
pos the new position (the z coordinate is discarded)
Definition at line 446 of file wheeledexperimenthelper.cpp.
Sets the position of the object in the plane.
Not all type of objects can be moved
- Parameters
-
x the new x coordinate y the new y coordinate
Implemented in WheeledRobot2DWrapper, Sphere2DWrapper, Cylinder2DWrapper, and Box2DWrapper.
|
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
-
s if 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
-
textureName the 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
-
b if 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().
|
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().
|
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().
|
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().
|
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 |
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
|
protected |
The pointer to the arena in which this object lives.
Definition at line 355 of file wheeledexperimenthelper.h.
Referenced by Box2DWrapper::computeDistanceAndOrientationFromRobot(), Cylinder2DWrapper::computeDistanceAndOrientationFromRobot(), Sphere2DWrapper::computeDistanceAndOrientationFromRobot(), and WheeledRobot2DWrapper::computeDistanceAndOrientationFromRobot().
The documentation for this class was generated from the following files:
- experiments/include/wheeledexperimenthelper.h
- experiments/src/wheeledexperimenthelper.cpp