Hi Alexandre,
There are a couple of ways you can get the time:
I hope that answers your question.
Greetings, Marcel
--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/09555871-ff73-4848-b37a-2072500e85aan%40googlegroups.com.
I think you need to explain more context about what you are trying to do. From your original question it was not clear to me at all that:
Greetings, Marcel
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/803bad59-c8a4-44c5-9e48-ff70feaa878cn%40googlegroups.com.
Can you share with us the relevant parts of your "simulation loop"?
For example (I'm using Chrono::Vehicle mostly) a lot of the vehicle related demos have a simulation loop that goes something like this:
// Simulation loop vehicle.EnableRealtime(true); while (vis->Run()) { // Render scene vis->BeginScene(); vis->Render(); vis->EndScene(); // Get driver inputs DriverInputs driver_inputs = driver->GetInputs(); // Update modules (process inputs from other modules) double time = vehicle.GetSystem()->GetChTime(); driver->Synchronize(time); vehicle.Synchronize(time, driver_inputs, terrain); if (add_trailer) trailer->Synchronize(time, driver_inputs, terrain); terrain.Synchronize(time); vis->Synchronize(time, driver_inputs); // Advance simulation for one timestep for all modules driver->Advance(step_size); vehicle.Advance(step_size); if (add_trailer) trailer->Advance(step_size); terrain.Advance(step_size); vis->Advance(step_size); }
(taken from demo_VEH_WheeledJSON.cpp)
So you can see it has a flag to determine if it should pause at
the end of each step to stay in realtime (assuming it finished
early). It could be you're missing that flag. It could also be
your loop is altogether slightly different and you need to add
some form of sleep at the end of your loop manually. I have a few
loops where I've done this "manually" as I wanted to have the
option not just to sleep at the end of each step, but, if the
simulation ran behind for a short while, to also "catch up" again.
Anyway, such logic is not that hard to write yourself if you want
something that suits your specific scenario.
Greetings, Marcel
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/4a574511-734b-43b6-acd4-f96103885806n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/4a574511-734b-43b6-acd4-f96103885806n%40googlegroups.com.