Conscience Core
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
conscience_core::simulator::CscPhysicsSimulator Class Reference

#include <CscPhysicsSimulator.h>

Classes

struct  BaseEntityOutputPhysicsState
 
struct  CscEntityPhysicsState
 
struct  MemberPhysicsState
 
struct  MemberState
 
struct  PivotPhysicsState
 
struct  PropellerPhysicsState
 
struct  TranslationPhysicsState
 
struct  WheelPhysicsState
 

Public Types

typedef int EntityOutputId
 

Public Member Functions

const PivotPhysicsStategetPivotState (const CscWorldElementId &entityId, int id) const
 
const PropellerPhysicsStategetPropellerState (const CscWorldElementId &entityId, int id) const
 
const WheelPhysicsStategetWheelState (const CscWorldElementId &entityId, int id) const
 
const TranslationPhysicsStategetTranslationState (const CscWorldElementId &entityId, int id) const
 
 CscPhysicsSimulator (bool integratedPhysicsThread, float simulatorSpeed=1.0)
 
virtual ~CscPhysicsSimulator ()
 
void initFloor ()
 
void removeFloor ()
 
void setFloorRotation (float yaw, float pitch, float roll)
 
void setFloorFriction (float val)
 
bool isEntityPhysicsStateReady (const CscWorldElementId &entityId)
 
void setEntityPhysicsInitDone (const CscWorldElementId &entityId)
 
bool isEntityPhysicsStateLoaded (const CscWorldElementId &entityId)
 
void importEntity (const CscWorldEntity *entity, const CscPoint3dOriented *customPositionAndOrientation=nullptr, bool requiresExternalInit=false)
 
void importObjectIntoPhysicsSimulator (CscWorldObject *object)
 
void importPlaceIntoPhysicsSimulator (CscWorldPlace *place)
 
void importObjectsIntoPhysicsSimulator (vector< CscWorldObject * > *objects)
 
void updateTranslation (const CscWorldElementId &entityId, int translationId, float val, bool relativeValues=false)
 
void updateWheel (const CscWorldElementId &entityId, int wheelId, float val, float cst=1000.0, float speedCoef=1.0)
 
void updateWheels (const CscWorldElementId &entityId, float val)
 
void updatePropeller (const CscWorldElementId &entityId, int propellerId, float val, float cst=1000.0)
 
void updatePivot (const CscWorldElementId &entityId, int pivotId, float newValPercent, bool relativeValues=false)
 
void forceMemberValuesAndVerifyState (const CscWorldElementId &entityId, const CscMemberInputStatus *inputsValues, const bool applyPosition[3], const bool applyEuler[3], const bool applyAcceleration[3], optional< int > nbMaxIteration={}, optional< int > maxLoopDurationMillis={}, const CscState *verifyState=nullptr)
 
int moveMemberToStateFromMember (const CscWorldElementId &entityId, const CscMemberInputStatus *inputsValues, const bool applyPosition[3], const bool applyEuler[3], const bool applyAcceleration[3], optional< int > nbMaxIteration={}, optional< int > maxLoopDurationMillis={}, int tryNumber=0)
 
void moveMember (const CscWorldElementId &entityId, float *vals, int bodyIndex, int isTranslate)
 
void memberTeleportToOrigin (const CscWorldElementId &entityId, int bodyIndex, float posX, float posY, float posZ)
 
void memberTeleportToRotation (const CscWorldElementId &entityId, int bodyIndex, float yaw, float pitch, float roll)
 
void memberTeleportToPositionAndAngle (const CscWorldElementId &entityId, int memberId, const CscPoint3dOriented *target, bool resetOutputsToInitialVals=false, optional< int > nbMaxIteration={}, optional< int > maxLoopDurationMillis={}, bool callPlayStateListener=false)
 
void entityTeleport (const CscWorldElementId &entityId, const CscPoint3dOriented *target)
 
void forceState (const CscWorldElementId &entityId, const CscState *appliedState, int memberIdForInputs, const bool applyPos[3], const bool applyRot[3], const bool applyAcc[3], optional< int > nbMaxIteration={}, optional< int > maxLoopDurationMillis={}, bool callPlayStateListener=false)
 
void playSequence (const CscWorldElementId &entityId, CscState *init, CscSequence *sequence, const map< int, CscPivotMovementType > &pivotMovementByPivotId, bool geneticAi=false, bool extrapolationRealTime=false)
 
void updateMemberPhysics (const CscWorldElementId &entityId, int itemId, float mass, float friction, float restitution, float linearDamping, float angularDamping)
 
void updatePivotPhysics (const CscWorldElementId &entityId, int id, float min, float max, float softness, float bias, float relaxation, float speedMax, float percentSpeedMax)
 
void updatePropellerPhysics (const CscWorldElementId &entityId, int id, float speedMax)
 
void updateWheelMaxSpeed (const CscWorldElementId &entityId, int wheelId, float newSpeedMax)
 
void updateTranslationPhysics (const CscWorldElementId &entityId, int translationId, float newMaxSpped)
 
void updateBehaviorMode (const CscWorldElementId &entityId, int modeId, int memberId)
 
void updateMemberEulers (const CscWorldElementId &entityId, int memberId, double eulerX, double eulerY, double eulerZ)
 
void updateMemberPosition (const CscWorldElementId &entityId, int memberId, float posX, float posY, float posZ)
 
void updatePivotSpeedMax (const CscWorldElementId &entityId, int id, float speedMax)
 
void disableMembersCollisions (const CscWorldElementId &entityId)
 
