RobWorkProject
24.12.4-
|
Wraps a simulator in a thread safe interface, and creates a separate thread for the simulator to run in. More...
#include <ThreadSimulator.hpp>
Public Types | |
typedef rw::core::Ptr< ThreadSimulator > | Ptr |
smart pointer type | |
typedef boost::function< void(ThreadSimulator *sim, rw::kinematics::State &)> | StepCallback |
The callback type for a hook into the step call. | |
Public Member Functions | |
ThreadSimulator (rwlibs::simulation::Simulator::Ptr simulator) | |
constructor - using the default workcell state as starting state | |
ThreadSimulator (rwlibs::simulation::Simulator::Ptr simulator, const rw::kinematics::State &state) | |
constructor | |
virtual | ~ThreadSimulator () |
destructor | |
void | setRealTimeScale (double scale) |
This can be used to scale simulation time relative to Real World time. A scale of 1.0 makes the simulation run real time (if possible). A scale of 0.5 makes the simulation run twice as fast as real time, where a scale of 2 makes the simulation twice as slow. More... | |
void | setTimeStep (double dt) |
sets the timestep that will be used for the calls to the step function of the simulator More... | |
void | start () |
starts the simulator constraining it too the specified period | |
void | stop () |
tries to stop the simulation and blocks until the thread is stopped | |
void | postStop () |
same as stop but this version is non-blocking. | |
void | step () |
step the simulation one timestep | |
rw::kinematics::State | getState () |
get the current state of the simuation More... | |
void | setState (const rw::kinematics::State &state) |
set the state of the simulator More... | |
void | reset (const rw::kinematics::State &state) |
reset the simulator to this state. The difference from the setState is that any changes to the non state-states such as the transform of the fixed frame, will also be updated. More... | |
bool | isRunning () |
test if this thread simulator is running | |
double | getTime () |
get the current simulator time in seconds | |
DynamicSimulator::Ptr | getSimulator () |
gets a pointer to the simulator. Make sure to stop the simulation before calling this function, otherwise an exception will be thrown. More... | |
void | setStepCallBack (StepCallback cb) |
if set this callback function will be called once on start and then after each step of the simulator. More... | |
bool | isInError () |
the simulator might fail because of too large penetrations. This method tests if the simulator is in an error. | |
void | setInError (bool inError) |
this can be used to force the resetting of an error state. More... | |
Public Attributes | |
boost::mutex | _simMutex |
boost::mutex | _stateMutex |
Wraps a simulator in a thread safe interface, and creates a separate thread for the simulator to run in.
|
inline |
gets a pointer to the simulator. Make sure to stop the simulation before calling this function, otherwise an exception will be thrown.
rw::kinematics::State getState | ( | ) |
get the current state of the simuation
void reset | ( | const rw::kinematics::State & | state | ) |
reset the simulator to this state. The difference from the setState is that any changes to the non state-states such as the transform of the fixed frame, will also be updated.
state | [in] the new state |
|
inline |
this can be used to force the resetting of an error state.
inError |
|
inline |
This can be used to scale simulation time relative to Real World time. A scale of 1.0 makes the simulation run real time (if possible). A scale of 0.5 makes the simulation run twice as fast as real time, where a scale of 2 makes the simulation twice as slow.
1 simTime -> max( realtime * scale , simDelayInRealTime )
scale | [in] |
void setState | ( | const rw::kinematics::State & | state | ) |
set the state of the simulator
state | [in] the new state |
|
inline |
if set this callback function will be called once on start and then after each step of the simulator.
Set to NULL if no callback is wanted
void setTimeStep | ( | double | dt | ) |
sets the timestep that will be used for the calls to the step function of the simulator
dt |