Page 1 of 1
Graph functionality
Posted: 10 Feb 2016, 02:48
by Matt
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
Re: Graph functionality
Posted: 10 Feb 2016, 08:30
by coppelia
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
Re: Graph functionality
Posted: 10 Feb 2016, 20:16
by Matt
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:
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...).
Re: Graph functionality
Posted: 04 Oct 2017, 10:24
by psychemedia
+1 on a simple function for getting data out of a graph object buffer.
Re: Graph functionality
Posted: 04 Oct 2017, 17:41
by coppelia
You have some undocumented graph functions, such as simGetGraphCurve. Have a look at the customization script located in lua/graph_customization.lua
Cheers