Hello Coppelia,
I see that there are multiple different ways to pack table in Lua scripts: such as packInt, packFloat, packDouble, packTable, etc. But there are only unpackInt and unpackFloat for the remote API, what if I want to pack table of table such as {{1,2,3
},{3,4,5}} and unpack them in python to get [[1,2,3],[3,4,5]]? What should I do?
Thank you!
Pack Table in Coppeliasim and Unpack in Python Remote API
Re: Pack Table in Coppeliasim and Unpack in Python Remote API
For complex data, one option is to use a codec such as JSON or CBOR.
E.g. in Lua:
in Python:
E.g. in Lua:
Code: Select all
--lua
cbor=require'cbor'
buf=cbor.encode{{1,2,3},{3,4,5}}
-- send buf...
Code: Select all
#python
# receive buf...
import cbor
print(cbor.loads(buf))
# prints [[1, 2, 3], [3, 4, 5]]