configuration of the time in the case using remote API

Typically: "How do I... ", "How can I... " questions
SitStudent
Posts: 23
Joined: 05 May 2020, 12:07

configuration of the time in the case using remote API

Post by SitStudent »

Hi, there

I simulate one scene using remote API and output the graph which has a time as x axis but, considering procedure of using remote API, x axis(time) is from the start of simulation not start of the remote API system .

Therefore, I want to set the start of the x axis on the graph as start of the remote API.

Is there any way for that?

sincerely,

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: configuration of the time in the case using remote API

Post by coppelia »

Hello,

currently you can only record graph value when simulation is running unfortunately. But this will be changed in next release (V4.2.0).

Cheers

SitStudent
Posts: 23
Joined: 05 May 2020, 12:07

Re: configuration of the time in the case using remote API

Post by SitStudent »

Thank you for your reply.

I use a remote api and lua child script on the scene at the same time. Is it possible lua script recognizes the moment remote API is connected on the child script?

I think about using sim.resetGraph.

Sincerely,

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: configuration of the time in the case using remote API

Post by coppelia »

Yes, this would be possible. However, there is a bug in current CoppeliaSim V4.1.0, where every graph would be automatically reset at simulation start, which is problematic for you. Next version will have that corrected.

Cheers

SitStudent
Posts: 23
Joined: 05 May 2020, 12:07

Re: configuration of the time in the case using remote API

Post by SitStudent »

Ok, so...is it possible that you tell me when that will be launched?

If you don't mind, please tell me.

Sincerely,

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: configuration of the time in the case using remote API

Post by coppelia »

next release should be out in January/February 2021. In the mean time you can always collect the data and/or transmit it to an external application for display (e.g. Matlab, etc.)

Cheers

SitStudent
Posts: 23
Joined: 05 May 2020, 12:07

Re: configuration of the time in the case using remote API

Post by SitStudent »

Hi

I updated new version of CoppeliaSim 4.2.0.
Actually, it's more useful for me to set a graph.
I really appreciate for that.

Then, about my topic, is my problem fixed by this new version of CoppeliaSim?

Sincerely,

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: configuration of the time in the case using remote API

Post by coppelia »

Hello,

yes, you can now also record graph data points when simulation is not running. Have a look inside of lua/graph_customization.lua.

Cheers

SitStudent
Posts: 23
Joined: 05 May 2020, 12:07

Re: configuration of the time in the case using remote API

Post by SitStudent »

Thank you

I saw the scripts inside lua\graph_customization.
However, I've never used these lua files inside CoppeliaSimEdu\lua so I couldn't make sense which scripts I should use.
If you don't mind, could you teach me which scripts I should use?

sincerely,

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: configuration of the time in the case using remote API

Post by coppelia »

Open the customization script attached to your graph, then past following code instead:

Code: Select all

graph=require('graph_customization')

function sysCall_init()
    graphHandle=sim.getObjectHandle(sim.handle_self)
    
    -- Create/update data streams/curves:
    sim.destroyGraphCurve(graphHandle,-1)
    stream1=sim.addGraphStream(graphHandle,'Object position X','m')
    objectHandle=sim.getObjectHandle('cube')
    startTime=sim.getSystemTime()
    
    graph.init()
end

function appendMeasurementPts()
    -- append measurement points, e.g. the x-position of an object:
    local p=sim.getObjectPosition(objectHandle,-1)
    sim.setGraphStreamValue(graphHandle,stream1,p[1])
    
    graph.handle(sim.getSystemTime()-startTime)
    graph.updateCurves()
end

function sysCall_sensing()
    appendMeasurementPts()
end

function sysCall_nonSimulation()
    appendMeasurementPts()
end

function sysCall_suspended()
    appendMeasurementPts()
end

function sysCall_beforeSimulation()
end

function sysCall_afterSimulation()
end

function sysCall_suspend()
end

function sysCall_resume()
end
In above code, the x-position of object cube will be displayed in the graph. On the x-axis, you'll have the real time, in seconds. When simulation is not running, there will be a new point added only one time every 8 seconds on average. To change that to say 25, do:

Code: Select all

sim.setInt32Parameter(sim.intparam_idle_fps,25)
When a change was made in the customization script, make sure you restart it by clicking the restart script button in the script editor.

Cheers

Post Reply