void enableMembersCollisions (const CscWorldElementId &entityId)
 
bool hadEntityReachedState (const CscWorldElementId &entityId, const CscState *objectiveState, float epsilon)
 
float getJointHingeAngle (const CscWorldElementId &entityId, int jointIdIn) const
 
vector< const CscMemberInputStatus * > * getCurrentInputs (const CscWorldElementId &entityId)
 
virtual CscStategetCurrentState (const CscWorldElementId &entityId)
 
CscStatefillStateInputs (const CscWorldElementId &entityId, const CscState *incompleteState)
 
void stepSimulationRealTime ()
 
void stepSimulationFutureVision (int millisecondsFromNow, int nbSubSteps=55)
 
void setGravity (float xIn, float yIn, float zIn)
 
void setEntityGravity (const CscWorldElementId &entityId, float xIn, float yIn, float zIn)
 
const CscWorldObjectgetObjectByIndex (int index) const
 
void setOnStatePlayedListener (PlayStateListener onStatePlayedListener)
 
void setSimulatorSpeed (float speed)
 
void setState (const CscWorldElementId &entityId, CscState *state, bool relativeValues=false, int duration=200)
 
void playState (const CscWorldElementId &entityId, CscState *state, int duration=0, int delay=0, bool relativeValues=false)
 
void moveObjectToPosition (CscWorldElement *object, const CscPoint3d *targetPosition)
 
void moveObjectToRotation (CscWorldElement *object, const CscPoint3d *targetRotation)
 
void moveObjectToPositionAndRotation (CscWorldElement *object, const CscPoint3d *targetPosition, const CscPoint3d *targetRotation)
 
vector< CscPoint3d * > * getEnvObjectShapesVertex (CscWorldElementId objectId)
 
int getEnvObjectShapesVertexCount (CscWorldElementId objectId)
 
void removeEntity (const CscWorldElementId &entityId)
 
void clearPlaces ()
 
void clearObjects ()
 
void removeConscienceMemberFrontFocus ()
 
CscPoint3dOrientedgetFocusBarPoint ()
 
CscPoint3dOrientedgetFocusSpherePoint ()
 
void focusVisionIntoPosition (float posX, float posY, float posZ)
 
void setAllPivotsToRelaxedMode (const CscWorldElementId &entityId)
 
void setAllPivotsMotorDisabled (const CscWorldElementId &entityId, bool enabled)
 
void unitUpdatePivots ()
 
void unitUpdateTranslations ()
 
void removeObjectById (CscWorldElementId objectId)
 
void removeObjectByName (string name)
 
void removePlaceById (string placeId)
 
vector< CscPoint3d * > performRayScale (const CscPoint3d *position, const vector< const CscPoint3d * > &rayEnds, optional< int > collisionFilterGroup={COL_ENV_PLACE|COL_FLOOR|COL_ROBOT_MEMBERS|COL_ENV_OBJ}, optional< int > collisionFilterMask={COL_ENV_PLACE|COL_FLOOR|COL_ENV_OBJ})
 
float getPivotLimitMin (const CscWorldElementId &entityId, int pivotId) const
 
float getPivotLimitMax (const CscWorldElementId &entityId, int pivotId) const
 
const MemberStategetMemberStateById (const CscWorldElementId &entityId, int id) const
 
const MemberStategetMemberState (const CscWorldElementId &entityId, const CscMember *member) const
 
const MemberStategetMemberStateByName (const CscWorldElementId &entityId, const string &memberName) const
 
string getPivotOtherMember (const CscWorldElementId &entityId, const string &memberName)
 
vector< CscState * > dividingOneStateIntoSubStates (CscState *stateToDivide, CscState *currentState, int durationStateToDivide, int nbStateToDivide, float durationLastSubStep, const map< int, CscPivotMovementType > &pivotMovementByPivotId)
 Divides a given state into multiple sub-states based on the specified duration and number of states to divide. More...
 
CscSequencedividingAllStatesOfOneSequenceIntoSubStates (CscSequence *sequenceToDivide, CscState *initialState, const map< int, CscPivotMovementType > &pivotMovementByPivotId)
 Divides all states in a given sequence into sub-states. More...
 
map< int, CscPoint3d * > getCenterOfMassOfAllMemberByMemberId (const CscWorldElementId &entityId)
 
CscPoint3dfindCenterOfMass (const CscEntityModel *entityModel, map< int, CscPoint3d * > centerOfMassOfAllMemberByMemberId)
 Computes the center of mass for a given entity model using member mass centers. More...
 

Public Attributes

const unsigned long long id
 
btDiscreteDynamicsWorld * m_dynamicsWorld = nullptr
 
float precisionGyro
 
int precisionAction
 
bool integratedPhysicsThread
 
long curTimeInMicroseconds
 
long prevTimeInMicroseconds
 
float simulatorSpeed
 
btClock clock
 
const float fixedTimeStep = 1.0 / 100.0
 
const float minFPS = 16.6666666666f
 
btFixedConstraint * visionCnt1 = NULL
 
btHingeConstraint * visionCnt2 = NULL
 

Protected Member Functions

btRigidBody * localCreateElasticBody (btScalar mass, const btTransform &startTransform, btCollisionShape *shape)
 
btRigidBody * localCreateRigidBody (btScalar mass, const btTransform &startTransform, btCollisionShape *shape)
 
void setMemberKinematicMode (const CscWorldElementId &entityId, int memberId, bool kinematicMode)
 
void memberApplyAcceleration (const CscWorldElementId &entityId, int bodyIndex, float accX, float accY, float accZ)
 
