Graph functionality

Requests or suggestions for new features
Post Reply
Matt
Posts: 10
Joined: 02 Feb 2016, 21:33

Graph functionality

Post by Matt » 10 Feb 2016, 02:48

Hi there,

It would be nice to see some extra graph functionality added. Specifically:

1) Getting data through an API function (simGetGraphData)
2) Saving/exporting data through an API function (simExportGraphData)
3) Creating a graph (simCreateGraph)
4) Associating/Removing objects from graph (simAddGraphItem)
5) Changing graph colours (simSetObjectInt32Parameter)

I'd like to save a decent amount of data from simulation runs, but it's unfeasible to manually do it for each point. Right now my workaround is to add a child script to the graph object, and append information to a table on every sensing step.

Matt

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

Re: Graph functionality

Post by coppelia » 10 Feb 2016, 08:30

Hello Matt,

the general way of doing this is that have a graph that contains several user-defined data streams, and to feed them via the API with data (simSetGraphUserData) that you collect with various API functions (e.g. simGetObjectPosition, etc.).

Cheers

Matt
Posts: 10
Joined: 02 Feb 2016, 21:33

Re: Graph functionality

Post by Matt » 10 Feb 2016, 20:16

Agreed, adding and visualizing data on a graph is no problem. (4) was maybe a bit more of a convenience then a necessity.

But right now it doesn't look like there's much functionality for doing other manipulations with it. If for example I wanted to collect data and save data over a time range, I've had to do something like this:

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then 

    data_table = {}

end 

if (sim_call_type==sim_childscriptcall_sensing) then 

    if simGetIntegerSignal("collectData") ~= nil then
        table.insert(data_table, data)
    end

    if simGetIntegerSignal("resetData") ~= nil then
        data_table = {}
    end

    if simGetIntegerSignal("saveData") ~= nil then
        ...
    end

end
Whereas the graph would have this information already. If instead of using signals and managing memory there was an equivalent function for getting recorded data from the graph object, e.g.:

Code: Select all

r, data = simGetGraphData(stream_name, time_start, time_end)
and saving data:

Code: Select all

r = simExportGraphData(data)
it would make things a lot more streamlined. Right now there's no API equivalent for exporting data, although it can be done manually (Menu bar --> File --> Export --> Selected graphs as CSV...).

psychemedia
Posts: 11
Joined: 09 Sep 2017, 01:10

Re: Graph functionality

Post by psychemedia » 04 Oct 2017, 10:24

+1 on a simple function for getting data out of a graph object buffer.

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

Re: Graph functionality

Post by coppelia » 04 Oct 2017, 17:41

You have some undocumented graph functions, such as simGetGraphCurve. Have a look at the customization script located in lua/graph_customization.lua

Cheers

Post Reply