Page 1 of 1

Live sync via CSV

Posted: 24 Sep 2021, 09:04
by kamtah
Hello,

I want to synchronize live my robot and my simulation on Coppelia.
For this, I write positions values continuously in a CSV file (the CSV is rewritten).

Then, I read at the same time, every "y" milliseconds, the values from this CSV on a Coppelia script.

Code: Select all

--lua
while true do
    sim.wait(y)
    PoseTable = readcsvf_function('path/to/csv_file_test',',')
    -- need the following condition because sometimes readcsvf_function return nothing 
    if  PoseTable ~= nil then
    ....do things
My program seems to work, but I was wondering if there was a more proper way of doing that, or if this code could cause possible errors that I have not spotted.

Re: Live sync via CSV

Posted: 24 Sep 2021, 10:17
by fferri
It would be best to use network sockets, or some high level abstraction over those, such as ZeroMQ, which is also simpler to use, and readily available for many programming languages (C, C++, Python, Swift, Ruby, Java, Scala, C#, Go, Lisp, PHP, Tcl, R, Perl, Bash, Ada, JavaScript (Node.js.), Lua, Objective-C, Julia, Haskell, Racket, Eiffel just to name a few), or ROS which might be already available for your robot.

Have a look at all the available options for having CoppeliaSim talk with the outside in Messaging/interfaces/connectivity.

Cheers