Rerun experiment with virtual-coach


#1

Hello,

I am trying to automate my simulations and use the Virtual Coach with a python script. In each step I would like to call a different world, as I want to test the behavior of my robots in different environments.

However I am running into problems, since after the first loop and I have tried different ways to start a new simulation.

  1. The most intuitive way seemed to be to simply do

sim.reset(‘full’)

However, after resetting, it keeps “kicking out” my transfer function and gives an error:

''ERROR: [2019-09-11 17:58:36,171 - Simulation (dlr_hbp_nrp_v00_vcoach - localhost #3)] There was a Runtime error resulting from the Transfer Function. The full error is below:
severity: 1
sourceType: “Transfer Function”
errorType: “Runtime”
message: “‘NoneType’ object has no attribute ‘pose’”
functionName: “Reflex_Controller”
lineNumber: 139
offset: -1
lineText: ‘’
fileName: ‘’

I tried deleting the Transfer function after each loop and simply adding at the beginning, but that does not helo. I checked using the visualization and the same error occurred, telling me also:

‘NoneType’ object has no attribute ‘pose’ (Runtime)

If I keep klicking on the green button to activate a TF however, it does take it eventually. It might be a problem with the communication with ROS? Is there a way to fix this problem??


  1. I also tried to just stop the Simulation at the end of one round with

sim.stop()

and then just start it again at the next loop. However, in this case I get the error:

File “/home/ansch/Documents/NRP/VirtualCoach/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/simulation.py”, line 172, in start
self.__set_state(‘started’)
File “/home/ansch/Documents/NRP/VirtualCoach/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/simulation.py”, line 241, in __set_state
raise Exception(“Unable to set simulation state, HTTP status %s” % status_code)
Exception: Unable to set simulation state, HTTP status 400

So eventually I also gave up on this… is there a fix?


  1. I also tried to simply relaunch the whole simulation by calling each loop:

vc = VirtualCoach(environment=‘local’, storage_username=‘nrpuser’)

but of course I do not want to type in the password every time and I have not figured out how to automatically prompt it. Is there a way to do this?

If I do not restart the whole environment I always get the error that there is no server available after the first loop, so again I cannot restart the simulation.

I am running out of ideas on how to fix this and I would be very happy if any of you have a hint on how I can solve this problem.

Thank you very much,
Annika


#2

Regrading your point #3, you can pass the password as a parameter when instantiating the Virtual Coach if you’re using an up-to-date version of the NRP.

vc = VirtualCoach(environment='local', storage_username='nrpuser', storage_password='password')

I’m not sure what might be causing your other errors, maybe someone from the dev team will be able to help.

Best,
Mahmoud


#3

Thank you!!! This seems to work. I will try if I can get it to work this way! :slight_smile:


#4

Hi Annika,

About this error:

It’s very likely caused by a transfer function (TF) trying to access a member (pose in your case) of a ROS message no yet received on a subscribed topic.
In a TF, every access to a message received on topics should be guarded against None since when the is not available its mapped variable (mapped with a decorator) will be None.

In fact, I recommend to validate the messages at the beginning of the TF so to be sure that the data needed by the computation are indeed been received. In case one or more (required) messages are not (yet) available, simply skip a simulation loop returning from the TF.

e.g.

let me know if this solves your problem.

Best,

Ugo


#5

Hello Mahmoud,

Thank you! The login without typing the password works, however, I still get the error, that no server is available.

Edit:
After some trying around, I found out, that the problem was that the CLE did not have enough time to stop the running server, thus it was still running at the beginning of the next loop.

I solved it by adding time.sleep(30) after stopping the simulation and giving it some time to shut down before the next iteration. This seems to work!

Thank you for your quick help,
Annika


#6

Hi Ugo,

your suggestion works! Thank you!
It does not fully solve my problem, since the reset does not seem to fully restart the whole simulation, e.g. recall the .bibi-file and .exc-file again. But the error is gone. So at least one problem solved.

Thank you,
Annika