The class modelling an arena. More...

Inheritance diagram for Arena:

Public Member Functions

 Arena (ConfigurationParameters &params, QString prefix)
 Constructor.
 
virtual ~Arena ()
 Destructor.
 
void addRobots (QStringList robots)
 Adds robots to the list of 2D objects.
 
Cylinder2DWrappercreateBigCylinder (QColor color, real height=-1.0)
 Creates a big cylinder.
 
Cylinder2DWrappercreateCircularTargetArea (real radius, QColor color)
 Creates a circular target area.
 
Box2DWrappercreateRectangularTargetArea (real width, real depth, QColor color)
 Creates a rectangular target area.
 
Cylinder2DWrappercreateSmallCylinder (QColor color, real height=-1.0)
 Creates a small cylinder.
 
Box2DWrappercreateWall (QColor color, wVector start, wVector end, real thickness, real height=-1.0)
 Creates a wall.
 
bool delete2DObject (PhyObject2DWrapper *obj)
 Deletes an object.
 
real getHeight () const
 Returns the height of the main plane.
 
QVector< PhyObject2DWrapper * > getKinematicRobotCollisions (WheeledRobot2DWrapper *robot) const
 Returns the list of objects that collided with the given kinematic robot at the previous timestep.
 
QVector< PhyObject2DWrapper * > getKinematicRobotCollisions (QString robotResourceName) const
 Returns the list of objects that collided with the given kinematic robot at the previous timestep.
 
const QVector
< PhyObject2DWrapper * > & 
getObjects () const
 Returns the list of 2D objects.
 
Box2DWrappergetPlane ()
 Returns the plane of the arena.
 
const Box2DWrappergetPlane () const
 Returns the plane of the arena (const version)
 
const WheeledRobot2DWrappergetRobotWrapper (QString robotName) const
 Returns a pointer to the wrapper of a robot given the robot resource name.
 
real getWidth () const
 Returns the width of the main plane.
 
real getZ () const
 Returns the z of the plane.
 
void handleKinematicRobotCollisions ()
 Checks collisions of kinematic robots.
 
void prepareToHandleKinematicRobotCollisions ()
 Call this before advancing the world to prepare stuffs needed by a call to handleKinematicRobotCollisions()
 
virtual void save (ConfigurationParameters &params, QString prefix)
 Saves the actual status of parameters into the ConfigurationParameters object passed.
 
- Public Member Functions inherited from ParameterSettableInConstructor
 ParameterSettableInConstructor (ConfigurationParameters &, QString)
 
void addObserver (RuntimeParameterObserver *obs)
 
getRuntimeParameter (QString paramName)
 
virtual ParameterSettableUIgetUIManager ()
 
 ParameterSettable ()
 
virtual void postConfigureInitialization ()
 
void removeObserver (RuntimeParameterObserver *obs)
 
void setRuntimeParameter (QString paramName, T newvalue)
 
QString typeName () const
 
- Public Member Functions inherited from ParameterSettable
void addObserver (RuntimeParameterObserver *obs)
 
getRuntimeParameter (QString paramName)
 
void removeObserver (RuntimeParameterObserver *obs)
 
void setRuntimeParameter (QString paramName, T newvalue)
 
QString typeName () const
 
- 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
 

Static Public Member Functions

static void describe (QString type)
 Adds to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
 
- Static Public Member Functions inherited from ParameterSettableInConstructor
static void describe (QString type)
 
static QString fullParameterDescriptionPath (QString type, QString param)
 
static QString fullSubgroupDescriptionPath (QString type, QString sub)
 
- Static Public Member Functions inherited from ParameterSettable
static void describe (QString type)
 
static QString fullParameterDescriptionPath (QString type, QString param)
 
static QString fullSubgroupDescriptionPath (QString type, QString sub)
 

Additional Inherited Members

- Public Types inherited from ParameterSettableInConstructor
enum  Property
 
- Public Types inherited from ConcurrentResourcesUser
typedef
Resource::ResourceChangeType 
ResourceChangeType
 
- Public Attributes inherited from ParameterSettableInConstructor
 AllowMultiple
 
 Default
 
 IsList
 
 IsMandatory
 
- Static Public Attributes inherited from ParameterSettableInConstructor
static const double Infinity
 
static const int MaxInteger
 
static const int MinInteger
 
- Protected Member Functions inherited from ParameterSettableInConstructor
void notifyChangesToParam (QString paramName)
 
- Protected Member Functions inherited from ConcurrentResourcesUser
T * getResource ()
 
ResourcesUseroperator= (const ResourcesUser &other)
 
 ResourcesUser ()
 
 ResourcesUser (const ResourcesUser &other)
 