void clearAllForces (const CscWorldElementId &entityId)
 
void activateEntityPhysics (const CscWorldElementId &entityId)
 
bool samePosition (float x1, float y1, float z1, float x2, float y2, float z2, float epsilon)
 
bool sameEuler (float yaw1, float pitch1, float roll1, float yaw2, float pitch2, float roll2, float epsilon)
 
bool allMembersImmobile (const CscWorldElementId &entityId, float epsilon)
 
map< int, float > getCurrentPropellers ()
 
map< int, float > getCurrentWheels ()
 
map< int, float > getCurrentTranslations ()
 
map< int, float > getCurrentJoints ()
 
string toDebugLogMemberInputs (const CscWorldElementId &entityId, int memberIndex)
 
void removeAndDeleteBody (btRigidBody *)
 
void removeObjectByIndex (int index)
 
void fireStatePlayed (const CscWorldElementId &entityId, const CscState *state, int duration=0, int delay=0, bool relativeValues=false)
 

Static Protected Member Functions

static CscMemberPhysicsModelingType definePhysicsModelingType (const CscMember *member)
 
static void buildConvexHull (CscWorldElement *object)
 
static void buildConcaveHull (CscWorldElement *object, float alphaShapeValue)
 

Protected Attributes

float floorWidth = 6000.0
 
float floorHeight = 25.4
 
float floorLength = 6000.0
 
float globalGravity = -9.81
 
btBroadphaseInterface * m_broadphase
 
btCollisionDispatcher * m_dispatcher
 
btDefaultCollisionConfiguration * m_collisionConfiguration
 
btSequentialImpulseConstraintSolver * m_solver
 
thread * simulatorPhysicsThread = nullptr
 
bool simulatorPhysicsThreadRunning = false
 
bool simulatorPhysicsThreadStopped = true
 
btRigidBody * floorBody = nullptr
 
map< CscWorldElementId, CscEntityPhysicsState * > entities
 
map< CscWorldElementId, btRigidBody * > placeBodies
 
vector< CscWorldObject * > environmentObjects
 
map< CscWorldElementId, btRigidBody * > otherBodies
 
map< CscWorldElementId, btCollisionShape * > otherShapes
 
btRigidBody * focusSphereBody = nullptr
 
btRigidBody * focusBarBody = nullptr
 
float speedFactor = 1.0
 
std::unique_ptr< CscLoggerlogger
 
recursive_mutex simulatorMutex
 
optional< PlayStateListeneronStatePlayedListener = {}
 

Member Typedef Documentation

◆ EntityOutputId

Constructor & Destructor Documentation

◆ CscPhysicsSimulator()

conscience_core::simulator::CscPhysicsSimulator::CscPhysicsSimulator ( bool  integratedPhysicsThread,
float  simulatorSpeed = 1.0 
)

◆ ~CscPhysicsSimulator()

conscience_core::simulator::CscPhysicsSimulator::~CscPhysicsSimulator ( )
virtual

Member Function Documentation

◆ activateEntityPhysics()

void conscience_core::simulator::CscPhysicsSimulator::activateEntityPhysics ( const CscWorldElementId entityId)
protected

◆ allMembersImmobile()

bool conscience_core::simulator::CscPhysicsSimulator::allMembersImmobile ( const CscWorldElementId entityId,
float  epsilon 
)
protected

◆ buildConcaveHull()

void conscience_core::simulator::CscPhysicsSimulator::buildConcaveHull ( CscWorldElement object,
float  alphaShapeValue 
)
staticprotected

◆ buildConvexHull()

void conscience_core::simulator::CscPhysicsSimulator::buildConvexHull ( CscWorldElement object)
staticprotected

◆ clearAllForces()

void conscience_core::simulator::CscPhysicsSimulator::clearAllForces ( const CscWorldElementId entityId)
protected

◆ clearObjects()

void conscience_core::simulator::CscPhysicsSimulator::clearObjects ( )

◆ clearPlaces()

void conscience_core::simulator::CscPhysicsSimulator::clearPlaces ( )

◆ definePhysicsModelingType()

CscMemberPhysicsModelingType conscience_core::simulator::CscPhysicsSimulator::definePhysicsModelingType ( const CscMember member)
staticprotected

◆ disableMembersCollisions()

void conscience_core::simulator::CscPhysicsSimulator::disableMembersCollisions ( const CscWorldElementId entityId)

◆ dividingAllStatesOfOneSequenceIntoSubStates()

CscSequence * conscience_core::simulator::CscPhysicsSimulator::dividingAllStatesOfOneSequenceIntoSubStates ( CscSequence sequenceToDivide,
CscState initialState,
const map< int, CscPivotMovementType > &  pivotMovementByPivotId 
)

Divides all states in a given sequence into sub-states.

This function takes a sequence of states and for each state, divides it into multiple sub-states using the dividingOneStateIntoSubStates method. This is done for each state in the sequence, using a specified initial state and the physics state of a specific entity.

The function also calculates the duration of each sub-state by dividing the total duration of each state by the number of sub-states created for that state. The resulting sequence includes all the generated sub-states, each associated with its calculated duration.

Parameters
sequenceToDividePointer to the sequence whose states are to be divided into sub-states.
initialStatePointer to the initial state to use when dividing the first state in the sequence.
pivotMovementByPivotIdMap wich associating each pivot to a type of movement.
Returns
A pointer to the new sequence containing all the generated sub-states.

Note: This function allocates new memory for the sequence and the sub-states, so it is the caller's responsibility to manage the allocated memory.

