arena.cpp
81 m_smallCylinderRadius(ConfigurationHelper::getDouble(params, prefix + "smallCylinderRadius", defaultSmallCylinderRadius)),
82 m_bigCylinderRadius(ConfigurationHelper::getDouble(params, prefix + "bigCylinderRadius", defaultBigCylinderRadius)),
112 Descriptor d = addTypeDescription(type, "The class modelling an arena in which robots can live");
113 d.describeReal("z").def(0.0).help("The z coordinate of the plane in the world frame of reference", "This is the z coordinate of the upper part of the plane in the world frame of reference");
114 d.describeReal("smallCylinderRadius").def(defaultSmallCylinderRadius).help("The radius of small cylinders", "This is the value to use for the radius of small cylinders. The default value is the one used in evorobot. If you change this, be careful which sample files you use.");
115 d.describeReal("bigCylinderRadius").def(defaultBigCylinderRadius).help("The radius of big cylinders", "This is the value to use for the radius of big cylinders. The default value is the one used in evorobot. If you change this, be careful which sample files you use.");
122 // First of all adding robots to the list of usable resources. This will call the resourceChanged callback
123 // because robots already exist, however they are not in the m_robotResourceWrappers map so the callback will
144 // If the robot actually exists, adding a wrapper, otherwise we simply add the robot to the map to
148 WheeledRobot2DWrapper* wrapper = new WheeledRobot2DWrapper(this, r, r->robotHeight(), r->robotRadius());
179 Box2DWrapper* Arena::createWall(QColor color, wVector start, wVector end, real thickness, real height)
188 Box2DWrapper* b = createBox(color, (end - start).norm(), thickness, height, Box2DWrapper::Wall);
190 // Moving the wall and setting the texture. We have to compute the rotation around the Z axis of the
216 // Creating the cylinder, then we only have to change its z position and set the material to nonCollidable
217 Cylinder2DWrapper* c = createCylinder(color, radius, targetAreasHeight, Cylinder2DWrapper::CircularTargetArea);
231 // Creating the box, then we only have to change its z position and set the material to nonCollidable
232 Box2DWrapper* b = createBox(color, width, depth, targetAreasHeight, Box2DWrapper::RectangularTargetArea);
281 // Here we use a naive approach: we check collision of every object with every robot. This is not
282 // the best possible algorithm (complexity is O(n^2)...), but it's the way things are done in evorobot
302 // Getting the distance between the robot and the object. If computeDistanceAndOrientationFromRobot
323 QVector<PhyObject2DWrapper*> Arena::getKinematicRobotCollisions(WheeledRobot2DWrapper* robot) const
328 QVector<PhyObject2DWrapper*> Arena::getKinematicRobotCollisions(QString robotResourceName) const
333 throw ArenaException(QString("The arena doesn't contain the robot named %1 (perhaps you used \"robot\"? You must use the complete name, e.g. agent[0]:robot)").arg(robotResourceName).toAscii().data());
337 Cylinder2DWrapper* Arena::createCylinder(QColor color, real radius, real height, Cylinder2DWrapper::Type type)
363 Box2DWrapper* Arena::createBox(QColor color, real width, real depth, real height, Box2DWrapper::Type type)
420 WheeledRobot2DWrapper* wrapper = new WheeledRobot2DWrapper(this, r, r->robotHeight(), r->robotRadius());
441 Box2DWrapper* Arena::createPlane(ConfigurationParameters& params, QString prefix, real z, Arena* arena)
450 ConfigurationHelper::throwUserMissingResourceError("world", "We need a world to create the arena!");
478 Box2DWrapper* Arena::createPlane2(ConfigurationParameters& params, QString prefix, real z, Arena* arena)
492 ConfigurationHelper::throwUserMissingResourceError("world", "We need a world to create the arena!");
500 plane->setPosition(wVector( w*cellSize-planeWidth/2.0, h*cellSize-planeHeight/2.0, z - (planeThickness / 2.0)));