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

Typically: "How do I... ", "How can I... " questions
Post Reply
mthor13
Posts: 4
Joined: 03 Jul 2017, 08:32

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

Post by mthor13 » 21 Jul 2017, 15:58

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

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

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

Post by coppelia » 25 Jul 2017, 20:45

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

Post Reply