◆ dividingOneStateIntoSubStates()

vector< CscState * > conscience_core::simulator::CscPhysicsSimulator::dividingOneStateIntoSubStates ( CscState stateToDivide,
CscState currentState,
int  durationStateToDivide,
int  nbStateToDivide,
float  durationLastSubStep,
const map< int, CscPivotMovementType > &  pivotMovementByPivotId 
)

Divides a given state into multiple sub-states based on the specified duration and number of states to divide.

This method generates a series of intermediate states between the current state and the target state. Each intermediate state corresponds to a sub-duration of the total transition duration. The method considers the type of movement (either Constant or Sinusoidal) of each pivot in the physics state of a specified entity.

If the movement type is Constant, the target value of the pivot for a sub-state is linearly interpolated between the current value and the target value.

If the movement type is Sinusoidal, the target value of the pivot for a sub-state is calculated as a sinusoidal function of time, with the amplitude equal to half of the total angle change and the offset equal to the average of the current and target values.

Parameters
stateToDivideThe target state to divide into sub-states.
currentStateThe current state from which to start the division.
durationStateToDivideThe total duration of the transition from the current state to the target state.
nbStateToDivideThe number of sub-states into which to divide the target state.
durationLastSubStepThe duration of the last subStep.
pivotMovementByPivotIdMap wich associating each pivot to a type of movement.
Returns
A vector of pointers to the sub-states generated by the division.

◆ enableMembersCollisions()

void conscience_core::simulator::CscPhysicsSimulator::enableMembersCollisions ( const CscWorldElementId entityId)

◆ entityTeleport()

void conscience_core::simulator::CscPhysicsSimulator::entityTeleport ( const CscWorldElementId entityId,
const CscPoint3dOriented target 
)

Teleports an entity to given position and orientation

◆ fillStateInputs()

CscState * conscience_core::simulator::CscPhysicsSimulator::fillStateInputs ( const CscWorldElementId entityId,
const CscState incompleteState 
)

Warning: this forces given state into current simulator, and returns a NEW state with inputs filled

◆ findCenterOfMass()

CscPoint3d * conscience_core::simulator::CscPhysicsSimulator::findCenterOfMass ( const CscEntityModel entityModel,
map< int, CscPoint3d * >  centerOfMassOfAllMemberByMemberId 
)

Computes the center of mass for a given entity model using member mass centers.

This function calculates the center of mass for an entity model. It iterates through the provided map of member IDs and their corresponding mass centers, computes a weighted sum of member mass centers based on the mass of each member, and finally divides by the total mass to determine the center of mass for the entire entity.

Parameters
entityModelPointer to the entity model that contains the mass data of each member.
centerOfMassOfAllMemberByMemberIdA map of member IDs to their respective mass center positions (as CscPoint3d pointers).
Returns
CscPoint3d* Pointer to the computed center of mass of the entity.
Note
The function assumes that each member's mass center is provided in the map and that the entity model correctly specifies the mass for every member.

◆ fireStatePlayed()

void conscience_core::simulator::CscPhysicsSimulator::fireStatePlayed ( const CscWorldElementId entityId,
const CscState state,
int  duration = 0,
int  delay = 0,
bool  relativeValues = false 
)
protected

◆ focusVisionIntoPosition()

void conscience_core::simulator::CscPhysicsSimulator::focusVisionIntoPosition ( float  posX,
float  posY,
float  posZ 
)

◆ forceMemberValuesAndVerifyState()

void conscience_core::simulator::CscPhysicsSimulator::forceMemberValuesAndVerifyState ( const CscWorldElementId entityId,
const CscMemberInputStatus inputsValues,
const bool  applyPosition[3],
const bool  applyEuler[3],
const bool  applyAcceleration[3],
optional< int >  nbMaxIteration = {},
optional< int >  maxLoopDurationMillis = {},
const CscState verifyState = nullptr 
)
Parameters
nbMaxIterationmaximum number of iteration for main loop which can take a long time before convergence
maxLoopDurationMillismaximum duration for main loop which can take a long time before convergence

◆ forceState()

void conscience_core::simulator::CscPhysicsSimulator::forceState ( const CscWorldElementId entityId,
const CscState appliedState,
int  memberIdForInputs,
const bool  applyPos[3],
const bool  applyRot[3],
const bool  applyAcc[3],
optional< int >  nbMaxIteration = {},
optional< int >  maxLoopDurationMillis = {},
bool  callPlayStateListener = false 
)
Parameters
nbMaxIterationmaximum number of iteration for forceMemberValuesAndVerifyState loop which can take a long time before convergence
maxLoopDurationMillismaximum duration for forceMemberValuesAndVerifyState loop which can take a long time before convergence

◆ getCenterOfMassOfAllMemberByMemberId()

map< int, CscPoint3d * > conscience_core::simulator::CscPhysicsSimulator::getCenterOfMassOfAllMemberByMemberId ( const CscWorldElementId entityId)

◆ getCurrentInputs()

vector< const CscMemberInputStatus * > * conscience_core::simulator::CscPhysicsSimulator::getCurrentInputs ( const CscWorldElementId entityId)

◆ getCurrentJoints()

map<int, float> conscience_core::simulator::CscPhysicsSimulator::getCurrentJoints ( )
protected

◆ getCurrentPropellers()

map<int, float> conscience_core::simulator::CscPhysicsSimulator::getCurrentPropellers ( )
protected

◆ getCurrentState()

CscState * conscience_core::simulator::CscPhysicsSimulator::getCurrentState ( const CscWorldElementId entityId)
virtual

