Public Types | |
enum | { E_Advance = 1200, E_Play = 1201, E_Stop = 1202, E_Pause = 1203 } |
Custom Event Types. More... | |
enum | w_state { playingS, pausedS, stoppedS } |
define the state of the World More... | |
Public Slots | |
void | advance () |
Do a step of the World. | |
void | finalize () |
Operation performed at the end of the simulation. | |
void | initialize () |
Initialize the World, it doesn't do anything if it's already initialized. | |
void | pause () |
Pause the World. | |
int | play () |
run the World calling advance as fast as possibile (return the timerId) | |
void | stop () |
Stop the World. | |
Signals | |
void | addedJoint (PhyJoint *) |
emitted when an PhyJoint has been added | |
void | addedObject (WObject *) |
emitted when an WObject has been added | |
void | advanced () |
When exit from advance method. | |
void | finished () |
When exit from finalize method. | |
void | initialized () |
When exit from initialize method. | |
void | paused () |
When the stop method is called. | |
void | removedJoint (PhyJoint *) |
emitted when an PhyJoint has been removed | |
void | removedObject (WObject *) |
emitted when an WObject has been removed | |
void | resized () |
emitted when the World change its size | |
void | stopped () |
When the stopped method is called. | |
Public Member Functions | |
World (QString worldname, bool LocalYarpPorts=false) | |
Constructor. | |
virtual | ~World () |
Destructor. | |
void | advanceUntil (real time) |
Advance the World until the time passed is reached (approx. | |
bool | checkContacts (PhyObject *obj1, PhyObject *obj2, int maxContacts=4, QVector< wVector > *contacts=NULL, QVector< wVector > *normals=NULL, QVector< real > *penetra=NULL) |
Checks whether two objects collide or not. | |
void | cleanUpMemory () |
Clean up memory. | |
bool | closestPoints (PhyObject *objA, PhyObject *objB, wVector &pointA, wVector &pointB) |
calculate the two closest points between the two objects; | |
real | collisionRayCast (PhyObject *obj, wVector start, wVector end, wVector *normal=NULL) |
Checks whether the ray from start to end intersects obj. | |
const contactMap & | contacts () |
return the contact map | |
void | disableCollision (PhyObject *obj1, PhyObject *obj2) |
Disable collision between bodies. | |
real | elapsedTime () const |
Get the elapsed time. | |
void | enableCollision (PhyObject *obj1, PhyObject *obj2) |
Enable collision. | |
WObject * | getObject (QString name) |
Return the WObject with name specified, otherwise return NULL. | |
real | gravityForce () const |
Return the gravity force. | |
bool | isRealTime () const |
return true is real-time is enabled ; false otherwise | |
const QLinkedList< PhyJoint * > | joints () |
Return the vector of joints present in this world. | |
const QHash< WObject *, QList < PhyJoint * > > | mapObjectsToJoints () |
Map object -> joints. | |
MaterialDB & | materials () |
return the MaterialDB object for managing World's materials | |
QString | name () const |
Return the name. | |
const QLinkedList< WObject * > | objects () |
Return the vector of objects present in this world. | |
void | popJoint (PhyJoint *) |
void | popObject (WObject *) |
void | pushJoint (PhyJoint *) |
void | pushObject (WObject *) |
void | resetElapsedTime () |
Reset the time counter and restart from zero seconds. | |
void | setFrictionModel (QString model) |
See Physic Engine Documentation. | |
void | setGravityForce (real g) |
Set the gravity force. | |
void | setIsRealTime (bool b) |
Enable/Disable Real-time advance. | |
void | setMinimumFrameRate (unsigned int frames) |
Set the minimum frame rate; in other word the number of integration steps per seconds regardless the time step setted. | |
void | setMultiThread (int numThreads) |
Set the multi-thread functionality. | |
void | setSize (const wVector &minPoint, const wVector &maxPoint) |
See Physic Engine Documentation. | |
void | setSolverModel (QString model) |
See Physic Engine Documentation. | |
void | setTimeStep (real) |
Set the time step. | |
void | size (wVector &minPoint, wVector &maxPoint) |
Get the bounding box of the world. | |
bool | smartCheckContacts (PhyObject *obj1, PhyObject *obj2, int maxContacts=4, QVector< wVector > *contacts=NULL) |
Checks whether two objects collide or not. | |
w_state | status () |
return the actual state | |
real | timeStep () const |
get the time step setted | |
rayCastHitVector | worldRayCast (wVector start, wVector end, bool onlyClosest, const QSet< PhyObject * > &ignoredObjs=QSet< PhyObject * >()) |
Returns the bodyes which intersect the ray from start to end. | |
Protected Member Functions | |
void | customEvent (QEvent *e) |
Custom Events. | |
void | timerEvent (QTimerEvent *e) |
Event for handling play/stop in order to stay syncronized with QT main thread. | |
Protected Attributes | |
real | gforce |
Gravity Force. | |
QLinkedList< PhyJoint * > | jointsv |
Vector of Joints inside the World. | |
QHash< WObject *, QList < PhyJoint * > > | mapObjJoints |
Map object -> joints. | |
wVector | maxP |
wVector | minP |
Size of the Newton world. | |
QLinkedList< WObject * > | objs |
Vector of WObject inside the World. | |
real | time |
The elapsed simulation-time from last calls of initialize() | |
real | timestepv |
The time step. | |
Friends | |
class | MaterialDB |
class | PhyJoint |
class | PhyObject |
class | WorldPrivate |
Detailed Description
World class.
- Motivation
- The World represent the environment in which robots are inserted and interacts with.
The World contains all objects: actives and passives.
The World has a continuous temporal dimension. It's possibile set the time step of integration.
- Description
- Description coming soon
- Warnings
- Warnings
Member Enumeration Documentation
Constructor & Destructor Documentation
World | ( | QString | worldname, |
bool | LocalYarpPorts = false |
||
) |
Constructor.
- Parameters
-
worldname is the reference name for the World, in particular it will be the root yarp port for all YarpObject (Devices) contained into this world LocalYarpPorts set a boolean variable that setup YARP network in local mode if true
Definition at line 156 of file world.cpp.
References World::gforce, World::minP, World::name(), World::time, and World::timestepv.
|
virtual |
Destructor.
Definition at line 203 of file world.cpp.
References World::jointsv, World::objs, and Ownable::owner().
Member Function Documentation
|
slot |
Do a step of the World.
- Note
- The sequence of actions here is: update motor controllers; call preUpdate on all objects; call preUpdate on all joints; perform the actual physical simulation step; call postUpdate on all objects; call postUpdate on all joints
Definition at line 242 of file world.cpp.
References World::advanced(), World::initialize(), World::jointsv, World::objs, SimpleTimer::tac(), SimpleTimer::tic(), World::time, and World::timestepv.
Referenced by World::advanceUntil(), World::customEvent(), and World::timerEvent().
|
signal |
When exit from advance method.
Referenced by World::advance().
void advanceUntil | ( | real | time | ) |
Advance the World until the time passed is reached (approx.
per difetto)
- Warning
- This method block the signals, so no signals will be emitted
- this method ignore real-time settings, it always go as fast as possible
Definition at line 377 of file world.cpp.
References World::advance(), and World::time.
bool checkContacts | ( | PhyObject * | obj1, |
PhyObject * | obj2, | ||
int | maxContacts = 4 , |
||
QVector< wVector > * | contacts = NULL , |
||
QVector< wVector > * | normals = NULL , |
||
QVector< real > * | penetra = NULL |
||
) |
Checks whether two objects collide or not.
- Parameters
-
obj1 first object obj2 second object maxContacts the maxium number of contacts to report contacts if not null, the vector is filled with collision contact points in the world frame of reference normals if not null, the vector is filled with collision contact normals in the world frame of reference penetra if not null, the vector is filled with collision penetration at each point
- Returns
- true if the two object are in contacts
Definition at line 549 of file world.cpp.
References WObject::matrix(), and PhyObject::priv.
Referenced by World::smartCheckContacts().
calculate the two closest points between the two objects;
- Parameters
-
objA first object objB second object pointA the point on objA's shape closest to objB pointB the point on objB's shape closest to objA
- Returns
- true is the calculation has been done, false if the object are colliding In the case of colliding objects the points will be setted to zero
Definition at line 673 of file world.cpp.
References WObject::matrix(), and PhyObject::priv.
Checks whether the ray from start to end intersects obj.
- Parameters
-
obj the object whose collision with the ray we have to check start the starting point of the ray (in the global frame of reference) end the ending point of the ray (in the global frame of reference) normal if not null the pointed wVector will store the normal to the contact point
- Returns
- a value between 0.0 and 1.0 indicating the point along the ray which intersects the object (with 0.0 being the starting point and 1.0 the ending point). If the ray misses the objects, the returned value is greater than 1.0
Definition at line 622 of file world.cpp.
References wMatrix::inverse(), WObject::matrix(), PhyObject::priv, and wMatrix::transformVector().
|
protected |
Custom Events.
Definition at line 314 of file world.cpp.
References World::advance(), World::pause(), World::play(), and World::stop().
real elapsedTime | ( | ) | const |
|
slot |
Operation performed at the end of the simulation.
Definition at line 276 of file world.cpp.
References World::finished().
Referenced by World::initialize(), and World::stop().
|
signal |
When exit from finalize method.
Referenced by World::finalize().
WObject * getObject | ( | QString | name | ) |
Return the WObject with name specified, otherwise return NULL.
Definition at line 392 of file world.cpp.
References WObject::name(), World::name(), and World::objs.
real gravityForce | ( | ) | const |
Return the gravity force.
Definition at line 373 of file world.cpp.
References World::gforce.
Referenced by MaterialDB::gravityForce().
|
slot |
Initialize the World, it doesn't do anything if it's already initialized.
Definition at line 229 of file world.cpp.
References World::finalize(), World::initialized(), SimpleTimer::tic(), and World::time.
Referenced by World::advance().
|
signal |
When exit from initialize method.
Referenced by World::initialize().
bool isRealTime | ( | ) | const |
const QLinkedList< PhyJoint * > joints | ( | ) |
Return the vector of joints present in this world.
Definition at line 400 of file world.cpp.
References World::jointsv.
|
inline |
return the MaterialDB object for managing World's materials
Definition at line 335 of file world.h.
Referenced by PhyEpuck::PhyEpuck(), PhyiCub::PhyiCub(), PhyKhepera::PhyKhepera(), and PhyMarXbot::PhyMarXbot().
QString name | ( | ) | const |
Return the name.
Definition at line 225 of file world.cpp.
Referenced by World::getObject(), and World::World().
const QLinkedList< WObject * > objects | ( | ) |
Return the vector of objects present in this world.
Definition at line 388 of file world.cpp.
References World::objs.
Referenced by RenderWObjectContainer::resourceChanged().
|
slot |
Pause the World.
Definition at line 292 of file world.cpp.
References World::paused().
Referenced by World::customEvent().
|
signal |
When the stop method is called.
Referenced by World::pause().
|
slot |
run the World calling advance as fast as possibile (return the timerId)
Definition at line 284 of file world.cpp.
Referenced by World::customEvent().
void resetElapsedTime | ( | ) |
Reset the time counter and restart from zero seconds.
Definition at line 343 of file world.cpp.
References World::time.
|
signal |
emitted when the World change its size
Referenced by World::setSize().
void setFrictionModel | ( | QString | model | ) |
void setGravityForce | ( | real | g | ) |
void setIsRealTime | ( | bool | b | ) |
void setMinimumFrameRate | ( | unsigned int | frames | ) |
void setMultiThread | ( | int | numThreads | ) |
Set the multi-thread functionality.
Definition at line 438 of file world.cpp.
References farsa::max().
See Physic Engine Documentation.
Definition at line 445 of file world.cpp.
References World::minP, and World::resized().
void setSolverModel | ( | QString | model | ) |
void setTimeStep | ( | real | ts | ) |
Get the bounding box of the world.
Definition at line 454 of file world.cpp.
References World::minP.
Referenced by RenderWObjectContainer::drawSkyGroundBox(), RenderWorld::init(), and RenderWorld::resourceChanged().
bool smartCheckContacts | ( | PhyObject * | obj1, |
PhyObject * | obj2, | ||
int | maxContacts = 4 , |
||
QVector< wVector > * | contacts = NULL |
||
) |
Checks whether two objects collide or not.
This function uses checkContacts if at least one object is kinematic or if both objects are static, otherwise collision information are taken from contactMap
- Parameters
-
obj1 first object obj2 second object maxContacts the maxium number of contacts to report contacts if not null, the vector is filled with collision contact points in the world frame of reference
- Returns
- true if the two object are in contacts
Definition at line 591 of file world.cpp.
References World::checkContacts(), PhyObject::getKinematic(), and PhyObject::getStatic().
|
slot |
Stop the World.
Definition at line 300 of file world.cpp.
References World::finalize(), and World::stopped().
Referenced by World::customEvent().
|
signal |
When the stopped method is called.
Referenced by World::stop().
|
protected |
Event for handling play/stop in order to stay syncronized with QT main thread.
Definition at line 309 of file world.cpp.
References World::advance().
real timeStep | ( | ) | const |
get the time step setted
Definition at line 365 of file world.cpp.
References World::timestepv.
Referenced by DOFStatusListener::update(), MultiMotorController::update(), PhySuspension::updateJointInfo(), and PhyHinge::updateJointInfo().
rayCastHitVector worldRayCast | ( | wVector | start, |
wVector | end, | ||
bool | onlyClosest, | ||
const QSet< PhyObject * > & | ignoredObjs = QSet<PhyObject*>() |
||
) |
Returns the bodyes which intersect the ray from start to end.
- Parameters
-
start the starting point of the ray (in the global frame of reference) end the ending point of the ray (in the global frame of reference) onlyClosest if true only the object closest to the ray start is returned, otherwise all objects which intersect the ray are returned ignoredObjs the set of objects to ignore when checking collisions. They are never inserted in returned list of intersected objects. This means that if onlyClosest is true, the first colliding object that doesn't belong to this set is returned
- Returns
- the list of objects intersected by the ray. If onlyClosest is true the list contains at most one object (the intersected one closest to the ray start). If no object is intersected by the ray, an empty list is returned
Definition at line 646 of file world.cpp.
Referenced by SingleIR::update().
Member Data Documentation
|
protected |
Gravity Force.
Definition at line 424 of file world.h.
Referenced by World::gravityForce(), World::setGravityForce(), and World::World().
|
protected |
Vector of Joints inside the World.
See objs description for an explanation of why we use QLinkedList.
Definition at line 440 of file world.h.
Referenced by World::advance(), World::joints(), and World::~World().
Map object -> joints.
Definition at line 442 of file world.h.
Referenced by World::mapObjectsToJoints().
|
protected |
Size of the Newton world.
Definition at line 426 of file world.h.
Referenced by World::setSize(), World::size(), and World::World().
|
protected |
Vector of WObject inside the World.
Here we use QLinkedList because we need to modify the list while iterating on it. It could happend that during World destruction we destroy an object that owns other objects which follow it in the list. In this situation the destructor of the object would take care of destroying owned objects. Owned objects destructors would then call popObject() which must be able to remove the object from this list, otherwise World destructor would try to access already freed objects. If instead owned objects precede their owner they are automatically skipped
Definition at line 436 of file world.h.
Referenced by World::advance(), World::getObject(), World::objects(), and World::~World().
|
protected |
The elapsed simulation-time from last calls of initialize()
Definition at line 420 of file world.h.
Referenced by World::advance(), World::advanceUntil(), World::elapsedTime(), World::initialize(), World::resetElapsedTime(), and World::World().
|
protected |
The time step.
Definition at line 422 of file world.h.
Referenced by World::advance(), World::setTimeStep(), World::timeStep(), and World::World().
The documentation for this class was generated from the following files: