Chipping in here as I recently started using Virtual Coach as well and had the same problem.

I have now found a solution that works very well for me in Jupyter Notebook and I have put the code here if it should be helpful to anyone: https://pastebin.com/xnd8NeDC

How I solved the problem of getting simulation time was through rospy.Time, and running an experiment for a given amount of time was by running a loop that checks rospy.Time.now() every 3 seconds. I don't know if this is a good way to do it but I didn't find a better alternative.However, if anyone has a better way I'm all ears

Here is a quick overview what my script does:

Logs on to NRP local platform

Establishing settings for how long to run experiment and which experiment

Clones experiment

Launches experiment

Starts simulation, checking both wall time and simulation time

Runs simulation for given amount of seconds (sim time) while showing a progress bar

Pauses simulation

Saves out CSV files

Copies all simulation data into a data_package (custom tools that are not included in this paste)

The last function call is to make sure that the reset operation was complete, as the amount of time needed to reset an experiment varies from one experiment to another depending on the number of models for example.

As for the real time issue, you can just import time in your python module and mark the time the simulation started at sim_start_time = time.time() right after starting the simulation and then calculate the difference of the current time from that marked time in the future.

I did see the register_callback function, but I couldn't find any examples of how to implement it, so I went with a more 'hacked' version. I didn't understand how to implement your code snippet in the current Guide, so I am looking forward to your rewritten Guide!

To extend it a little (and sorry for hijacking the thread) - In your diagram, what is the method (procedure) to induce parameters into your experiment for each new mutation? I guess its the step you call "Parameterize Brain"?

Would you simply get the Brain model / Transfer Functions, edit them and save them back into the experiment and run again, or is there another (smarter) way?Would you recommend making a 'settings' file that are imported + reloaded in the various TF's and Brain models and then you edit that settings file for each re-run of the experiment? (forced 'reload' because it seems that imported modules in TF's and Brain models are not automatically being reloaded, when re-running an experiment, even though TF files and Brain models are being reloaded themselves?)

Any pointer of an efficient/easy way to do this would be greatly appreciated

Yeah I save the brain code in a string and then modify the string and update the brain with the edit_brain() function. Currently there is no smarter way unfortunately. Same goes for Transfer Functions.

The imported settings could be an option, but I didn't play around with that. I would be interested in exploring this option once I'm done updating the guide.

Please let me know also if you would like to have more Virtual Coach features.