return requested entity's current state WARNING: a NEW state is returned, which means pointer needs to be deleted after usage

◆ getCurrentTranslations()

map<int, float> conscience_core::simulator::CscPhysicsSimulator::getCurrentTranslations ( )
protected

◆ getCurrentWheels()

map<int, float> conscience_core::simulator::CscPhysicsSimulator::getCurrentWheels ( )
protected

◆ getEnvObjectShapesVertex()

vector< CscPoint3d * > * conscience_core::simulator::CscPhysicsSimulator::getEnvObjectShapesVertex ( CscWorldElementId  objectId)

◆ getEnvObjectShapesVertexCount()

int conscience_core::simulator::CscPhysicsSimulator::getEnvObjectShapesVertexCount ( CscWorldElementId  objectId)

◆ getFocusBarPoint()

CscPoint3dOriented * conscience_core::simulator::CscPhysicsSimulator::getFocusBarPoint ( )

◆ getFocusSpherePoint()

CscPoint3dOriented * conscience_core::simulator::CscPhysicsSimulator::getFocusSpherePoint ( )

◆ getJointHingeAngle()

float conscience_core::simulator::CscPhysicsSimulator::getJointHingeAngle ( const CscWorldElementId entityId,
int  jointIdIn 
) const

◆ getMemberState()

const CscPhysicsSimulator::MemberState * conscience_core::simulator::CscPhysicsSimulator::getMemberState ( const CscWorldElementId entityId,
const CscMember member 
) const

◆ getMemberStateById()

const CscPhysicsSimulator::MemberState * conscience_core::simulator::CscPhysicsSimulator::getMemberStateById ( const CscWorldElementId entityId,
int  id 
) const

◆ getMemberStateByName()

const CscPhysicsSimulator::MemberState * conscience_core::simulator::CscPhysicsSimulator::getMemberStateByName ( const CscWorldElementId entityId,
const string &  memberName 
) const

◆ getObjectByIndex()

const CscWorldObject* conscience_core::simulator::CscPhysicsSimulator::getObjectByIndex ( int  index) const
inline

◆ getPivotLimitMax()

float conscience_core::simulator::CscPhysicsSimulator::getPivotLimitMax ( const CscWorldElementId entityId,
int  pivotId 
) const

◆ getPivotLimitMin()

float conscience_core::simulator::CscPhysicsSimulator::getPivotLimitMin ( const CscWorldElementId entityId,
int  pivotId 
) const

◆ getPivotOtherMember()

string conscience_core::simulator::CscPhysicsSimulator::getPivotOtherMember ( const CscWorldElementId entityId,
const string &  memberName 
)

Return other member name attached by a pivot to member having name in parameter

◆ getPivotState()

const CscPhysicsSimulator::PivotPhysicsState * conscience_core::simulator::CscPhysicsSimulator::getPivotState ( const CscWorldElementId entityId,
int  id 
) const

◆ getPropellerState()

const CscPhysicsSimulator::PropellerPhysicsState * conscience_core::simulator::CscPhysicsSimulator::getPropellerState ( const CscWorldElementId entityId,
int  id 
) const

◆ getTranslationState()

const CscPhysicsSimulator::TranslationPhysicsState * conscience_core::simulator::CscPhysicsSimulator::getTranslationState ( const CscWorldElementId entityId,
int  id 
) const

◆ getWheelState()

const CscPhysicsSimulator::WheelPhysicsState * conscience_core::simulator::CscPhysicsSimulator::getWheelState ( const CscWorldElementId entityId,
int  id 
) const

◆ hadEntityReachedState()

bool conscience_core::simulator::CscPhysicsSimulator::hadEntityReachedState ( const CscWorldElementId entityId,
const CscState objectiveState,
float  epsilon 
)

◆ importEntity()

void conscience_core::simulator::CscPhysicsSimulator::importEntity ( const CscWorldEntity entity,
const CscPoint3dOriented customPositionAndOrientation = nullptr,
bool  requiresExternalInit = false 
)

◆ importObjectIntoPhysicsSimulator()

void conscience_core::simulator::CscPhysicsSimulator::importObjectIntoPhysicsSimulator ( CscWorldObject object)

◆ importObjectsIntoPhysicsSimulator()

void conscience_core::simulator::CscPhysicsSimulator::importObjectsIntoPhysicsSimulator ( vector< CscWorldObject * > *  objects)

◆ importPlaceIntoPhysicsSimulator()

void conscience_core::simulator::CscPhysicsSimulator::importPlaceIntoPhysicsSimulator ( CscWorldPlace place)

◆ initFloor()

void conscience_core::simulator::CscPhysicsSimulator::initFloor ( )

◆ isEntityPhysicsStateLoaded()

bool conscience_core::simulator::CscPhysicsSimulator::isEntityPhysicsStateLoaded ( const CscWorldElementId entityId)

entity physics state and ready when it received its first refresh from physics simulator

◆ isEntityPhysicsStateReady()

bool conscience_core::simulator::CscPhysicsSimulator::isEntityPhysicsStateReady ( const CscWorldElementId entityId)

entity physics state and ready when it received its first refresh from physics simulator AND fully initialized (please see CscEntityReflexionParameters physicsRequiresAdditionalInit param)

◆ localCreateElasticBody()

btRigidBody * conscience_core::simulator::CscPhysicsSimulator::localCreateElasticBody ( btScalar  mass,
const btTransform &  startTransform,
btCollisionShape *  shape 
)
protected

◆ localCreateRigidBody()

btRigidBody * conscience_core::simulator::CscPhysicsSimulator::localCreateRigidBody ( btScalar  mass,
const btTransform &  startTransform,
btCollisionShape *  shape 
)
protected

◆ memberApplyAcceleration()

void conscience_core::simulator::CscPhysicsSimulator::memberApplyAcceleration ( const CscWorldElementId entityId,
int  bodyIndex,
float  accX,
float  accY,
float  accZ 
)
protected

◆ memberTeleportToOrigin()

void conscience_core::simulator::CscPhysicsSimulator::memberTeleportToOrigin ( const CscWorldElementId entityId,
int  bodyIndex,
float  posX,
float  posY,
float  posZ 
)

◆ memberTeleportToPositionAndAngle()

void conscience_core::simulator::CscPhysicsSimulator::memberTeleportToPositionAndAngle ( const CscWorldElementId entityId,
int  memberId,
const CscPoint3dOriented target,
bool  resetOutputsToInitialVals = false,
optional< int >  nbMaxIteration = {},
optional< int >  maxLoopDurationMillis = {},
bool  callPlayStateListener = false 
)
Parameters
nbMaxIterationmaximum number of iteration for forceMemberValuesAndVerifyState loop which can take a long time before convergence
maxLoopDurationMillismaximum duration for forceMemberValuesAndVerifyState loop which can take a long time before convergence

◆ memberTeleportToRotation()

void conscience_core::simulator::CscPhysicsSimulator::memberTeleportToRotation ( const CscWorldElementId entityId,
int  bodyIndex,
float  yaw,
float  pitch,
float  roll 
)

◆ moveMember()

void conscience_core::simulator::CscPhysicsSimulator::moveMember ( const CscWorldElementId entityId,
float *  vals,
int  bodyIndex,
int  isTranslate 
)

◆ moveMemberToStateFromMember()

int conscience_core::simulator::CscPhysicsSimulator::moveMemberToStateFromMember ( const CscWorldElementId entityId,
const CscMemberInputStatus inputsValues,
const bool  applyPosition[3],
const bool  applyEuler[3],
const bool  applyAcceleration[3],
optional< int >  nbMaxIteration = {},
optional< int >  maxLoopDurationMillis = {},
int  tryNumber = 0 
)
Returns
number of iteration needed to reach the state

◆ moveObjectToPosition()

void conscience_core::simulator::CscPhysicsSimulator::moveObjectToPosition ( CscWorldElement object,
const CscPoint3d targetPosition 
)

◆ moveObjectToPositionAndRotation()

void conscience_core::simulator::CscPhysicsSimulator::moveObjectToPositionAndRotation ( CscWorldElement object,
const CscPoint3d targetPosition,
const CscPoint3d targetRotation 
)

◆ moveObjectToRotation()

void conscience_core::simulator::CscPhysicsSimulator::moveObjectToRotation ( CscWorldElement object,
const CscPoint3d targetRotation 
)

◆ performRayScale()

vector< CscPoint3d * > conscience_core::simulator::CscPhysicsSimulator::performRayScale ( const CscPoint3d position,
const vector< const CscPoint3d * > &  rayEnds,
optional< int >  collisionFilterGroup = {COL_ENV_PLACE | COL_FLOOR | COL_ROBOT_MEMBERS | COL_ENV_OBJ},
optional< int >  collisionFilterMask = {COL_ENV_PLACE | COL_FLOOR | COL_ENV_OBJ} 
)

◆ playSequence()

void conscience_core::simulator::CscPhysicsSimulator::playSequence ( const CscWorldElementId entityId,
CscState init,
CscSequence sequence,
const map< int, CscPivotMovementType > &  pivotMovementByPivotId,
bool  geneticAi = false,
bool  extrapolationRealTime = false 
)
Parameters
isGeneticAiis use to know if method is called by a genetic algorityhm, in this case, we need to perform some "stepSimulationFutureVision" to make sure that we can't have residual forces on entity
extrapolationRealTimeis use to play a sequence with its extrapolation in real time instead futureVision
Note
SEQUENCE IS NOT DELETED TO THE END OF METHOD, REMEMBER TO DELETE IT WHEN NECESSARY

◆ playState()

void conscience_core::simulator::CscPhysicsSimulator::playState ( const CscWorldElementId entityId,
CscState state,
int  duration = 0,
int  delay = 0,
bool  relativeValues = false 
)

Plays an entity's state in this simulator. This is the normal way of requesting a state for an entity. This will set state fully, and call listener

◆ removeAndDeleteBody()

void conscience_core::simulator::CscPhysicsSimulator::removeAndDeleteBody ( btRigidBody *  body)
protected

◆ removeConscienceMemberFrontFocus()

void conscience_core::simulator::CscPhysicsSimulator::removeConscienceMemberFrontFocus ( )

◆ removeEntity()

void conscience_core::simulator::CscPhysicsSimulator::removeEntity ( const CscWorldElementId entityId)

◆ removeFloor()

void conscience_core::simulator::CscPhysicsSimulator::removeFloor ( )

◆ removeObjectById()

void conscience_core::simulator::CscPhysicsSimulator::removeObjectById ( CscWorldElementId  objectId)

◆ removeObjectByIndex()

void conscience_core::simulator::CscPhysicsSimulator::removeObjectByIndex ( int  index)
protected

◆ removeObjectByName()

void conscience_core::simulator::CscPhysicsSimulator::removeObjectByName ( string  name)

◆ removePlaceById()

void conscience_core::simulator::CscPhysicsSimulator::removePlaceById ( string  placeId)

◆ sameEuler()

bool conscience_core::simulator::CscPhysicsSimulator::sameEuler ( float  yaw1,
float  pitch1,
float  roll1,
float  yaw2,
float  pitch2,
float  roll2,
float  epsilon 
)
protected

◆ samePosition()

bool conscience_core::simulator::CscPhysicsSimulator::samePosition ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2,
float  epsilon 
)
protected

◆ setAllPivotsMotorDisabled()

void conscience_core::simulator::CscPhysicsSimulator::setAllPivotsMotorDisabled ( const CscWorldElementId entityId,
bool  enabled 
)

◆ setAllPivotsToRelaxedMode()

void conscience_core::simulator::CscPhysicsSimulator::setAllPivotsToRelaxedMode ( const CscWorldElementId entityId)

◆ setEntityGravity()

void conscience_core::simulator::CscPhysicsSimulator::setEntityGravity ( const CscWorldElementId entityId,
float  xIn,
float  yIn,
float  zIn 
)

◆ setEntityPhysicsInitDone()

void conscience_core::simulator::CscPhysicsSimulator::setEntityPhysicsInitDone ( const CscWorldElementId entityId)

◆ setFloorFriction()

void conscience_core::simulator::CscPhysicsSimulator::setFloorFriction ( float  val)

◆ setFloorRotation()

void conscience_core::simulator::CscPhysicsSimulator::setFloorRotation ( float  yaw,
float  pitch,
float  roll 
)

◆ setGravity()

void conscience_core::simulator::CscPhysicsSimulator::setGravity ( float  xIn,
float  yIn,
float  zIn 
)

◆ setMemberKinematicMode()

void conscience_core::simulator::CscPhysicsSimulator::setMemberKinematicMode ( const CscWorldElementId entityId,
int  memberId,
bool  kinematicMode 
)
protected

◆ setOnStatePlayedListener()

void conscience_core::simulator::CscPhysicsSimulator::setOnStatePlayedListener ( PlayStateListener  onStatePlayedListener)
inline

◆ setSimulatorSpeed()

void conscience_core::simulator::CscPhysicsSimulator::setSimulatorSpeed ( float  speed)
inline

◆ setState()

void conscience_core::simulator::CscPhysicsSimulator::setState ( const CscWorldElementId entityId,
CscState state,
bool  relativeValues = false,
int  duration = 200 
)

Forces entity's state in this simulator. No listener will be called

◆ stepSimulationFutureVision()

void conscience_core::simulator::CscPhysicsSimulator::stepSimulationFutureVision ( int  millisecondsFromNow,
int  nbSubSteps = 55 
)

◆ stepSimulationRealTime()

void conscience_core::simulator::CscPhysicsSimulator::stepSimulationRealTime ( )

◆ toDebugLogMemberInputs()

string conscience_core::simulator::CscPhysicsSimulator::toDebugLogMemberInputs ( const CscWorldElementId entityId,
int  memberIndex 
)
inlineprotected

◆ unitUpdatePivots()

void conscience_core::simulator::CscPhysicsSimulator::unitUpdatePivots ( )

◆ unitUpdateTranslations()

void conscience_core::simulator::CscPhysicsSimulator::unitUpdateTranslations ( )

◆ updateBehaviorMode()

void conscience_core::simulator::CscPhysicsSimulator::updateBehaviorMode ( const CscWorldElementId entityId,
int  modeId,
int  memberId 
)

◆ updateMemberEulers()

void conscience_core::simulator::CscPhysicsSimulator::updateMemberEulers ( const CscWorldElementId entityId,
int  memberId,
double  eulerX,
double  eulerY,
double  eulerZ 
)

◆ updateMemberPhysics()

void conscience_core::simulator::CscPhysicsSimulator::updateMemberPhysics ( const CscWorldElementId entityId,
int  itemId,
float  mass,
float  friction,
float  restitution,
float  linearDamping,
float  angularDamping 
)

◆ updateMemberPosition()

void conscience_core::simulator::CscPhysicsSimulator::updateMemberPosition ( const CscWorldElementId entityId,
int  memberId,
float  posX,
float  posY,
float  posZ 
)

◆ updatePivot()

void conscience_core::simulator::CscPhysicsSimulator::updatePivot ( const CscWorldElementId entityId,
int  pivotId,
float  newValPercent,
bool  relativeValues = false 
)

◆ updatePivotPhysics()

void conscience_core::simulator::CscPhysicsSimulator::updatePivotPhysics ( const CscWorldElementId entityId,
int  id,
float  min,
float  max,
float  softness,
float  bias,
float  relaxation,
float  speedMax,
float  percentSpeedMax 
)

◆ updatePivotSpeedMax()

void conscience_core::simulator::CscPhysicsSimulator::updatePivotSpeedMax ( const CscWorldElementId entityId,
int  id,
float  speedMax 
)

◆ updatePropeller()

void conscience_core::simulator::CscPhysicsSimulator::updatePropeller ( const CscWorldElementId entityId,
int  propellerId,
float  val,
float  cst = 1000.0 
)

◆ updatePropellerPhysics()

void conscience_core::simulator::CscPhysicsSimulator::updatePropellerPhysics ( const CscWorldElementId entityId,
int  id,
float  speedMax 
)

◆ updateTranslation()

void conscience_core::simulator::CscPhysicsSimulator::updateTranslation ( const CscWorldElementId entityId,
int  translationId,
float  val,
bool  relativeValues = false 
)

◆ updateTranslationPhysics()

