Is there less features of graph scene object properties in coppelia 4.2.0?

Typically: "How do I... ", "How can I... " questions
Post Reply
hhkm10052
Posts: 1
Joined: 09 Aug 2021, 18:49

Is there less features of graph scene object properties in coppelia 4.2.0?

Post by hhkm10052 »

Hi Coppelia,

I can easily draw cruves by using GUI of graph scene object properties in coppelia 4.1.0, but coppelia 4.2.0 reduces some features on graph scene object properties. Is that i have to draw cruves by using graph's customization scripts?

When i using graph's customization scripts, i meet some problems. This is the code I'm using:

Code: Select all

graph=require('graph_customization')
function sysCall_init()
    graph=sim.getObjectHandle('Graph')
    base=sim.getObjectHandle('base_respondable')
    z=sim.addGraphStream(graph,'z','mm')
end

function sysCall_sensing()
    p=sim.getObjectPosition(base,-1)
    sim.setGraphStreamValue(graph,z,p[3])
end
it report an error:

Code: Select all

67: One of the function's argument type is not correct. (in function 'sim.getObjectInt32Param')
    stack traceback:
        [C]: in function 'sim.getObjectInt32Param'
        ...peliaRobotics/CoppeliaSimEdu/lua/graph_customization.lua:67: in function 'sysCall_nonSimulation'
Hope you can help me. Thank you in advance. Looking forward to your reply.
Sincerely,
hhkm10052

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

Re: Is there less features of graph scene object properties in coppelia 4.2.0?

Post by coppelia »

Hello,

since CoppeliaSim V4.2.0 graphs should be populated and updated programmatically. This makes things much more flexible. You have a few graph functions available for that, mainly sim.addGraphStream, sim.addGraphCurve, sim.setGraphStreamValue.

Following is a very simple example:

Code: Select all

function sysCall_init()
    graph=sim.getObjectHandle('Graph')
    joint1Vel=sim.addGraphStream(graph,'joint 1 velocity','deg/s',0,{1,0,0})
    joint2Vel=sim.addGraphStream(graph,'joint 2 velocity','deg/s',0,{0,1,0})
end

function sysCall_sensing()
    sim.setGraphStreamValue(graph,joint1Vel,180*sim.getJointVelocity(joint1Handle)/math.pi)
    sim.setGraphStreamValue(graph,joint1Vel,180*sim.getJointVelocity(joint1Handle)/math.pi)
end
Above can be in any script. However, if you want to put that code directly inside the customization script that controls the graph (which I don't recommend), then be aware that the code you showed us is overwriting the sysCall_init and sysCall_sensing functions in file lua/graph_customization.lua. So in that particular situation, you'd rather write following:

Code: Select all

graph=require('graph_customization')

function sysCall_init()
    graph=sim.getObjectHandle('Graph')
    base=sim.getObjectHandle('base_respondable')
    z=sim.addGraphStream(graph,'z','mm')
    
    -- Following taken from the corresponding function in file lua/graph_customization.lua:
    _S.graph.init()
end

function sysCall_sensing()
    p=sim.getObjectPosition(base,-1)
    sim.setGraphStreamValue(graph,z,p[3])
    
    -- Following taken from the corresponding function in file lua/graph_customization.lua:
    _S.graph.handle()
    _S.graph.updateCurves()
end
But again, we don't recommend you to put that code in the customization script attached to the graph. Rather use a child script, then you won't need above modifications. Make sure to also inspect the graphs in the many demo scenes to get an idea how things work.

Cheers

Post Reply