Page 1 of 1

Plotting a variable in a graph (from a ROS node)

Posted: 21 Jul 2017, 15:58
by mthor13
Hi,
I want to plot a variable (received from a C++ ROS node) in a graph, but I am having some issues.
I get the following error message:
Lua runtime error: [string "[embScript_47452005.lua] SCRIPT hexapod"]:147: Invalid data stream. (sim.setGraphUserData)
stack traceback:
[C]: in function 'setGraphUserData'
...EP_PRO_EDU_V3_4_0_Linux/lua/hexapod_child_script.lua:147: in function '__scriptCodeToRun__'
/home/mat/V-REP_PRO_EDU_V3_4_0_Linux/lua/sim.lua:19: in function 'include'
[string "[embScript_47452005.lua] SCRIPT hexapod"]:1: in main chunkck:
This is what is currently have:

Code: Select all

function CPGOutput_cb(msg)
    data=msg.data
    sim.setGraphUserData(graphHandle, "CPG_output", data)
end

Code: Select all

if (sim_call_type==sim.childscriptcall_initialization) then
    graphHandle=sim.getObjectHandle("Graph")
Is it even possible to plot just a float variable?

SOLUTION:

Code: Select all

function CPGOutput_cb(msg)
    data = msg.data
    sim.setStringSignal("CPGOutput_signal",data)
end

Code: Select all

if (sim_call_type==sim.childscriptcall_sensing) then
    signalData=simGetStringSignal("CPGOutput_signal")
    simClearStringSignal("CPGOutput_signal")
    if signalData then
        print(signalData)
        print("\n")
        simSetGraphUserData(graphHandle,"CPGOutput_stream",signalData)
    end
end
Best Regards,
Mathias Thor

Re: Plotting a variable in a graph (from a ROS node)

Posted: 25 Jul 2017, 20:45
by coppelia
Hello Mathias,

Are you sure your data stream type is "Various: user-defined"?
Also, make sure to check this link.
Otherwise you can always open a custom user interface window and draw the curve manually (i.e. where you control every aspect of the graph). For that, you can find inspiration in the demo scene customUI.ttt

Cheers

Re: Plotting a variable in a graph (from a ROS node)

Posted: 14 Feb 2018, 16:03
by mthor13
Thanks!
Worked for me.