Page 1 of 2
configuration of the time in the case using remote API
Posted: 02 Nov 2020, 10:33
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,
Re: configuration of the time in the case using remote API
Posted: 03 Nov 2020, 10:32
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
Re: configuration of the time in the case using remote API
Posted: 03 Nov 2020, 17:27
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,
Re: configuration of the time in the case using remote API
Posted: 04 Nov 2020, 16:24
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
Re: configuration of the time in the case using remote API
Posted: 05 Nov 2020, 12:17
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,
Re: configuration of the time in the case using remote API
Posted: 09 Nov 2020, 09:20
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
Re: configuration of the time in the case using remote API
Posted: 20 May 2021, 11:37
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,
Re: configuration of the time in the case using remote API
Posted: 20 May 2021, 13:00
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
Re: configuration of the time in the case using remote API
Posted: 21 May 2021, 07:20
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,
Re: configuration of the time in the case using remote API
Posted: 25 May 2021, 06:46
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