Problem using setStringSignal with packFloatTable

Report crashes, strange behaviour, or apparent bugs
Post Reply
doug
Posts: 4
Joined: 17 Jun 2021, 14:33

Problem using setStringSignal with packFloatTable

Post by doug »

Hello,

I'm having trouble using sim.setStringSignal in combination with sim.packFloatTable in a custom child script for the fastHokuyo sensor. Here's a simplified version of my code:

Code: Select all

        
        sim.setStringSignal('hokuyo_range_data', sim.packFloatTable(dists))
        sim.setStringSignal('hokuyo_angle_data', sim.packFloatTable(angles))
        
Both 'dists' and 'angles' are tables with float numbers, and I’ve confirmed they contain valid data.

If I replace the packed data with a simple dummy string, the signal is sent and received correctly. However, when I use packFloatTable, I get the following error in the terminal:

Code: Select all

[Connectivity >> ZMQ remote API server@addOnScript:error] [string "Connectivity >> ZMQ remote API server@addOnSc..."]:488: [string "Connectivity >> ZMQ remote API server@addOnSc..."]:442: ...10_0_rev0_Win/luarocks/share/lua/5.3/org\conman\cbor.lua:395: TEXT: not UTF-8 text
{ret = {{data = [long string (2736 bytes)], }}, }
stack traceback:
    [C]: in function 'error'
    [string "Connectivity >> ZMQ remote API server@addOnSc..."]:442: in field 'send'
    [string "Connectivity >> ZMQ remote API server@addOnSc..."]:560: in function 'coroutineMain'
stack traceback:
    [C]: in function 'error'
    [string "Connectivity >> ZMQ remote API server@addOnSc..."]:543: in field 'resumeCoroutine'
    [string "Connectivity >> ZMQ remote API server@addOnSc..."]:488: in field 'handleQueue'
    [string "Connectivity >> ZMQ remote API server@addOnSc..."]:714: in function 'sysCall_actuation'
I seems the packed binary string might be causing an encoding issue with the ZMQ remote API server.

Has anyone encountered this before or found a workaround? Is there a recommended way to transmit binary data (like packed float arrays) through string signals when using the remote API?

Thanks in advance for any help!
coppelia
Site Admin
Posts: 10807
Joined: 14 Dec 2012, 00:25

Re: Problem using setStringSignal with packFloatTable

Post by coppelia »

Hi, sorry for the late reply due to summer vacation...

what CoppeliaSim version are you running?

Starting with CoppeliaSim V4.7, buffers are used to convey binary data that is not text. Also, starting with CoppeliaSim V4.9 signals functions are deprecated and replaced by properties. So you'd rather do:

Code: Select all

sim.setBufferProperty(sim.handle_scene, 'signal.hokuyo_range_data', sim.packFloatTable(dists))
But sim.setStringSignal is still supported for backward compatibility.

Now make sure you use the latest CoppeliaSim, and the latest ZMQ remote API package.

Cheers
Post Reply