|
AGX Dynamics 2.42.1.1
|
Sensor environment implementation where different sensors collects data given a set of added objects, such as rigid bodies, geometries, shapes, wires, cables, terrains, etc. More...
#include <Environment.h>
Inheritance diagram for agxSensor::Environment:Public Member Functions | |
| Environment () | |
| Default constructor - the default sensor systems will be added. | |
| virtual | ~Environment () |
| Destructor. | |
| bool | add (agx::RigidBody *rb) |
| Add rigid body to be visible to sensors in this sensor environment. | |
| bool | add (agxCollide::Geometry *geometry) |
| Add geometry to be visible to sensors in this sensor environment. | |
| bool | add (agxCollide::Shape *shape) |
| Add shape to be visible to sensors in this sensor environment. | |
| bool | add (agxModel::DeformableObject *deformable) |
| Add deformable object to be visible to sensors in this sensor environment. | |
| bool | add (agxSDK::LinkedStructure *linkedStructure) |
| Add agxCable::Cable, agxVehicle::Track, agxModel::Beam, ..., to be visible to sensors in this sensor environment. | |
| bool | add (agxTerrain::Terrain *terrain) |
| Add terrain to be visible to sensors in this sensor environment. | |
| bool | add (agxTerrain::TerrainPager *pager) |
| Add terrain pager to be visible to sensors in this sensor environment. | |
| bool | add (agxWire::Wire *wire) |
| Add wire to be visible to sensors in this sensor environment. | |
| bool | add (SystemNode *system) |
| Add system root node (normally an implementation of a sensor) to this sensor environment. | |
| MagneticField * | getMagneticField () |
| const MagneticField * | getMagneticField () const |
| RtSceneRef | getScene () const |
| bool | remove (agx::RigidBody *rb) |
| Remove the rigid body, and all its geometries, from this sensor environment. | |
| bool | remove (agxCollide::Geometry *geometry) |
| Remove geometry, and all its shapes, from this sensor environment. | |
| bool | remove (agxCollide::Shape *shape) |
| Remove shape from this sensor environment. | |
| bool | remove (agxModel::DeformableObject *deformable) |
| Remove deformable object from this sensor environment. | |
| bool | remove (agxSDK::LinkedStructure *linkedStructure) |
| Remove linked structure (agxCable::Cable, agxVehicle::Track, agxModel::Beam, ...) from this sensor environment. | |
| bool | remove (agxTerrain::Terrain *terrain) |
| Remove terrain from this sensor environment. | |
| bool | remove (agxTerrain::TerrainPager *pager) |
| Remove terrain pager from this sensor environment. | |
| bool | remove (agxWire::Wire *wire) |
| Remove wire from this sensor environment. | |
| bool | remove (SystemNode *system) |
| Remove system root node (sensor) from this sensor environment. | |
| void | setMagneticField (MagneticField *magneticField) |
| Set environment magnetic field. | |
Public Member Functions inherited from agxSDK::ISensorEnvironment | |
| ISensorEnvironment ()=default | |
| Default constructor. | |
| virtual | ~ISensorEnvironment ()=default |
| Destructor. | |
| virtual void | addNotification ()=0 |
| Called when added to a simulation or explicitly called when the sensor simulation should start. | |
| virtual void | fetchStepResults ()=0 |
| Block main thread until the sensor simulation is done and the data/results/outputs are accessible. | |
| const Simulation * | getSimulation () const |
| virtual void | removeNotification ()=0 |
| Called when removed from a simulation or explicitly called when the sensor simulation should stop/join the main thread. | |
| virtual void | step (agx::Real dt)=0 |
Start the sensor simulation and step for delta time dt. | |
| virtual void | updateGraphics (const agxRender::RenderManager &renderManager)=0 |
| Update the graphical components of the sensor environment. | |
Public Member Functions inherited from agx::Referenced | |
| Referenced () | |
| Default constructor. | |
| Referenced (const Referenced &) | |
| template<typename T > | |
| T * | as () |
| Subclass casting. | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. | |
| template<typename T > | |
| const T * | asSafe () const |
| int | getReferenceCount () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. | |
| Referenced & | operator= (const Referenced &) |
| Assignment operator. Will increment the number of references to the referenced object. | |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
Public Member Functions inherited from agxStream::Serializable | |
| virtual | ~Serializable () |
| Destructor for normal C++ use but hidden from SWIG bindings. | |
| virtual const char * | getClassName () const |
| bool | getEnableSerialization () const |
| bool | getEnableUuidGeneration () |
| agx::UInt32 | getIndex () const |
| This index is given at creation of this object. | |
| virtual StorageAgent * | getStorageAgent () const =0 |
| agx::Uuid | getUuid () const |
| bool | isFinished () const |
| void | setEnableSerialization (bool flag) |
| Set to false to disable serialization of this object. | |
| void | setFinished () |
| Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. | |
| void | setUuid (const agx::Uuid &uuid) |
| Explicitly set a Uuid on a serializable object. | |
Static Public Member Functions | |
| static Environment * | get (agxSDK::Simulation *simulation) |
| static const Environment * | get (const agxSDK::Simulation *simulation) |
| static Environment * | getOrCreate (agxSDK::Simulation *simulation) |
Returns an existing or creates and initializes a new instance of a sensor environment given a simulation. | |
Static Public Member Functions inherited from agx::Referenced | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Static Public Member Functions inherited from agxStream::Serializable | |
| static void | setEnableUuidGeneration (bool flag) |
| Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. | |
Additional Inherited Members | |
Protected Member Functions inherited from agx::Referenced | |
| virtual | ~Referenced () |
| Destructor. | |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
Protected Member Functions inherited from agxStream::Serializable | |
| Serializable () | |
| Default constructor. | |
| Serializable (const Serializable &other) | |
| Copy constructor. | |
| void | generateUuid () |
Static Protected Member Functions inherited from agx::Referenced | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. | |
Protected Attributes inherited from agx::Referenced | |
| Mutex | m_mutex |
| ObserverContainer | m_observers |
| AtomicValue | m_refCount |
Sensor environment implementation where different sensors collects data given a set of added objects, such as rigid bodies, geometries, shapes, wires, cables, terrains, etc.
This sensor environment can be run in cooperative mode with an agxSDK::Simulation instance (normal use case) or standalone and is always integrated in its own thread.
In cooperative mode, the stepping/integration of the sensor environment starts after the simulation step event 'preCollide'. New/updated sensor data is available from the simulation step event 'post'. This means that any changes, such as updated transforms or configuration changes, has to be made before calling simulation 'stepForward' or in a 'preCollide' step event.
Important: When the sensor environment is integrated in its own thread it's undefined to interact with sensors and/or adding removing objects during the collision detection, contact event callbacks, pre step events and dynamics solvers integrations. Data access and object/sensor modifications are safe to do in post step events, post contact events, last step events and outside of 'stepForward'.
To create or access a sensor simulation using agxSDK::Simulation, do:
Cooperative: agxSensor::Environment* sensorEnv = agxSensor::Environment::getOrCreate( simulation ); simulation->stepForward(); // Will step the sensor environment.
OR (also cooperative) agxSensor::EnvironmentRef sensorEnv = new agxSensor::Environment(); simulation->setSensorEnvironment( sensorEnv ); simulation->stepForward(); // Will step the sensor environment.
Standalone: agxSensor::EnvironmentRef sensorEnv = new agxSensor::Environment(); sensorEnv->addNotification(); // Important, will create a separate thread that the sensor environment is integrated in. while ( !done ) { sensorEnv->step( 0.0166667 ); // Read data from added objects and start the sensor environment simulation step - in the thread created in addNotification. ... // Do other things. sensorEnv->fetchStepResults(); // Blocking until the sensor environment has been integrated and new sensor output data is available. }
Definition at line 112 of file agxSensor/Environment.h.
| agxSensor::Environment::Environment | ( | ) |
Default constructor - the default sensor systems will be added.
|
virtual |
Destructor.
| bool agxSensor::Environment::add | ( | agx::RigidBody * | rb | ) |
Add rigid body to be visible to sensors in this sensor environment.
All geometries (and shapes) of the given rigid body will also be added and visible to sensors. If added successfully, a reference to the rigid body will be held until the rigid body is removed or when this sensor environment is removed from its cooperative simulation (or explicit call to removeNotification for standalone).
| rb | - rigid body instance (and its geometries) to add |
| bool agxSensor::Environment::add | ( | agxCollide::Geometry * | geometry | ) |
Add geometry to be visible to sensors in this sensor environment.
All shapes of the given geometry will also be added and visible to sensors. If added successfully, a reference to the geometry will be held until the geometry is removed or when this sensor environment is removed from its cooperative simulation (or explicit call to removeNotification for standalone).
| geometry | - geometry instance (and its shapes) to add |
| bool agxSensor::Environment::add | ( | agxCollide::Shape * | shape | ) |
Add shape to be visible to sensors in this sensor environment.
If added successfully, a reference to the shape will be held until the shape is removed or when this sensor environment is removed from its cooperative simulation (or explicit call to removeNotification for standalone).
| shape | - shape instance to add |
| bool agxSensor::Environment::add | ( | agxModel::DeformableObject * | deformable | ) |
Add deformable object to be visible to sensors in this sensor environment.
If added successfully, a reference to the deformable will be held until the deformable is removed or when this sensor environment is removed from its cooperative simulation (or explicit call to removeNotification for standalone).
| deformable | - deformable instance to add |
| bool agxSensor::Environment::add | ( | agxSDK::LinkedStructure * | linkedStructure | ) |
Add agxCable::Cable, agxVehicle::Track, agxModel::Beam, ..., to be visible to sensors in this sensor environment.
The wheels (agxVehicle::TrackWheel) of agxVehicle::Track instances are added as separate rigid bodies during this call, but can be removed separately if they shouldn't be visible to sensors, e.g., sensorEnv->remove( wheel4->getRigidBody() ). If added successfully, a reference to the linked structure will be held until the linked structure is removed or when this sensor environment is removed from its cooperative simulation (or explicit call to removeNotification for standalone).
| linkedStructure | - agxCable::Cable, agxVehicle::Track, agxModel::Beam, ..., instance to add |
| bool agxSensor::Environment::add | ( | agxTerrain::Terrain * | terrain | ) |
Add terrain to be visible to sensors in this sensor environment.
The granular bodies and topology changes will be reflected and visible to the sensors and the active granular bodies will inherit the surface material (or other) properties of this given terrain instance. If added successfully, a reference to the terrain will be held until the terrain is removed or when this sensor environment is removed from its cooperative simulation (or explicit call to removeNotification for standalone).
| terrain | - terrain instance to add |
| bool agxSensor::Environment::add | ( | agxTerrain::TerrainPager * | pager | ) |
Add terrain pager to be visible to sensors in this sensor environment.
The granular bodies and topology changes will be reflected and visible to the sensors and the active granular bodies will inherit the surface material (or other) properties of this given terrain pager instance. If added successfully, a reference to the terrain pager will be held until the terrain pager is removed or when this sensor environment is removed from its cooperative simulation (or explicit call to removeNotification for standalone).
| pager | - terrain pager instance to add |
| bool agxSensor::Environment::add | ( | agxWire::Wire * | wire | ) |
Add wire to be visible to sensors in this sensor environment.
If added successfully, a reference to the wire will be held until the wire is removed or when this sensor environment is removed from its cooperative simulation (or explicit call to removeNotification for standalone).
| wire | - wire instance to add |
| bool agxSensor::Environment::add | ( | SystemNode * | system | ) |
Add system root node (normally an implementation of a sensor) to this sensor environment.
If added successfully, the system will receive calls to 'synchronize', from the main thread, and 'execute', from the sensor environment thread, each step.
| system | - system to add |
|
static |
| simulation | - simulation instance for the sensor environment |
simulation hasn't been assigned one
|
static |
| simulation | - simulation instance for the sensor environment |
simulation hasn't been assigned one | MagneticField * agxSensor::Environment::getMagneticField | ( | ) |
| const MagneticField * agxSensor::Environment::getMagneticField | ( | ) | const |
|
static |
Returns an existing or creates and initializes a new instance of a sensor environment given a simulation.
This method will only return nullptr if the given simulation is nullptr.
| simulation | - simulation instance for the sensor environment |
simulation is nullptr | RtSceneRef agxSensor::Environment::getScene | ( | ) | const |
| bool agxSensor::Environment::remove | ( | agx::RigidBody * | rb | ) |
Remove the rigid body, and all its geometries, from this sensor environment.
The rigid body will no longer be visible to sensors.
| rb | - rigid body instance to remove |
| bool agxSensor::Environment::remove | ( | agxCollide::Geometry * | geometry | ) |
Remove geometry, and all its shapes, from this sensor environment.
The geometry will no longer be visible to sensors.
| geometry | - geometry instance to remove |
| bool agxSensor::Environment::remove | ( | agxCollide::Shape * | shape | ) |
Remove shape from this sensor environment.
The shape will no longer be visible to sensors.
| shape | - shape instance to remove |
| bool agxSensor::Environment::remove | ( | agxModel::DeformableObject * | deformable | ) |
Remove deformable object from this sensor environment.
The deformable will no longer be visible to sensors.
| deformable | - deformable instance to remove |
| bool agxSensor::Environment::remove | ( | agxSDK::LinkedStructure * | linkedStructure | ) |
Remove linked structure (agxCable::Cable, agxVehicle::Track, agxModel::Beam, ...) from this sensor environment.
The linked structure will no longer be visible to sensors. The wheels of agxVehicle::Track instances will also be removed.
| linkedStructure | - linked structure instance to remove |
| bool agxSensor::Environment::remove | ( | agxTerrain::Terrain * | terrain | ) |
Remove terrain from this sensor environment.
The terrain will no longer be visible to sensors.
| terrain | - terrain instance to remove |
| bool agxSensor::Environment::remove | ( | agxTerrain::TerrainPager * | pager | ) |
Remove terrain pager from this sensor environment.
The terrain pager will no longer be visible to sensors.
| pager | - terrain pager instance to remove |
| bool agxSensor::Environment::remove | ( | agxWire::Wire * | wire | ) |
Remove wire from this sensor environment.
The wire will no longer be visible to sensors.
| wire | - wire instance to remove |
| bool agxSensor::Environment::remove | ( | SystemNode * | system | ) |
Remove system root node (sensor) from this sensor environment.
| system | - system to remove |
| void agxSensor::Environment::setMagneticField | ( | MagneticField * | magneticField | ) |
Set environment magnetic field.
| magneticField | - magnetic field to span the environment, nullptr removes the current magnetic field |