The class modelling an arena. More...
Public Member Functions | |
Arena (ConfigurationParameters ¶ms, QString prefix) | |
Constructor. More... | |
virtual | ~Arena () |
Destructor. More... | |
void | addRobots (QStringList robots) |
Adds robots to the list of 2D objects. More... | |
Cylinder2DWrapper * | createBigCylinder (QColor color, real height=-1.0) |
Creates a big cylinder. More... | |
Cylinder2DWrapper * | createCircularTargetArea (real radius, QColor color) |
Creates a circular target area. More... | |
Cylinder2DWrapper * | createCylinder (real radius, QColor color, real height=-1.0) |
Creates a cylinder. More... | |
Sphere2DWrapper * | createLightBulb (QColor color) |
Creates a LightBulb. More... | |
Box2DWrapper * | createRectangularTargetArea (real width, real depth, QColor color) |
Creates a rectangular target area. More... | |
Cylinder2DWrapper * | createSmallCylinder (QColor color, real height=-1.0) |
Creates a small cylinder. More... | |
Box2DWrapper * | createWall (QColor color, wVector start, wVector end, real thickness, real height=-1.0) |
Creates a wall. More... | |
bool | delete2DObject (PhyObject2DWrapper *obj) |
Deletes an object. More... | |
real | getHeight () const |
Returns the height of the main plane. More... | |
FARSA_DEPRECATED QVector< PhyObject2DWrapper * > | getKinematicRobotCollisions (WheeledRobot2DWrapper *robot) const |
Returns the list of objects that collided with the given kinematic robot at the previous timestep. More... | |
FARSA_DEPRECATED QVector< PhyObject2DWrapper * > | getKinematicRobotCollisions (QString robotResourceName) const |
Returns the list of objects that collided with the given kinematic robot at the previous timestep. More... | |
QSet< PhyObject2DWrapper * > | getKinematicRobotCollisionsSet (WheeledRobot2DWrapper *robot) const |
Returns the set of objects that collided with the given kinematic robot at the previous timestep. More... | |
QSet< PhyObject2DWrapper * > | getKinematicRobotCollisionsSet (QString robotResourceName) const |
Returns the set of objects that collided with the given kinematic robot at the previous timestep. More... | |
const QVector< PhyObject2DWrapper * > & | getObjects () const |
Returns the list of 2D objects. More... | |
Box2DWrapper * | getPlane () |
Returns the plane of the arena. More... | |
const Box2DWrapper * | getPlane () const |
Returns the plane of the arena (const version) More... | |
const WheeledRobot2DWrapper * | getRobotWrapper (QString robotName) const |
Returns a pointer to the wrapper of a robot given the robot resource name. More... | |
real | getWidth () const |
Returns the width of the main plane. More... | |
real | getZ () const |
Returns the z of the plane. More... | |
void | handleKinematicRobotCollisions () |
Checks collisions of kinematic robots. More... | |
void | prepareToHandleKinematicRobotCollisions () |
Call this before advancing the world to prepare stuffs needed by a call to handleKinematicRobotCollisions() More... | |
virtual void | save (ConfigurationParameters ¶ms, QString prefix) |
Saves the actual status of parameters into the ConfigurationParameters object passed. More... | |
Public Member Functions inherited from ParameterSettableInConstructor | |
ParameterSettableInConstructor (ConfigurationParameters &, QString) | |
Public Member Functions inherited from ParameterSettable | |
void | addObserver (RuntimeParameterObserver *obs) |
T | getRuntimeParameter (QString paramName) |
virtual ParameterSettableUI * | getUIManager () |
virtual void | postConfigureInitialization () |
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. More... | |
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 ParameterSettable | |
enum | Property |
Public Types inherited from ResourcesUser | |
typedef Resource::ResourceChangeType | ResourceChangeType |
Public Types inherited from Resource | |
enum | ResourceChangeType |
Public Attributes inherited from ParameterSettable | |
AllowMultiple | |
Default | |
IsList | |
IsMandatory | |
Static Public Attributes inherited from ParameterSettable | |
static const double | Infinity |
static const int | MaxInteger |
static const int | MinInteger |
Protected Member Functions inherited from ParameterSettable | |
void | notifyChangesToParam (QString paramName) |
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) |
Static Protected Member Functions inherited from ParameterSettable | |
static Descriptor | addTypeDescription (QString type, QString shortHelp, QString longHelp=QString("")) |
static void | setGraphicalEditor (QString type) |
Protected Attributes inherited from ResourcesUser | |
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.
Constructor & Destructor Documentation
Arena | ( | ConfigurationParameters & | params, |
QString | prefix | ||
) |
Constructor.
- Parameters
-
params the configuration parameters object with parameters to use prefix the 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 126 of file arena.cpp.
References ConfigurationParameters::getValue(), ConfigurationHelper::throwUserConfigError(), and ConcurrentResourcesUser::usableResources().
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
-
robots the name of the resources with robots
Definition at line 177 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
-
color the color of the cylinder height the height of the wall. If negative the default height for objects is used
- Returns
- the new object
Definition at line 264 of file arena.cpp.
References Arena::createCylinder().
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
-
radius the radius of the area color the color of the area
- Returns
- the new object
Definition at line 274 of file arena.cpp.
References Arena::createCylinder(), WObject::matrix(), Cylinder2DWrapper::phyObject(), and WObject::setMatrix().
Cylinder2DWrapper * createCylinder | ( | real | radius, |
QColor | color, | ||
real | height = -1.0 |
||
) |
Creates a cylinder.
This creates a cylinder with the specified radius
- Parameters
-
radius the radius of the cylinder color the color of the cylinder height the height of the wall. If negative the default height for objects is used
- Returns
- the new object
- Note
- If you plan to use sampled sensors, you should use either createSmallCylinder or createBigCylinder as cylinders created by this function are not taken into account
Definition at line 269 of file arena.cpp.
Referenced by Arena::createBigCylinder(), Arena::createCircularTargetArea(), and Arena::createSmallCylinder().
Sphere2DWrapper * createLightBulb | ( | QColor | color | ) |
Creates a LightBulb.
The light bulb is a spherical object which acts as a source of light and is seen by certain sensors. It is not a physical object, i.e. it doesn't interact with other objects or robots
- Parameters
-
color the color of the light bulb
- Returns
- the new object
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
-
width the width of the area depth the depth of the area color the color of the area
- Returns
- the new object
Definition at line 289 of file arena.cpp.
References WObject::matrix(), Box2DWrapper::phyObject(), and WObject::setMatrix().
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
-
color the color of the cylinder height the height of the wall. If negative the default height for objects is used
- Returns
- the new object
Definition at line 259 of file arena.cpp.
References Arena::createCylinder().
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
-
color the color of the wall start the starting point of the wall. The Z coordinate of the vector is discarded end the ending point of the wall. The Z component is discarded thickness the thickness of the wall height the height of the wall. If negative the default height for objects is used
- Returns
- the new object
Definition at line 236 of file arena.cpp.
References WObject::matrix(), Box2DWrapper::phyObject(), wMatrix::roll(), WObject::setMatrix(), and PhyObject2DWrapper::setTexture().
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
-
obj the object to delete
- Returns
- true if the object is deleted, false if the object is not in the arena
Definition at line 314 of file arena.cpp.
References PhyObject2DWrapper::phyObject().
|
static |
Adds to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
- Parameters
-
type the 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 162 of file arena.cpp.
References ParameterSettable::addTypeDescription(), and ParameterSettable::Infinity.
|
inline |
QVector< PhyObject2DWrapper * > getKinematicRobotCollisions | ( | WheeledRobot2DWrapper * | robot | ) | const |
Returns the list of objects that collided with the given kinematic robot at the previous timestep.
- Parameters
-
robot 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!!!
- Warning
- This function is deprecated, use getKinematicRobotCollisionsSet(), instead
Definition at line 364 of file arena.cpp.
References Arena::getKinematicRobotCollisionsSet().
QVector< PhyObject2DWrapper * > getKinematicRobotCollisions | ( | QString | robotResourceName | ) | const |
Returns the list of objects that collided with the given kinematic robot at the previous timestep.
- Parameters
-
robotResourceName the 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!!!
- Warning
- This function is deprecated, use getKinematicRobotCollisionsSet(), instead
Definition at line 369 of file arena.cpp.
References Arena::getKinematicRobotCollisionsSet().
QSet< PhyObject2DWrapper * > getKinematicRobotCollisionsSet | ( | WheeledRobot2DWrapper * | robot | ) | const |
Returns the set of objects that collided with the given kinematic robot at the previous timestep.
- Parameters
-
robot the robot whose collisions are requested
- Returns
- the set of objects that collided with the given robot at the previous timestep. The set 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 374 of file arena.cpp.
Referenced by Arena::getKinematicRobotCollisions(), and Arena::getKinematicRobotCollisionsSet().
QSet< PhyObject2DWrapper * > getKinematicRobotCollisionsSet | ( | QString | robotResourceName | ) | const |
Returns the set of objects that collided with the given kinematic robot at the previous timestep.
- Parameters
-
robotResourceName the name of the resource of the robot whose collisions are requested
- Returns
- the set of objects that collided with the given robot at the previous timestep. The set 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 379 of file arena.cpp.
References Arena::getKinematicRobotCollisionsSet().
|
inline |
Returns the list of 2D objects.
- Returns
- the list of 2D objects
Definition at line 136 of file arena.h.
Referenced by LinearCamera::update(), KheperaSampledProximityIRSensor::update(), KheperaSampledLightSensor::update(), EpuckSampledProximityIRSensor::update(), and MarXbotSampledProximityIRSensor::update().
Box2DWrapper * getPlane | ( | ) |
Returns the plane of the arena.
- Returns
- the plane of the arena
Definition at line 226 of file arena.cpp.
Referenced by Box2DWrapper::computeDistanceAndOrientationFromRobot(), Cylinder2DWrapper::computeDistanceAndOrientationFromRobot(), Sphere2DWrapper::computeDistanceAndOrientationFromRobot(), and WheeledRobot2DWrapper::computeDistanceAndOrientationFromRobot().
const Box2DWrapper * getPlane | ( | ) | const |
const WheeledRobot2DWrapper * getRobotWrapper | ( | QString | robotName | ) | const |
Returns a pointer to the wrapper of a robot given the robot resource name.
- Parameters
-
robotName the 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 217 of file arena.cpp.
Referenced by KheperaSampledProximityIRSensor::update(), KheperaSampledLightSensor::update(), EpuckSampledProximityIRSensor::update(), and MarXbotSampledProximityIRSensor::update().
|
inline |
|
inline |
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 348 of file arena.cpp.
References farsa::throwUserRuntimeError().
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 332 of file arena.cpp.
References farsa::throwUserRuntimeError().
|
virtual |
Saves the actual status of parameters into the ConfigurationParameters object passed.
This is not implemented yet
- Parameters
-
params the configuration parameters object on which save actual parameters prefix the prefix to use to access the object configuration parameters.
Implements ParameterSettable.
Definition at line 156 of file arena.cpp.
References Logger::error().
The documentation for this class was generated from the following files: