7 #include "RbMovableItem.h"
10 #include "RbMotorizedJoint.h"
11 #include "RbRigidBody.h"
12 #include "RbClassFactory.h"
13 #include "RbSimulator.h"
23 RbSimulator::RbSimulator()
29 m_dblTotalVortexStepTime = 0;
30 m_lStepVortexTimeCount = 0;
36 RbSimulator::~RbSimulator()
46 {
Std_TraceMsg(0,
"Caught Error in desctructor of Simulator\r\n",
"", -1,
false,
true);}
49 #pragma region AccessorMutatorOverrides
71 Simulator::ResetSimulation();
76 void RbSimulator::SetSimulationStabilityParams()
82 unsigned long long RbSimulator::GetTimerTick()
88 double RbSimulator::TimerDiff_n(
unsigned long long lStart,
unsigned long long lEnd)
89 {
return osg::Timer::instance()->delta_n(lStart, lEnd);}
91 double RbSimulator::TimerDiff_u(
unsigned long long lStart,
unsigned long long lEnd)
92 {
return osg::Timer::instance()->delta_u(lStart, lEnd);}
94 double RbSimulator::TimerDiff_m(
unsigned long long lStart,
unsigned long long lEnd)
95 {
return osg::Timer::instance()->delta_m(lStart, lEnd);}
97 double RbSimulator::TimerDiff_s(
unsigned long long lStart,
unsigned long long lEnd)
98 {
return osg::Timer::instance()->delta_s(lStart, lEnd);}
100 void RbSimulator::MicroSleep(
unsigned int iMicroTime)
101 {OpenThreads::Thread::microSleep(iMicroTime);}
103 void RbSimulator::WriteToConsole(std::string strMessage)
105 std::cout << strMessage <<
"\r\n";
110 void RbSimulator::InitializeRobotics(
int argc,
const char **argv)
142 InitializeRobotics(argc, argv);
163 Simulator::StepSimulation();
165 unsigned long long lStart = GetTimerTick();
178 double dblVal = TimerDiff_s(lStart, GetTimerTick());
183 m_dblTotalVortexStepTime += dblVal;
184 m_lStepVortexTimeCount++;
188 double dblAvgStepTime = m_dblTotalVortexStepTime/m_lStepVortexTimeCount;
199 catch(CStdErrorInfo oError)
201 std::string strError =
"An error occurred while step the simulation.\nError: " + oError.m_strError;
202 HandleNonCriticalError(strError);
bool m_bPaused
true if the simulation is paused.
float m_fltPhysicsStepTime
This is the time pers step for the physics engine.
ExternalStimuliMgr m_oExternalStimuliMgr
Manager for external stimuli.
virtual void ResetSimulation()
Resets the the simulation to its orginal settings at time 0.
virtual void ShutdownSimulation()
Shuts down the simulation.
virtual AnimatSim::Recording::SimulationRecorder * CreateSimulationRecorder()
Creates the simulation recorder.
virtual void StepSimulation()
Steps the entire simulation forward by one physics integration time step.
virtual void SimulateEnd()
Called at the end of the Simulate method.
virtual void InitializeStructures()
Initializes all of the structures of this simulation.
bool m_bShuttingDown
True if the simulation is shutting down. This is used by other objects in their destructor to know wh...
bool m_bForceSimulationStop
Set to true to stop the simulation. This is a more forceful way of stopping the sim.
long m_lTimeSlice
The current time slice. This a long value.
virtual bool PauseSimulation()
Pauses the simulation.
virtual void ToggleSimulation()
Toggles the simulation between running and paused.
bool m_bSimRunning
true if the simulation is running
unsigned long long m_lLastTickTaken
This is the last tick taken by a GetTickCount. It is used in debugging.
DataChartMgr m_oDataChartMgr
Manager for data charts.
SimulationRecorder * m_lpSimRecorder
The pointer to a simulation recorder.
virtual bool InSimulation()
Used to determine if we are running in a simulation, or in a real control mode.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
long m_lStepTimeCount
This is a temp variable for measuring sim time for a set period for each simulation.
unsigned long long m_lStartSimTick
The tick count for when the simulation first begins running.
virtual void Initialize()
Initializes this object with no argc/argv params.
virtual void SimPausing()
Simulation pausing event.
double m_dblTotalStepTime
This is a temp variable for measuring sim time for a set period for each simulation.
virtual void StopSimulation()
Stops the simulation and resets it.
virtual void SimStopping()
Simulation stopping event.
virtual bool StartSimulation()
Starts the simulation.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
virtual void SimStarting()
Simulation starting event.
virtual void Reset()
Resets all objects of the simulation to their unloaded state.
IStdClassFactory * m_lpAnimatClassFactory