Live sync via CSV

Typically: "How do I... ", "How can I... " questions
Post Reply
kamtah
Posts: 12
Joined: 31 Aug 2021, 09:56

Live sync via CSV

Post 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.

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Live sync via CSV

Post 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

Post Reply