- Static Protected Member Functions inherited from ParameterSettableInConstructor
static Descriptor addTypeDescription (QString type, QString shortHelp, QString longHelp=QString(""))
 
static void setGraphicalEditor (QString type)
 
- Protected Attributes inherited from ConcurrentResourcesUser
ResourceCollectionHolder m_resources
 

Detailed Description

The class modelling an arena.

This class contains functions to create and manipulate an arena, which is used mostly in simulations with wheeled robots. The arena always has a plane at the given height, you can add more planes at different heights and you can connected different planes with ramps. Planes are perpendicular to the Z axis. The dimension of the main plane and its Z position can only be set via configuration parameters and are fixed.

Definition at line 47 of file arena.h.

Constructor & Destructor Documentation

Arena ( ConfigurationParameters params,
QString  prefix 
)

Constructor.

Parameters
paramsthe configuration parameters object with parameters to use
prefixthe prefix to use to access the object configuration parameters. This is guaranteed to end with the separator character when called by the factory, so you don't need to add one

Definition at line 77 of file arena.cpp.

References ConcurrentResourcesUser::usableResources().

~Arena ( )
virtual

Destructor.

Definition at line 93 of file arena.cpp.

Member Function Documentation

void addRobots ( QStringList  robots)

Adds robots to the list of 2D objects.

This function adds the given robots to the list of 2D objects so that they can be perceived by the sensors of other robots (like, e.g. the linear camera)

Parameters
robotsthe name of the resources with robots

Definition at line 120 of file arena.cpp.

References ConcurrentResourcesUser::addUsableResources(), RobotOnPlane::robotHeight(), and RobotOnPlane::robotRadius().

Referenced by EvoRobotExperiment::configure(), and EvoRobotExperiment::recreateArena().

Cylinder2DWrapper * createBigCylinder ( QColor  color,
real  height = -1.0 
)

Creates a big cylinder.

The cylinder has a fixed radius. You can specify its color and height

Parameters
colorthe color of the cylinder
heightthe height of the wall. If negative the default height for objects is used
Returns
the new object

Definition at line 207 of file arena.cpp.

Cylinder2DWrapper * createCircularTargetArea ( real  radius,
QColor  color 
)

Creates a circular target area.

The target area is placed on the ground and is detectable by ground sensors

Parameters
radiusthe radius of the area
colorthe color of the area
Returns
the new object

Definition at line 212 of file arena.cpp.

References PhyCylinder::matrix(), Cylinder2DWrapper::phyObject(), PhyCylinder::setMaterial(), PhyCylinder::setMatrix(), and wMatrix::w_pos.

Box2DWrapper * createRectangularTargetArea ( real  width,
real  depth,
QColor  color 
)

Creates a rectangular target area.

The target area is placed on the ground and is detectable by ground sensors

Parameters
widththe width of the area
depththe depth of the area
colorthe color of the area
Returns
the new object

Definition at line 227 of file arena.cpp.

References PhyBox::matrix(), Box2DWrapper::phyObject(), PhyBox::setMaterial(), PhyBox::setMatrix(), and wMatrix::w_pos.

Cylinder2DWrapper * createSmallCylinder ( QColor  color,
real  height = -1.0 
)

Creates a small cylinder.

The cylinder has a fixed radius. You can specify its color and height

Parameters
colorthe color of the cylinder
heightthe height of the wall. If negative the default height for objects is used
Returns
the new object

Definition at line 202 of file arena.cpp.

Box2DWrapper * createWall ( QColor  color,
wVector  start,
wVector  end,
real  thickness,
real  height = -1.0 
)

Creates a wall.

The wall is created using a starting point and an ending point. The z component of the vectors for the starting point and the ending point are discarded. If you imagine the wall as a rectangle, the starting point and the ending point are in the middle of two opposite sides. The wall also have a thickness and an height

Parameters
colorthe color of the wall
startthe starting point of the wall. The Z coordinate of the vector is discarded
endthe ending point of the wall. The Z component is discarded
thicknessthe thickness of the wall
heightthe height of the wall. If negative the default height for objects is used
Returns
the new object

Definition at line 179 of file arena.cpp.

References PhyBox::matrix(), Box2DWrapper::phyObject(), wMatrix::roll(), PhyBox::setMatrix(), PhyObject2DWrapper::setTexture(), wMatrix::w_pos, and wVectorT< Shared >::z.

bool delete2DObject ( PhyObject2DWrapper obj)

Deletes an object.

This deletes the wrapper and the underlying physical object. This also takes care of removing the object from the list of 2D objects of the arena. If the object is not in the arena, this does nothing and returns false

Warning
You should NEVER pass a robot to this function. If you do, the function does nothing and returns false
Parameters
objthe object to delete
Returns
true if the object is deleted, false if the object is not in the arena

Definition at line 242 of file arena.cpp.

References PhyObject2DWrapper::phyObject().

void describe ( QString  type)
static

Adds to Factory::typeDescriptions() the descriptions of all parameters and subgroups.

Parameters
typethe name of the type regarding the description. The type is used when a subclass reuses the description of its parent calling the parent describe method passing the type of the subclass. In this way, the result of the method describe of the parent will be the addition of the description of the parameters of the parent class into the type of the subclass

Definition at line 107 of file arena.cpp.

References ParameterSettableInConstructor::addTypeDescription(), ParameterSettable::RealDescriptor::def(), ParameterSettable::Descriptor::describeReal(), ParameterSettable::RealDescriptor::help(), ParameterSettableInConstructor::Infinity, and ParameterSettable::RealDescriptor::limits().

real getHeight ( ) const
inline

Returns the height of the main plane.

Returns
the height of the main plane

Definition at line 128 of file arena.h.

QVector< PhyObject2DWrapper * > getKinematicRobotCollisions ( WheeledRobot2DWrapper robot) const

Returns the list of objects that collided with the given kinematic robot at the previous timestep.

Parameters
robotthe robot whose collisions are requested
Returns
the list of objects that collided with the given robot at the previous timestep. The list is empty if the robot had no collisions or the robot is not in the list
Note
This only works for robots that are kinematic!!!

Definition at line 323 of file arena.cpp.

Referenced by Arena::getKinematicRobotCollisions().

QVector< PhyObject2DWrapper * > getKinematicRobotCollisions ( QString  robotResourceName) const

Returns the list of objects that collided with the given kinematic robot at the previous timestep.

Parameters
robotResourceNamethe name of the resource of the robot whose collisions are requested
Returns
the list of objects that collided with the given robot at the previous timestep. The list is empty if the robot had no collisions or the robot is not in the list
Note
This only works for robots that are kinematic!!!

Definition at line 328 of file arena.cpp.

References Arena::getKinematicRobotCollisions().

const QVector<PhyObject2DWrapper*>& getObjects ( ) const
inline

Returns the list of 2D objects.

Returns
the list of 2D objects

Definition at line 98 of file arena.h.

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

const Box2DWrapper * getPlane ( ) const

Returns the plane of the arena (const version)

Returns
the plane of the arena

Definition at line 174 of file arena.cpp.

const WheeledRobot2DWrapper * getRobotWrapper ( QString  robotName) const

Returns a pointer to the wrapper of a robot given the robot resource name.

Parameters
robotNamethe name of the resource for the robot
Returns
the wrapper for the robot with the given resource or NULL if no wrapper exists for the given robot

Definition at line 160 of file arena.cpp.

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

real getWidth ( ) const
inline

Returns the width of the main plane.

Returns
the width of the main plane

Definition at line 118 of file arena.h.

real getZ ( ) const
inline

Returns the z of the plane.

Returns
the z of the plane

Definition at line 108 of file arena.h.

void handleKinematicRobotCollisions ( )

Checks collisions of kinematic robots.

This function checks collisions of kinematic robots with walls, other robots and objects. If a robot collides with something else, it is moved back to the position and orientation it had in the previous timestep. This is not very accurate but it is fast.

Definition at line 277 of file arena.cpp.

References PhyObject2DWrapper::computeDistanceAndOrientationFromRobot(), RobotOnPlane::isKinematic(), WheeledRobot2DWrapper::previousMatrix(), WheeledRobot2DWrapper::robotOnPlane(), WObject::setMatrix(), and WheeledRobot2DWrapper::wObject().

void prepareToHandleKinematicRobotCollisions ( )

Call this before advancing the world to prepare stuffs needed by a call to handleKinematicRobotCollisions()

This function has to be called before world advance if you plan to use the handleKinematicRobotCollisions() afterward. What it actually does is storing the previous robot position.

Definition at line 260 of file arena.cpp.

References RobotOnPlane::isKinematic(), WheeledRobot2DWrapper::robotOnPlane(), and WheeledRobot2DWrapper::storePreviousMatrix().

void save ( ConfigurationParameters params,
QString  prefix 
)
virtual

Saves the actual status of parameters into the ConfigurationParameters object passed.

This is not implemented yet

Parameters
paramsthe configuration parameters object on which save actual parameters
prefixthe prefix to use to access the object configuration parameters.

Implements ParameterSettableInConstructor.

Definition at line 101 of file arena.cpp.

References Logger::error().


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