![]() |
An open-source, flexible 3D physical simulation framework
|
The Simulator class implements the main functions of the MARS simulation. More...
#include <Simulator.h>
Classes | |
struct | LoadOptions |
Public Types | |
enum | Status { UNKNOWN = -1, STOPPED = 0, RUNNING = 1, STOPPING = 2, STEPPING =3 } |
Public Member Functions | |
Simulator (lib_manager::LibManager *theManager) | |
Constructor of the class Simulator. More... | |
virtual | ~Simulator () |
int | getLibVersion () const |
const std::string | getLibName () const |
void | newLibLoaded (const std::string &libName) |
CREATE_MODULE_INFO () | |
void | checkOptionalDependency (const std::string &libName) |
void | updateSim () |
Updates the graphical simulation. More... | |
void | myRealTime (void) |
control the realtime calculation More... | |
void | runSimulation (bool startThread=true) |
Initiates the simulation. More... | |
std::string | getTmpPath () const |
Returns the tmp path for temprary files, on linux /tmp/mars on windows the current config_dir. More... | |
virtual void | StartSimulation () |
virtual void | StopSimulation () |
virtual void | resetSim (bool resetGraphics=true) |
virtual bool | isSimRunning () const |
bool | startStopTrigger () |
Starts and pauses the simulation. More... | |
virtual void | singleStep (void) |
virtual void | newWorld (bool clear_all=false) |
virtual void | exitMars (void) |
void | readArguments (int argc, char **argv) |
virtual interfaces::ControlCenter * | getControlCenter (void) const |
void | addLight (interfaces::LightData light) |
virtual void | connectNodes (unsigned long id1, unsigned long id2) |
virtual void | disconnectNodes (unsigned long id1, unsigned long id2) |
virtual void | rescaleEnvironment (interfaces::sReal x, interfaces::sReal y, interfaces::sReal z) |
virtual int | loadScene (const std::string &filename, const std::string &robotname, bool threadsave=false, bool blocking=false) |
virtual int | loadScene (const std::string &filename, bool wasrunning=false, const std::string &robotname="", bool threadsave=false, bool blocking=false) |
virtual int | saveScene (const std::string &filename, bool wasrunning) |
virtual void | exportScene () const |
Exports the current scene as both *.obj and *.osg file. More... | |
virtual bool | sceneChanged () const |
virtual void | sceneHasChanged (bool reset) |
virtual bool | allConcurrencysHandled () |
Checks if external requests are open. More... | |
void | setSyncThreads (bool value) |
Syncs the threads of GUI and simulation. More... | |
virtual void | physicsThreadLock (void) |
virtual void | physicsThreadUnlock (void) |
virtual interfaces::PhysicsInterface * | getPhysics (void) const |
virtual void | handleError (interfaces::PhysicsError error) |
virtual void | setGravity (const utils::Vector &gravity) |
virtual int | checkCollisions (void) |
virtual bool | hasSimFault () const |
Checks if the physic simulation thread has been stopped caused by an ODE error. More... | |
virtual void | postGraphicsUpdate (void) |
virtual void | finishedDraw (void) |
void | allowDraw (void) |
Allows the osgWidget to draw a frame. More... | |
virtual bool | getAllowDraw (void) |
virtual bool | getSyncGraphics (void) |
virtual void | addPlugin (const interfaces::pluginStruct &plugin) |
virtual void | removePlugin (interfaces::PluginInterface *pl) |
virtual void | switchPluginUpdateMode (int mode, interfaces::PluginInterface *pl) |
virtual void | sendDataToPlugin (int plugin_index, void *data) |
virtual void | cfgUpdateProperty (cfg_manager::cfgPropertyStruct _property) |
const std::string | getConfigDir () const |
void | noGUITimerUpdate (void) |
virtual void | receiveData (const data_broker::DataInfo &info, const data_broker::DataPackage &package, int callbackParam) |
The DataBroker will call this method to notify the receiver of whenever the condition for which the receiver registered occur. More... | |
virtual const utils::Vector & | getGravity (void) |
virtual void | step (bool setState=false) |
virtual unsigned long | getTime () |
![]() | |
Thread () | |
virtual | ~Thread () |
void | start () |
Starts the execution of this Thread. More... | |
void | cancel (bool block=false) |
Tries to cancel the Thread. More... | |
void | setCancellationPoint () |
Adds a cancellation point to your run method. More... | |
bool | wait () |
stops execution until the thread has finished. More... | |
bool | join () |
bool | wait (unsigned long timeoutMilliseconds) |
puts the Thread to sleep for a specified amount of time. More... | |
bool | isRunning () const |
returns true if the Thread is running. More... | |
bool | isFinished () const |
void | setStackSize (std::size_t stackSize) |
std::size_t | getStackSize () const |
bool | isCurrentThread () const |
![]() | |
virtual | ~SimulatorInterface () |
bool | allConcurrencysHandled () |
![]() | |
GraphicsUpdateInterface (void) | |
virtual | ~GraphicsUpdateInterface (void) |
virtual void | preGraphicsUpdate (void) |
![]() | |
LibInterface (LibManager *theManager) | |
virtual | ~LibInterface (void) |
ModuleInfo | getModuleInfo () const |
virtual void | createModuleInfo (void) |
![]() | |
CFGClient () | |
virtual | ~CFGClient () |
virtual void | cfgParamCreated (cfgParamId _id) |
virtual void | cfgParamRemoved (cfgParamId _id) |
![]() | |
ReceiverInterface () | |
virtual | ~ReceiverInterface () |
Static Public Attributes | |
static Simulator * | activeSimulator = 0 |
Protected Member Functions | |
void | run () |
The simulator main loop. More... | |
Private Member Functions | |
void | processRequests () |
This method is used for all calls that cannot be done from an external thread. More... | |
void | reloadWorld (void) |
int | loadScene_internal (const std::string &filename, bool wasrunning, const std::string &robotname) |
void | initCfgParams (void) |
Additional Inherited Members | |
![]() | |
static Thread * | getCurrentThread () |
static void | cancelAll (bool block=false) |
![]() | |
static SimulatorInterface * | getInstance (lib_manager::LibManager *libManager) |
![]() | |
static void | msleep (unsigned long msec) |
causes the current thread to sleep for More... | |
![]() | |
LibManager * | libManager |
ModuleInfo | moduleInfo |
The Simulator class implements the main functions of the MARS simulation.
Its constructor presents the core function in the simulation and directly takes the arguments given by the user if the simulation is starting from a command line. It inherits the mars::Thread class
and the i_GuiToSim A Simulator object presents a separate thread and shares data with all other threads within the process.(remarque) To handle and access the data of the Simulator properly, the mutex variable coreMutex
is used.
Definition at line 64 of file Simulator.h.
Enumerator | |
---|---|
UNKNOWN | |
STOPPED | |
RUNNING | |
STOPPING | |
STEPPING |
Definition at line 73 of file Simulator.h.
mars::sim::Simulator::Simulator | ( | lib_manager::LibManager * | theManager | ) |
Constructor of the class
Simulator.
Definition at line 78 of file Simulator.cpp.
|
virtual |
Definition at line 137 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 655 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1068 of file Simulator.cpp.
|
virtual |
Checks if external requests are open.
true
if no external requests are open. Definition at line 1155 of file Simulator.cpp.
|
virtual |
Allows the osgWidget to draw a frame.
This method is used for gui and simulation synchronization.
Implements mars::interfaces::SimulatorInterface.
Definition at line 1148 of file Simulator.cpp.
|
virtual |
Reimplemented from mars::cfg_manager::CFGClient.
Definition at line 1200 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1122 of file Simulator.cpp.
void mars::sim::Simulator::checkOptionalDependency | ( | const std::string & | libName | ) |
Definition at line 172 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 904 of file Simulator.cpp.
mars::sim::Simulator::CREATE_MODULE_INFO | ( | ) |
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 912 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 891 of file Simulator.cpp.
|
virtual |
Exports the current scene as both *.obj and *.osg file.
Implements mars::interfaces::SimulatorInterface.
Definition at line 1191 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 667 of file Simulator.cpp.
|
inlinevirtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 173 of file Simulator.h.
|
inline |
Definition at line 192 of file Simulator.h.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1064 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1374 of file Simulator.cpp.
|
inlinevirtual |
Implements lib_manager::LibInterface.
Definition at line 91 of file Simulator.h.
|
inlinevirtual |
Implements lib_manager::LibInterface.
Definition at line 87 of file Simulator.h.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 883 of file Simulator.cpp.
|
inlinevirtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 177 of file Simulator.h.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1378 of file Simulator.cpp.
std::string mars::sim::Simulator::getTmpPath | ( | ) | const |
Returns the tmp path for temprary files, on linux /tmp/mars on windows the current config_dir.
Definition at line 562 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1004 of file Simulator.cpp.
|
virtual |
Checks if the physic simulation thread has been stopped caused by an ODE error.
If true
you cannot recover (currently) from this point without restarting the simulation.
To extend this, restart the simulator thread and reset the scene (untested).
true
if the simulation thread was not interrupted by ODE Implements mars::interfaces::SimulatorInterface.
Definition at line 1000 of file Simulator.cpp.
|
private |
Definition at line 1274 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 554 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 581 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 585 of file Simulator.cpp.
|
private |
Definition at line 607 of file Simulator.cpp.
void mars::sim::Simulator::myRealTime | ( | void | ) |
control the realtime calculation
Definition at line 496 of file Simulator.cpp.
|
virtual |
Reimplemented from lib_manager::LibInterface.
Definition at line 168 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 741 of file Simulator.cpp.
void mars::sim::Simulator::noGUITimerUpdate | ( | void | ) |
Definition at line 1059 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 865 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 874 of file Simulator.cpp.
|
virtual |
Reimplemented from mars::interfaces::GraphicsUpdateInterface.
Definition at line 887 of file Simulator.cpp.
|
private |
This method is used for all calls that cannot be done from an external thread.
This means the requests have to be caches (like in loadScene) and have to be handled by this method, which is called by Simulator::run().
Definition at line 1163 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 789 of file Simulator.cpp.
|
virtual |
The DataBroker will call this method to notify the receiver of whenever the condition for which the receiver registered occur.
info | Information about the DataPackage. |
dataPackage | The DataPackage containing all the data. |
callbackParam | The int the receiver passed during registration. The default (the receiver didn't provide a callbackParam) is 0. This can be used to easily distinguish different registrations. |
Implements mars::data_broker::ReceiverInterface.
Definition at line 1327 of file Simulator.cpp.
|
private |
Definition at line 782 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1075 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 916 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 763 of file Simulator.cpp.
|
protectedvirtual |
The simulator main loop.
This function is executing while the program is running.
It handles the physical simulation, if the physical simulation is started, otherwise the function is in idle mode.
pre: start the simulator thread and by the way the Physics loop
post:
Implements mars::utils::Thread.
Definition at line 320 of file Simulator.cpp.
|
virtual |
Initiates the simulation.
Implements mars::interfaces::SimulatorInterface.
Definition at line 226 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 642 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 558 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 573 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1126 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 1047 of file Simulator.cpp.
|
virtual |
Syncs the threads of GUI and simulation.
Implements mars::interfaces::SimulatorInterface.
Definition at line 1133 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 926 of file Simulator.cpp.
|
inlinevirtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 112 of file Simulator.h.
|
virtual |
Starts and pauses the simulation.
true
if started, false
if stopped Implements mars::interfaces::SimulatorInterface.
Definition at line 463 of file Simulator.cpp.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 360 of file Simulator.cpp.
|
inlinevirtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 119 of file Simulator.h.
|
virtual |
Implements mars::interfaces::SimulatorInterface.
Definition at line 933 of file Simulator.cpp.
void mars::sim::Simulator::updateSim | ( | ) |
Updates the graphical simulation.
Calls GraphicsManager::update() method to redraw all OSG objects in the simulation.
Definition at line 1140 of file Simulator.cpp.
|
private |
Definition at line 276 of file Simulator.h.
|
static |
Definition at line 83 of file Simulator.h.
|
private |
Definition at line 243 of file Simulator.h.
|
private |
Definition at line 274 of file Simulator.h.
|
private |
Definition at line 228 of file Simulator.h.
|
private |
Definition at line 228 of file Simulator.h.
|
private |
Definition at line 228 of file Simulator.h.
|
private |
Definition at line 228 of file Simulator.h.
|
private |
Definition at line 282 of file Simulator.h.
|
private |
Definition at line 260 of file Simulator.h.
|
private |
Definition at line 259 of file Simulator.h.
|
private |
Definition at line 259 of file Simulator.h.
|
private |
Definition at line 283 of file Simulator.h.
|
private |
Definition at line 265 of file Simulator.h.
|
private |
Definition at line 261 of file Simulator.h.
|
private |
Definition at line 245 of file Simulator.h.
|
private |
Definition at line 298 of file Simulator.h.
|
private |
Definition at line 289 of file Simulator.h.
|
private |
Definition at line 290 of file Simulator.h.
|
private |
Definition at line 291 of file Simulator.h.
|
private |
Definition at line 289 of file Simulator.h.
|
private |
Definition at line 292 of file Simulator.h.
|
private |
Definition at line 292 of file Simulator.h.
|
private |
Definition at line 292 of file Simulator.h.
|
private |
Definition at line 290 of file Simulator.h.
|
private |
Definition at line 291 of file Simulator.h.
|
private |
Definition at line 295 of file Simulator.h.
|
private |
Definition at line 297 of file Simulator.h.
|
private |
Definition at line 294 of file Simulator.h.
|
private |
Definition at line 293 of file Simulator.h.
|
private |
Definition at line 293 of file Simulator.h.
|
private |
Definition at line 288 of file Simulator.h.
|
private |
Definition at line 296 of file Simulator.h.
|
private |
Pointer to instance of ControlCenter (created in Simulator::Simulator(lib_manager::LibManager *theManager))
Definition at line 233 of file Simulator.h.
|
private |
Definition at line 252 of file Simulator.h.
|
private |
Definition at line 260 of file Simulator.h.
|
private |
Definition at line 269 of file Simulator.h.
|
private |
Definition at line 301 of file Simulator.h.
|
private |
Definition at line 270 of file Simulator.h.
|
private |
Definition at line 303 of file Simulator.h.
|
private |
Definition at line 270 of file Simulator.h.
|
private |
Definition at line 302 of file Simulator.h.
|
private |
Definition at line 248 of file Simulator.h.
|
private |
Definition at line 236 of file Simulator.h.
|
private |
Definition at line 251 of file Simulator.h.
|
private |
Definition at line 240 of file Simulator.h.
|
private |
Definition at line 234 of file Simulator.h.
|
private |
Definition at line 257 of file Simulator.h.
|
private |
Definition at line 268 of file Simulator.h.
|
private |
Definition at line 277 of file Simulator.h.
|
private |
Definition at line 284 of file Simulator.h.
|
private |
Definition at line 232 of file Simulator.h.
|
private |
Definition at line 266 of file Simulator.h.
|
private |
Definition at line 239 of file Simulator.h.
|
private |
Definition at line 275 of file Simulator.h.
|
private |
Definition at line 264 of file Simulator.h.
|
private |
Definition at line 258 of file Simulator.h.
|
private |
Definition at line 254 of file Simulator.h.
|
private |
Definition at line 253 of file Simulator.h.
|
private |
Definition at line 249 of file Simulator.h.
|
private |
Definition at line 271 of file Simulator.h.
|
private |
Definition at line 229 of file Simulator.h.
|
private |
Definition at line 229 of file Simulator.h.
|
private |
Definition at line 230 of file Simulator.h.
|
private |
Definition at line 281 of file Simulator.h.
|
private |
Definition at line 235 of file Simulator.h.
|
private |
Definition at line 237 of file Simulator.h.
|
private |
Controller port (default value: 1600)
Definition at line 267 of file Simulator.h.
|
private |
Used for preventing active waiting for a single step or start event.
Definition at line 255 of file Simulator.h.
|
private |
Used for preventing active waiting for a single step or start event.
Definition at line 256 of file Simulator.h.
|
private |
Definition at line 250 of file Simulator.h.
|
private |
Definition at line 244 of file Simulator.h.
|
private |
Definition at line 238 of file Simulator.h.
|
private |
Definition at line 231 of file Simulator.h.