Page 1 of 1

how to run simulations circularly and automatically

Posted: 31 Jan 2018, 03:40
by Matthew Qi
Hi,

I am using V-REP with Python API to simulate the walking process of my robot, to make the robot perform perfectly, I have to adjust some parameters which could be a heavy work. So I want to run the simulation circularly and adjust these parameters automatically to find the optimums.

But I have no idea to make it in V-REP, could you give me some examples or any tutorials?

Thanks in advance!

Yours,
Matt

Re: how to run simulations circularly and automatically

Posted: 04 Feb 2018, 16:16
by coppelia
Hello Matt,

the best for that is to use a customization script, that will adjust various parameters when simulation is not running, and that will listen to some signal or other trigger to start and stop a simulation. That customization script could also interact with a remote API client, a ROS node, or a BlueZero node (will be available in V-REP 3.5.0, to be released within 1-3 days).

Cheers

Re: how to run simulations circularly and automatically

Posted: 08 Feb 2018, 10:04
by Matthew Qi
Hi,
Thank you for your quick reply!

Do we have any examples about customization scripts that I can refer to?

Re: how to run simulations circularly and automatically

Posted: 08 Feb 2018, 18:28
by coppelia
Have a look at the following models for instance:
  • Models/tools/rosInterface helper tool.ttm
  • Models/tools/simulation stepper tool.ttm
Cheers

Re: how to run simulations circularly and automatically

Posted: 26 Feb 2018, 02:22
by Matthew Qi
Hi,
Though have read the rosInterface helper tool.ttl, I still have no idea how to write customization script interface with Python.

And I am wondering if you've misunderstanding what I mean, I think it's better to write code in Python API to make simulation keep running circularly and change parameters to find the optimum.

Thanks

Re: how to run simulations circularly and automatically

Posted: 27 Feb 2018, 10:30
by coppelia
What I meant to say:

From Python (or in general from an external application) you are much more limited in what you are able to do. But you don't have that limitation from a script running in V-REP. For that reason it is often a good idea to handle the more complex things from within a script, and have the external application just trigger specific routines or behaviours in the script.

Basically, a script can run hand-in-hand with an external application, whether it is a remote API client, a ROS node, or a BlueZero node.

Cheers

Re: how to run simulations circularly and automatically

Posted: 08 Mar 2018, 14:18
by Matthew Qi
Hi,

Let's make it concretely. Suppose we have two variables , a = [0,10] and b =[1,5], in Python Remote API, we begin simulations when a = 0, b =1, every time when simulation stop , a and b should both plus one , a = 1 and b = 2, and then simulation start again.

So how could I change the value of a and b in the customization script, some sample code would be the best.

And I'm also wondering if there have any method to save data(such as the torque of joint) automatically, rather than by export the graph into CSV by hand

Thanks in advance!

Re: how to run simulations circularly and automatically

Posted: 12 Mar 2018, 07:10
by coppelia
If you run in synchronous mode, then you'll be triggering each simulation step from your remote API client. Then, inside of your customization script, in a sensing section, i.e.:

Code: Select all

function sysCall_sensing()
    a=a+1
    b=b+1
end
you could be incrementing your values. sysCall_sensing() is called exactly once for each simulation step.

To say data, best is to do that yourself inside of a child script or customization script: you'll simply have to open a file, and write data to that file, then close that file at the end of a simulation.

Cheers