robots.cpp
39 ConfigurationHelper::throwUserMissingResourceError("world", "We need a world to create the iCub robot!");
61 ConfigurationHelper::throwUserConfigError(prefix + "transformation", value, "The transformation matrix must have 4 rows. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
68 ConfigurationHelper::throwUserConfigError(prefix + "transformation", value, "The transformation matrix must have 4 columns. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
74 ConfigurationHelper::throwUserConfigError(prefix + "transformation", value, "The transformation matrix elements must be numbers");
87 m_color(ConfigurationHelper::getString(params, prefix + "color", "+FFFFFF").replace("+", "#")) // We have to do this because # is for comments in .ini files
90 ConfigurationHelper::throwUserConfigError(prefix + "color", params.getValue(prefix + "color"), "The value of the \"color\" parameter is not a valid color");
104 Descriptor d = addTypeDescription(type, "The base class for robots that lie on a plane", "The base class for robots that lie on a plane");
105 d.describeString("color").def("+FFFFFF").help("The color of the robot.", "This is a string. Its format can be: +RGB, +RRGGBB, +RRRGGGBBB, +RRRRGGGGBBBB (each of R, G, and B is a single hex digit) or a name from the list of colors defined in the list of SVG color keyword names provided by the World Wide Web Consortium (see http://www.w3.org/TR/SVG/types.html#ColorKeywords). The default value is \"+FFFFFF\"");
120 PhyMarXbot(extractWorld(params), extractRobotName(params, prefix, "marXbot"), extractRobotTranformation(params, prefix))
125 const bool enableProximityIR = ConfigurationHelper::getBool(params, prefix + "enableProximityIR", false);
126 const bool enableGroundBottomIR = ConfigurationHelper::getBool(params, prefix + "enableGroundBottomIR", false);
127 const bool enableGroundAroundIR = ConfigurationHelper::getBool(params, prefix + "enableGroundAroundIR", false);
128 const bool enableAttachDev = ConfigurationHelper::getBool(params, prefix + "enableAttachmentDevice", false);
129 const bool drawProximityIR = ConfigurationHelper::getBool(params, prefix + "drawProximityIR", false);
130 const bool drawGroundBottomIR = ConfigurationHelper::getBool(params, prefix + "drawGroundBottomIR", false);
131 const bool drawGroundAroundIR = ConfigurationHelper::getBool(params, prefix + "drawGroundAroundIR", false);
133 const bool drawIRRaysRange = ConfigurationHelper::getBool(params, prefix + "drawIRRaysRange", false);
144 QString ledColorsString = ConfigurationHelper::getString(params, prefix + "ledColors", "").replace("+", "#");
150 ConfigurationHelper::throwUserConfigError(prefix + "ledColors", params.getValue(prefix + "ledColors"), "The ledColors parameter must be a list of exactly 12 elements");
155 ConfigurationHelper::throwUserConfigError(prefix + "ledColors", params.getValue(prefix + "ledColors"), QString("The value of the %1th color is not a valid color").arg(i));
175 Descriptor d = addTypeDescription(type, "The simulated wheeled MarXBot robot in a physical world", "This type models the wheeled MarXBot robot in a physical world. Note that to create a robot we need a resource named \"world\" with a valid World instance");
177 d.describeBool("kinematicRobot").def(false).help("Whether only the kinematic behaviour of the robot has to be simulated or not", "If true only the kinematic properties of the robot are simulated (i.e. velocity); is false (the default) the whole dynamic of the robot is simulated");
179 d.describeString("name").def("marXbot").help("The name of the MarXBot robot", "The name of the MarXBot robot");
181 d.describeString("transformation").def("").help("The initial transformation matrix for the robot", "The transformation matrix must be a 4x4 matrix. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
183 d.describeBool("enableWheels").def(true).help("If true enables the wheel motors", "When set to false the wheel motors are not enabled, so the robot cannot move by itself");
185 d.describeBool("enableProximityIR").def(false).help("If true enables the proximity IR sensors", "When set to false the proximity infrared sensors are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
187 d.describeBool("enableGroundBottomIR").def(false).help("If true enables the bottom ground IR sensors", "When set to false the ground infrared sensors below the battery pack are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
189 d.describeBool("enableGroundAroundIR").def(false).help("If true enables the around ground IR sensors", "When set to false the ground infrared sensors on the bottom part of the base (just above the wheels) are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
191 d.describeBool("enableAttachmentDevice").def(false).help("If true enables the attachement device of the MarXbot", "When set to true the attachement device is enabled. This device can be used by the robot to attach to another robot. The default is false");
193 d.describeBool("drawProximityIR").def(false).help("If true draws the proximity IR sensors", "When set to true draws the proximity infrared sensors");
195 d.describeBool("drawGroundBottomIR").def(false).help("If true draws the bottom ground IR sensors", "When set to true draws the ground infrared sensors below the battery pack");
197 d.describeBool("drawGroundAroundIR").def(false).help("If true draws the around ground IR sensors", "When set to true draws the ground infrared sensors on the bottom part of the base (just above the wheels)");
199 d.describeBool("drawIRRays").def(false).help("If true draws rays of enabled IR sensors", "When set to true rays of the enabled IR sensors (i.e. proximity, ground bottom and ground around infrared sensors) are drawn");
201 d.describeBool("drawIRRaysRange").def(false).help("If true rays of enabled IR sensors are shown in their real range", "When drawIRRays is true, this parameter sets whether rays are drawn in their real range (the parameter is true) or instead only their direction is shown (the parameter is false)");
203 d.describeString("ledColors").def("+FFFFFF +FFFFFF +FFFFFF +FFFFFF +FFFFFF +FFFFFF +FFFFFF +FFFFFF +FFFFFF +FFFFFF +FFFFFF +FFFFFF").help("The color of the leds of the robot.", "This is a list of colors separated by white spaces. Each color can be in one of the following formats: +RGB, +RRGGBB, +RRRGGGBBB, +RRRRGGGGBBBB (each of R, G, and B is a single hex digit) or a name from the list of colors defined in the list of SVG color keyword names provided by the World Wide Web Consortium (see http://www.w3.org/TR/SVG/types.html#ColorKeywords). The list must have exactly 12 elements. The default value is white for all leds");
232 #warning LE FUNZIONI orientation() E setOrientation() DEI ROBOT NON USANO LO STESSO RIFERIMENTO, OSSIA setOrientation(orientation()) RUOTA IL ROBOT ANCHE SE NON DOVREBBE! CORREGGERE IN FARSA2
263 PhyEpuck(extractWorld(params), extractRobotName(params, prefix, "epuck"), extractRobotTranformation(params, prefix))
268 const bool enableProximityIR = ConfigurationHelper::getBool(params, prefix + "enableProximityIR", false);
269 const bool enableGroundIR = ConfigurationHelper::getBool(params, prefix + "enableGroundIR", false);
270 const bool drawProximityIR = ConfigurationHelper::getBool(params, prefix + "drawProximityIR", false);
273 const bool drawIRRaysRange = ConfigurationHelper::getBool(params, prefix + "drawIRRaysRange", false);
293 Descriptor d = addTypeDescription(type, "The simulated wheeled Epuck robot in a physical world", "This type models the wheeled Epuck robot in a physical world. Note that to create a robot we need a resource named \"world\" with a valid World instance");
295 d.describeBool("kinematicRobot").def(false).help("Whether only the kinematic behaviour of the robot has to be simulated or not", "If true only the kinematic properties of the robot are simulated (i.e. velocity); is false (the default) the whole dynamic of the robot is simulated");
297 d.describeString("name").def("epuck").help("The name of the Epuck robot", "The name of the Epuck robot");
299 d.describeString("transformation").def("").help("The initial transformation matrix for the robot", "The transformation matrix must be a 4x4 matrix. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
301 d.describeBool("enableWheels").def(true).help("If true enables the wheel motors", "When set to false the wheel motors are not enabled, so the robot cannot move by itself");
303 d.describeBool("enableProximityIR").def(false).help("If true enables the proximity IR sensors", "When set to false the proximity infrared sensors are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
305 d.describeBool("enableGroundIR").def(false).help("If true enables the ground IR sensors", "When set to false the ground infrared sensors are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
307 d.describeBool("drawProximityIR").def(false).help("If true draws the proximity IR sensors", "When set to true draws the proximity IR sensors");
309 d.describeBool("drawGroundIR").def(false).help("If true draws the ground IR sensors", "When set to true draws the ground IR sensors");
311 d.describeBool("drawIRRays").def(false).help("If true draws rays of enabled IR sensors", "When set to true rays of the enabled IR sensors (i.e. proximity and ground infrared sensors) are drawn");
313 d.describeBool("drawIRRaysRange").def(false).help("If true rays of enabled IR sensors are shown in their real range", "When drawIRRays is true, this parameter sets whether rays are drawn in their real range (the parameter is true) or instead only their direction is shown (the parameter is false)");
370 PhyKhepera(extractWorld(params), extractRobotName(params, prefix, "khepera"), extractRobotTranformation(params, prefix))
375 const bool enableProximityIR = ConfigurationHelper::getBool(params, prefix + "enableProximityIR", false);
376 const bool drawProximityIR = ConfigurationHelper::getBool(params, prefix + "drawProximityIR", false);
378 const bool drawIRRaysRange = ConfigurationHelper::getBool(params, prefix + "drawIRRaysRange", false);
398 Descriptor d = addTypeDescription(type, "The simulated wheeled Khepera II robot in a physical world", "This type models the wheeled Khepera II robot in a physical world. Note that to create a robot we need a resource named \"world\" with a valid World instance");
400 d.describeBool("kinematicRobot").def(false).help("Whether only the kinematic behaviour of the robot has to be simulated or not", "If true only the kinematic properties of the robot are simulated (i.e. velocity); is false (the default) the whole dynamic of the robot is simulated");
402 d.describeString("name").def("khepera").help("The name of the Khepera robot", "The name of the Khepera robot");
404 d.describeString("transformation").def("").help("The initial transformation matrix for the robot", "The transformation matrix must be a 4x4 matrix. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
406 d.describeBool("enableWheels").def(true).help("If true enables the wheel motors", "When set to false the wheel motors are not enabled, so the robot cannot move by itself");
408 d.describeBool("enableProximityIR").def(false).help("If true enables the proximity IR sensors", "When set to false the proximity infrared sensors are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
410 d.describeBool("drawProximityIR").def(false).help("If true draws the proximity IR sensors", "When set to true draws the proximity IR sensors");
412 d.describeBool("drawIRRays").def(false).help("If true draws rays of enabled IR sensors", "When set to true rays of the enabled IR sensors (i.e. proximity and ground infrared sensors) are drawn");
414 d.describeBool("drawIRRaysRange").def(false).help("If true rays of enabled IR sensors are shown in their real range", "When drawIRRays is true, this parameter sets whether rays are drawn in their real range (the parameter is true) or instead only their direction is shown (the parameter is false)");
void doKinematicSimulation(bool k)
virtual bool isKinematic() const
Returns true if the robot is in kinematic mode.
Definition: robots.cpp:459
wMatrix extractRobotTranformation(ConfigurationParameters ¶ms, QString prefix)
Gets the transformation matrix of the robot.
Definition: robots.cpp:50
static void describe(QString type)
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition: robots.cpp:100
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves the actual status of parameters into the ConfigurationParameters object passed.
Definition: robots.cpp:390
static wMatrix identity()
static void throwUserMissingResourceError(QString resourceName, QString description)
void setGroundIRSensorsGraphicalProperties(bool drawSensor, bool drawRay=false, bool drawRealRay=false)
virtual void setOrientation(const Box2DWrapper *plane, real angle)
Sets the orientation of the robot.
Definition: robots.cpp:332
static QString getString(ConfigurationParameters ¶ms, QString paramPath, QString def=QString())
virtual void setOrientation(const Box2DWrapper *plane, real angle)
Sets the orientation of the robot.
Definition: robots.cpp:433
The subclass of PhyObject2DWrapper wrapping a box.
Definition: wheeledexperimenthelper.h:390
bool isKinematic() const
virtual void setPosition(const Box2DWrapper *plane, real x, real y)
Sets the position of the robot in the plane.
Definition: robots.cpp:210
QColor color() const
const QColor & configuredRobotColor() const
Returns the robot color specified by the configuration parameter.
Definition: robots.h:250
void setPosition(const Box2DWrapper *plane, const wVector &pos)
Sets the position of the robot in the plane.
Definition: robots.cpp:113
static const real bodyh
WheelMotorController * wheelsController()
SimulatedIRProximitySensorController * proximityIRSensorController()
void setDrawFrontMarker(bool drawMarker)
void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay=false, bool drawRealRay=false)
bool isKinematic() const
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves the actual status of parameters into the ConfigurationParameters object passed.
Definition: robots.cpp:167
SimulatedIRGroundSensorController * groundBottomIRSensorController()
static void describe(QString type)
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition: robots.cpp:395
virtual void setPosition(const Box2DWrapper *plane, real x, real y)
Sets the position of the robot in the plane.
Definition: robots.cpp:422
void setGroundAroundIRSensorsGraphicalProperties(bool drawSensor, bool drawRay=false, bool drawRealRay=false)
void setColor(QColor c)
WheelMotorController * wheelsController()
static const real batteryplacez
static void throwUserConfigError(QString paramName, QString paramValue, QString description)
static const real bodydistancefromground
void setLedColors(QList< QColor > c)
const wMatrix & matrix() const
void setEnabled(bool b)
static void describe(QString type)
static void describe(QString type)
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition: robots.cpp:172
void setEnabled(bool b)
SimpleResourcesUser * getResourcesUserForResource(QString resourceName)
static bool getBool(ConfigurationParameters ¶ms, QString paramPath, bool def=false)
static void error(QString msg)
World * extractWorld(ConfigurationParameters ¶ms)
Gets the resource for world.
Definition: robots.cpp:34
void doKinematicSimulation(bool k)
QString extractRobotName(ConfigurationParameters ¶ms, QString prefix, QString defaultName)
Gets the name of the robot.
Definition: robots.cpp:45
void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay=false, bool drawRealRay=false)
SimulatedIRGroundSensorController * groundIRSensorController()
void doKinematicSimulation(bool k)
void setPosition(const wVector &newpos)
virtual real orientation(const Box2DWrapper *plane) const
Returns the orientation of the robot.
Definition: robots.cpp:342
virtual bool isKinematic() const
Returns true if the robot is in kinematic mode.
Definition: robots.cpp:358
virtual bool isKinematic() const
Returns true if the robot is in kinematic mode.
Definition: robots.cpp:251
virtual void setOrientation(const Box2DWrapper *plane, real angle)
Sets the orientation of the robot.
Definition: robots.cpp:221
static Descriptor addTypeDescription(QString type, QString shortHelp, QString longHelp=QString(""))
QString getValue(QString path, bool alsoMatchParents=false) const
static const real batteryplacedistancefromground
float real
static const real bodyr
SimulatedIRProximitySensorController * proximityIRSensorController()
void setGroundBottomIRSensorsGraphicalProperties(bool drawSensor, bool drawRay=false, bool drawRealRay=false)
void enableAttachmentDevice(bool enable)
void setMatrix(const wMatrix &newm)
virtual real orientation(const Box2DWrapper *plane) const
Returns the orientation of the robot.
Definition: robots.cpp:443
QList< QColor > ledColors() const
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves the actual status of parameters into the ConfigurationParameters object passed.
Definition: robots.cpp:285
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves the actual status of parameters into the ConfigurationParameters object passed.
Definition: robots.cpp:94
virtual void setPosition(const Box2DWrapper *plane, real x, real y)
Sets the position of the robot in the plane.
Definition: robots.cpp:321
virtual PhyBox * phyObject()
Returns a pointer to the wrapped PhyObject.
Definition: wheeledexperimenthelper.cpp:505
T * getResource(QString name)
static const real bodyh
virtual real orientation(const Box2DWrapper *plane) const
Returns the orientation of the robot.
Definition: robots.cpp:235
SimulatedIRGroundSensorController * groundAroundIRSensorController()
SimulatedIRProximitySensorController * proximityIRSensorController()
static void describe(QString type)
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition: robots.cpp:290
void setProximityIRSensorsGraphicalProperties(bool drawSensor, bool drawRay=false, bool drawRealRay=false)
bool isKinematic() const
WheelMotorController * wheelsController()
static const real bodyr