14#ifndef MOMENTUM_SIMULATION_H
15#define MOMENTUM_SIMULATION_H
17#include "momentum_export.h"
18#include "momentum_namespace.h"
27#include "MaterialPair.h"
28#include "GranularBodySystem.h"
29#include "GranularContacts.h"
30#include "BodyDistribution.h"
34#include "ContactPoint.h"
35#include "PrismaticJoint.h"
36#include "CylindricalJoint.h"
37#include "ConveyorBelt.h"
40#include "SpringJoint.h"
41#include "HingeJoint.h"
43#include <agx/ContactForceReader.h>
44#include <agx/GranularContactForceReader.h>
51 class SimulationController;
77 IMPACT_AND_RESTING = (IMPACT & RESTING)
89 Simulation(agxSDK::Simulation* simulation, agxSDK::SimulationController* simulationController);
104#ifndef AGX_MOMENTUM_ANALYSIS_API
130#ifndef AGX_MOMENTUM_ANALYSIS_API
140 const Vec3& position,
141 const Quat& rotation,
142 const Vec3& velocity );
416 std::shared_ptr<RigidBody>
getRigidBody(
const std::string& name)
const;
424 std::shared_ptr<Joint>
getJoint(
const std::string& name)
const;
456 std::shared_ptr<BallJoint>
getBallJoint(
const std::string& name)
const;
464 std::shared_ptr<LockJoint>
getLockJoint(
const std::string& name)
const;
480 std::shared_ptr<Observer>
getObserver(
const std::string& name)
const;
488 std::shared_ptr<Material>
getMaterial(
const std::string& name)
const;
506 std::shared_ptr<MaterialPair>
getMaterialPair(
const std::string& firstName,
const std::string& secondName)
const;
514 std::shared_ptr<Geometry>
getGeometry(
const std::string& name )
const;
580 bool onlyCheckForMidPoint )
const;
615 std::shared_ptr<Emitter>
getEmitter(
const std::string& name)
const;
629 std::shared_ptr<Sensor>
getSensor(
const std::string& name )
const;
747 size_t write(
const std::string& filename );
772#ifndef AGX_MOMENTUM_ANALYSIS_API
783 std::string __str__()
const;
791 std::string getMaterialName(
const std::string& name)
const;
794 agx::ContactForceReaderRef m_contactForceReader;
795 agx::GranularContactForceReaderRef m_granularContactForceReader;
Matrix class for rigid transformations (translation, rotation).
Definition: AffineMatrix4x4.h:51
Wrapper class for a rigid body model used in the body distribution.
Definition: BodyDistribution.h:38
A class describing a Geometry.
Definition: Geometry.h:44
A GranularBody class, representing a 6DOF spherical object that interacts with the environment trough...
Definition: GranularBody.h:36
A class describing a Material which is attached to a Geometry.
Definition: Material.h:41
The object holding quaternions and providing operations on these.
Definition: Quat.h:55
A rigid body is a moving (translation/rotation) object with a mass and a inertia.
Definition: RigidBody.h:52
This class is used to access an existing simulation with all its contents including joints,...
Definition: Simulation.h:70
void removeEmittedBodiesInGeometry(const Geometry *geometry)
Utility method for quickly removing emitted Non-Spherical-Shapes(NSS) bodies currently inside the spe...
bool loadGranularFile(const std::string &filename, Material *initMaterial, const AffineMatrix4x4 &offset=AffineMatrix4x4())
Load an .agx file that contains both granular and Non-Spherical-Shapes(NSS) bodies into the simulatio...
Vec3 getGranularRigidBodyContactForces(const RigidBody *body=nullptr)
Get sum of all contact (Normal and Friction) forces in world coordinate system between a rigid bodies...
Vec3 getGranularRigidBodySumAbsoluteFrictionContactForces(const RigidBody *body=nullptr)
Get sum of all absolute friction contact forces between a rigid body and the granular bodies in the s...
ConveyorBeltVector getConveyorBelts() const
Get all conveyor belts associated with the simulation.
Vec3 getNormalContactForces(const Geometry *geometry1, const Geometry *geometry2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all Normal contact forces in world coordinate system between two geometries.
Vec3 getSumAbsoluteNormalContactForces(const RigidBody *rb, const Geometry *geo, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute normal contact forces between two rigid bodies.
bool removeDisabledCollisionGroupPair(const std::string &name1, const std::string &name2)
Remove a pair of geometry collision groups to re-enable contact generation between two named geometry...
Vec3 getSumAbsoluteContactForces(const RigidBody *body1, const RigidBody *body2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute contact forces between two rigid bodies.
std::shared_ptr< MaterialPair > getMaterialPair(const std::string &firstName, const std::string &secondName) const
Get a specific MaterialPair between two named materials.
unsigned int getNumRestingIterations() const
RigidBodyVector filterRigidBodiesInGeometry(const Geometry *geometry, const RigidBodyVector &rigidBodies, bool onlyCheckForMidPoint) const
Return a subset of specified rigid bodies that intersect with a specified geometry.
Vec3 getSumAbsoluteNormalContactForces(const RigidBody *body1, const RigidBody *body2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute normal contact forces between two rigid bodies.
ContactType
Definition: Simulation.h:74
JointVector getJoints() const
Get all joints associated with the simulation.
Vec3 getSumAbsoluteContactForces(const RigidBody *rb, const Geometry *geo, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute contact forces between a rigid body and a geometry.
MaterialPairVector getMaterialPairs() const
Get all contact materials associated with the simulation.
Vec3 getNormalContactForces(const RigidBody *body1, const RigidBody *body2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all Normal contact forces in world coordinate system between two rigid bodies.
Vec3 getGranularGeometrySumAbsoluteContactForces(const Geometry *geometry=nullptr)
Get sum of all absolute contact forces between a geometry.
BallJointVector getBallJoints() const
Get all ball joints associated with the simulation.
unsigned int getNumParallelRestingIterations() const
std::shared_ptr< Emitter > getEmitter(const std::string &name) const
Get a specific named Emitter.
Vec3 getGranularRigidBodySumAbsoluteNormalContactForces(const RigidBody *body=nullptr)
Get sum of all absolute normal contact forces between a rigid body and the granular bodies in the sim...
Vec3 getGranularRigidBodyNormalContactForces(const RigidBody *body=nullptr)
Get sum of all Normal contact forces in world coordinate system between a rigid body and the granular...
void addDisabledCollisionGroupPair(const std::string &name1, const std::string &name2)
Add a pair of geometry collision groups which will be disabled for contact generation.
Vec3 getFrictionContactForces(const RigidBody *rb, const Geometry *geo, ContactType type=IMPACT_AND_RESTING)
Get sum of all Friction contact forces in world coordinate system between a rigid body and a geometry...
friend Simulation * getSimulation()
Return a pointer to the simulation object which can be used to access all joints, bodies,...
Vec3 getGranularGeometryContactForces(const Geometry *geometry=nullptr)
Get sum of all contact (Normal and Friction) forces in world coordinate system between a geometry and...
CylindricalJointVector getCylindricalJoints() const
Get all cylindrical joints associated with the simulation.
std::shared_ptr< HingeJoint > getHingeJoint(const std::string &name) const
Get a specific named HingeJoint.
EmitterVector getEmitters() const
Get all emitters associated with the simulation.
Vec3 getGranularGeometrySumAbsoluteFrictionContactForces(const Geometry *geometry=nullptr)
Get sum of all absolute friction contact forces between a geometry and the granular bodies in the sim...
std::shared_ptr< SpringJoint > getSpringJoint(const std::string &name) const
Get a specific named SpringJoint.
std::shared_ptr< LockJoint > getLockJoint(const std::string &name) const
Get a specific named LockJoint.
std::shared_ptr< Material > getMaterial(const std::string &name) const
Get a specific named Material.
double getTimeStep() const
Get the current length of the time step in seconds.
void setGravity(const Vec3 &gravity)
Set the uniform gravity of the simulation in m/s^2.
RigidBodyVector getEmittedBodies() const
ContactPointVector getContacts(const RigidBody *body1, const RigidBody *body2=nullptr) const
Get all contacts in the simulation for the current timestep that involves two specified RigidBodies.
GeometryVector getGeometries() const
Get all geometries associated with the simulation.
Vec3 getGranularGeometryFrictionContactForces(const Geometry *geometry=nullptr)
Get sum of all Friction contact forces in world coordinate system between a geometry and the granular...
LockJointVector getLockJoints() const
Get all lock joints associated with the simulation.
unsigned int getNumImpactIterations() const
HingeJointVector getHingeJoints() const
Get all hinge joints associated with the simulation.
std::shared_ptr< Sensor > getSensor(const std::string &name) const
Get a specific named Sensor.
Vec3 getSumAbsoluteContactForces(const Geometry *geometry1, const Geometry *geometry2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute contact forces between two geometries.
GranularRigidBodyContactVector getGranularGeometryContacts(const Geometry *geometry=nullptr) const
Get granular contacts against a Geometry.
std::shared_ptr< CylindricalJoint > getCylindricalJoint(const std::string &name) const
Get a specific named CylindricalJoint.
bool operator==(const Simulation &other) const
Vec3 getFrictionContactForces(const Geometry *geometry1, const Geometry *geometry2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all Friction contact forces in world coordinate system between two geometries.
GranularRigidBodyContactVector getGranularRigidBodyContacts(const RigidBody *rigidBody=nullptr) const
Get granular contacts against a RigidBody.
std::shared_ptr< GranularBodySystem > getGranularBodySystem() const
Get the GranularBodySystem coupled to the active Simulation.
GranularGranularContactVector getGranularContacts(const GranularBody *granularBody=nullptr) const
Get granular contacts against a GranularBody.
bool writeGranularFile(const std::string &filename, const GranularBodyVector &granularBodies, const RigidBodyVector &rigidBodies) const
Write granular and Non-Spherical-Shapes(NSS) bodies that intersect with a specified geometry to an ....
std::shared_ptr< ConveyorBelt > getConveyorBelt(const std::string &name) const
Get a specific named Conveyor Belt.
Vec3 getContactForces(const Geometry *geometry1, const Geometry *geometry2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all contact (Normal and Friction) forces in world coordinate system between two geometries...
Vec3 getSumAbsoluteFrictionContactForces(const Geometry *geometry1, const Geometry *geometry2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute friction contact forces between two geometries.
SpringJointVector getSpringJoints() const
Get all spring joints associated with the simulation.
Vec3 getFrictionContactForces(const RigidBody *body1, const RigidBody *body2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all Friction contact forces in world coordinate system between two rigid bodies.
std::shared_ptr< Geometry > getGeometry(const std::string &name) const
Get a specific named Geometry .
std::shared_ptr< MaterialPair > getMaterialPair(Material *firstMaterial, Material *secondMaterial) const
Get a specific MaterialPair between two materials.
Vec3 getGranularRigidBodySumAbsoluteContactForces(const RigidBody *body=nullptr)
Get sum of all absolute contact forces between a rigid body and the granular bodies in the simulation...
SensorVector getSensors() const
Get all Sensors associated with the simulation.
Vec3 getGravity() const
Get the uniform gravity in m/s^2.
std::shared_ptr< BallJoint > getBallJoint(const std::string &name) const
Get a specific named BallJoint.
ContactPointVector getContacts(const Geometry *geometry1=nullptr, const Geometry *geometry2=nullptr) const
Get all contacts in the simulation for the current timestep that involves two specified geometries.
Vec3 getContactForces(const RigidBody *rb, const Geometry *geo, ContactType type=IMPACT_AND_RESTING)
Get sum of all contact (Normal and Friction) forces in world coordinate system between a rigid body a...
size_t write(const std::string &filename)
Write current simulation state to a file in native .aagx/.agx format, depending on specified file end...
Vec3 getGranularGeometryNormalContactForces(const Geometry *geometry=nullptr)
Get sum of all Normal contact forces in world coordinate system between a geometry and granular bodie...
ObserverVector getObservers() const
Get all observers associated with the simulation.
std::shared_ptr< PrismaticJoint > getPrismaticJoint(const std::string &name) const
Get a specific named PrismaticJoint.
Vec3 getGranularRigidBodyFrictionContactForces(const RigidBody *body=nullptr)
Get sum of all Friction contact forces in world coordinate system between a rigid body and the granul...
std::shared_ptr< RigidBody > getRigidBody(const std::string &name) const
Get a specific named RigidBody.
Vec3 getSumAbsoluteFrictionContactForces(const RigidBody *rb, const Geometry *geo, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute friction contact forces between a rigid body and a geometry.
Vec3 getNormalContactForces(const RigidBody *rb, const Geometry *geo, ContactType type=IMPACT_AND_RESTING)
Get sum of all Normal contact forces in world coordinate system between a rigid body and a geometry.
MaterialVector getMaterials() const
Get all materials associated with the simulation.
double getImpactSpeedThreshold() const
RigidBodyVector getRigidBodies() const
Get all rigid bodies associated with the simulation.
std::shared_ptr< Observer > getObserver(const std::string &name) const
Get a specific named ObserverFrame.
std::shared_ptr< Geometry > getGeometry(unsigned int id) const
Get a specific Geometry given an id.
Vec3 getContactForces(const RigidBody *body1, const RigidBody *body2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all contact (Normal and Friction) forces in world coordinate system between two rigid bodi...
void setImpactSpeedThreshold(double threshold)
Set the speed threshold for when to trigger impacts in contacts according to Newton's impact law.
std::shared_ptr< RigidBody > createRigidBodyFromBodyModel(const BodyModel *bodymodel, const Vec3 &position, const Quat &rotation, const Vec3 &velocity)
Create a rigid body from a distribution model.
PrismaticJointVector getPrismaticJoints() const
Get all prismatic joints associated with the simulation.
Vec3 getSumAbsoluteNormalContactForces(const Geometry *geometry1, const Geometry *geometry2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute normal contact forces between two geometries.
Vec3 getSumAbsoluteFrictionContactForces(const RigidBody *body1, const RigidBody *body2=nullptr, ContactType type=IMPACT_AND_RESTING)
Get sum of all absolute friction contact forces between two rigid bodies.
std::vector< std::pair< std::string, std::string > > getDisabledCollisionGroupPairs() const
Get a list of all disabled collision group pairs.
std::shared_ptr< Joint > getJoint(const std::string &name) const
Get a specific named Joint.
Vec3 getGranularGeometrySumAbsoluteNormalContactForces(const Geometry *geometry=nullptr)
Get sum of all absolute normal contact forces between a geometry and the granular bodies in the simul...
A 3 dimensional vector which can be used to define a point or a vector and contains basic arithmetic.
Definition: Vec3.h:40
Namespace for Momentum Scripting API.
Definition: AffineMatrix4x4.h:29
std::vector< std::shared_ptr< GranularBody > > GranularBodyVector
A vector with objects of the type GranularBody .
Definition: GranularBody.h:362
std::vector< std::shared_ptr< GranularGranularContact > > GranularGranularContactVector
A vector with objects of the type GranularGranularContact .
Definition: GranularContacts.h:135
std::vector< std::shared_ptr< LockJoint > > LockJointVector
A vector with objects of the type LockJoint .
Definition: LockJoint.h:64
std::vector< std::shared_ptr< CylindricalJoint > > CylindricalJointVector
A vector with objects of the type CylindricalJoint .
Definition: CylindricalJoint.h:153
std::vector< std::shared_ptr< PrismaticJoint > > PrismaticJointVector
A vector with objects of the type PrismaticJoint .
Definition: PrismaticJoint.h:106
std::vector< std::shared_ptr< Observer > > ObserverVector
A vector with objects of the type Observer .
Definition: Observer.h:252
std::vector< std::shared_ptr< ContactPoint > > ContactPointVector
A vector with objects of the type ContactPoint .
Definition: ContactPoint.h:43
Simulation * getSimulation()
Return a pointer to the simulation object which can be used to access all joints, bodies,...
std::vector< std::shared_ptr< SpringJoint > > SpringJointVector
A vector with objects of the type SpringJoint .
Definition: SpringJoint.h:127
std::vector< std::shared_ptr< ConveyorBelt > > ConveyorBeltVector
A vector with objects of the type ConveyorBelt .
Definition: ConveyorBelt.h:101
std::vector< std::shared_ptr< Material > > MaterialVector
A vector with objects of the type Material .
Definition: Material.h:83
std::vector< std::shared_ptr< MaterialPair > > MaterialPairVector
A vector with objects of the type MaterialPair .
Definition: MaterialPair.h:252
std::vector< std::shared_ptr< GranularRigidBodyContact > > GranularRigidBodyContactVector
A vector with objects of the type GranularRigidBodyContact .
Definition: GranularContacts.h:231
std::vector< std::shared_ptr< Sensor > > SensorVector
A vector with objects of the type Sensor .
Definition: Sensor.h:130
std::vector< std::shared_ptr< Geometry > > GeometryVector
A vector with objects of the type Geometry .
Definition: Geometry.h:169
std::vector< std::shared_ptr< HingeJoint > > HingeJointVector
A vector with objects of the type HingeJoint .
Definition: HingeJoint.h:106
std::vector< std::shared_ptr< RigidBody > > RigidBodyVector
A vector with objects of the type RigidBody .
Definition: RigidBody.h:749
std::vector< std::shared_ptr< Joint > > JointVector
A vector with objects of the type Joint .
Definition: Joint.h:255
std::vector< std::shared_ptr< BallJoint > > BallJointVector
A vector with objects of the type BallJoint .
Definition: BallJoint.h:65
std::vector< std::shared_ptr< Emitter > > EmitterVector
A vector with objects of the type Emitter .
Definition: Emitter.h:255
Definition: SceneGraph.h:29