void conscience_core::simulator::CscPhysicsSimulator::updateTranslationPhysics ( const CscWorldElementId entityId,
int  translationId,
float  newMaxSpped 
)

◆ updateWheel()

void conscience_core::simulator::CscPhysicsSimulator::updateWheel ( const CscWorldElementId entityId,
int  wheelId,
float  val,
float  cst = 1000.0,
float  speedCoef = 1.0 
)

◆ updateWheelMaxSpeed()

void conscience_core::simulator::CscPhysicsSimulator::updateWheelMaxSpeed ( const CscWorldElementId entityId,
int  wheelId,
float  newSpeedMax 
)

◆ updateWheels()

void conscience_core::simulator::CscPhysicsSimulator::updateWheels ( const CscWorldElementId entityId,
float  val 
)

Member Data Documentation

◆ clock

btClock conscience_core::simulator::CscPhysicsSimulator::clock

◆ curTimeInMicroseconds

long conscience_core::simulator::CscPhysicsSimulator::curTimeInMicroseconds

◆ entities

map<CscWorldElementId, CscEntityPhysicsState *> conscience_core::simulator::CscPhysicsSimulator::entities
protected

◆ environmentObjects

vector<CscWorldObject *> conscience_core::simulator::CscPhysicsSimulator::environmentObjects
protected

◆ fixedTimeStep

const float conscience_core::simulator::CscPhysicsSimulator::fixedTimeStep = 1.0 / 100.0

◆ floorBody

btRigidBody* conscience_core::simulator::CscPhysicsSimulator::floorBody = nullptr
protected

◆ floorHeight

float conscience_core::simulator::CscPhysicsSimulator::floorHeight = 25.4
protected

◆ floorLength

float conscience_core::simulator::CscPhysicsSimulator::floorLength = 6000.0
protected

◆ floorWidth

float conscience_core::simulator::CscPhysicsSimulator::floorWidth = 6000.0
protected

◆ focusBarBody

btRigidBody* conscience_core::simulator::CscPhysicsSimulator::focusBarBody = nullptr
protected

◆ focusSphereBody

btRigidBody* conscience_core::simulator::CscPhysicsSimulator::focusSphereBody = nullptr
protected

◆ globalGravity

float conscience_core::simulator::CscPhysicsSimulator::globalGravity = -9.81
protected

◆ id

const unsigned long long conscience_core::simulator::CscPhysicsSimulator::id

◆ integratedPhysicsThread

bool conscience_core::simulator::CscPhysicsSimulator::integratedPhysicsThread

◆ logger

std::unique_ptr<CscLogger> conscience_core::simulator::CscPhysicsSimulator::logger
protected

◆ m_broadphase

btBroadphaseInterface* conscience_core::simulator::CscPhysicsSimulator::m_broadphase
protected

◆ m_collisionConfiguration

btDefaultCollisionConfiguration* conscience_core::simulator::CscPhysicsSimulator::m_collisionConfiguration
protected

◆ m_dispatcher

btCollisionDispatcher* conscience_core::simulator::CscPhysicsSimulator::m_dispatcher
protected

◆ m_dynamicsWorld

btDiscreteDynamicsWorld* conscience_core::simulator::CscPhysicsSimulator::m_dynamicsWorld = nullptr

◆ m_solver

btSequentialImpulseConstraintSolver* conscience_core::simulator::CscPhysicsSimulator::m_solver
protected

◆ minFPS

const float conscience_core::simulator::CscPhysicsSimulator::minFPS = 16.6666666666f

◆ onStatePlayedListener

optional<PlayStateListener> conscience_core::simulator::CscPhysicsSimulator::onStatePlayedListener = {}
protected

◆ otherBodies

map<CscWorldElementId, btRigidBody *> conscience_core::simulator::CscPhysicsSimulator::otherBodies
protected

◆ otherShapes

map<CscWorldElementId, btCollisionShape *> conscience_core::simulator::CscPhysicsSimulator::otherShapes
protected

◆ placeBodies

map<CscWorldElementId, btRigidBody *> conscience_core::simulator::CscPhysicsSimulator::placeBodies
protected

◆ precisionAction

int conscience_core::simulator::CscPhysicsSimulator::precisionAction

◆ precisionGyro

float conscience_core::simulator::CscPhysicsSimulator::precisionGyro

◆ prevTimeInMicroseconds

long conscience_core::simulator::CscPhysicsSimulator::prevTimeInMicroseconds

◆ simulatorMutex

recursive_mutex conscience_core::simulator::CscPhysicsSimulator::simulatorMutex
protected

◆ simulatorPhysicsThread

thread* conscience_core::simulator::CscPhysicsSimulator::simulatorPhysicsThread = nullptr
protected

◆ simulatorPhysicsThreadRunning

bool conscience_core::simulator::CscPhysicsSimulator::simulatorPhysicsThreadRunning = false
protected

◆ simulatorPhysicsThreadStopped

bool conscience_core::simulator::CscPhysicsSimulator::simulatorPhysicsThreadStopped = true
protected

◆ simulatorSpeed

float conscience_core::simulator::CscPhysicsSimulator::simulatorSpeed

◆ speedFactor

float conscience_core::simulator::CscPhysicsSimulator::speedFactor = 1.0
protected

◆ visionCnt1

btFixedConstraint* conscience_core::simulator::CscPhysicsSimulator::visionCnt1 = NULL

◆ visionCnt2

btHingeConstraint* conscience_core::simulator::CscPhysicsSimulator::visionCnt2 = NULL

The documentation for this class was generated from the following files: