Coppelia/Matlab synchronisation

Typically: "How do I... ", "How can I... " questions
Post Reply
jovan_s
Posts: 18
Joined: 01 Dec 2020, 10:19

Coppelia/Matlab synchronisation

Post by jovan_s »

Hello Coppelia,

I have a problem connecting Coppelia and Matlab. I want to start the simulation from Matlab, then let a threaded child script in Coppelia do something, then, when that's finished receive some values from Matlab. While Coppelia child script is executed Matlab is in a while loop and constantly reading signal value. I tried to set a flag signal from Coppelia so Matlab will know when to start sending values. However, Matlab cannot read the correct value. I can see in Coppelia that the signal has indeed changed value, but when I read it from Matlab it still shows the old value. So instead of setting the flag in a threaded script, I tried doing it from another, non-threaded one but the same thing happened. I use synchronous mode and I tried using different operation modes in Matlab (blocking, streaming, buffer) to read the script but the same thing happened.
Does anyone have any idea as to why this happens and how I could fix it?
Cheers
Jovan

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: Coppelia/Matlab synchronisation

Post by coppelia »

Hello Jovan,

how are you trying to read the signal on the client side? And how are you setting the signal on CoppeliaSim side?

Cheers

jovan_s
Posts: 18
Joined: 01 Dec 2020, 10:19

Re: Coppelia/Matlab synchronisation

Post by jovan_s »

Hi,

So on the Coppelia side, I used

sim.setIntegerSignal('flag',1)

and on the Matlab side, I used

sim.simxGetIntegerSignal(clientID, 'flag', sim.simx_opmode_blocking)

I also tried with simx_opmode_oneshot and I also tried using the combined streaming+buffer mode, but it still did not work.

Cheers
Jovan

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: Coppelia/Matlab synchronisation

Post by coppelia »

There is another problem probably. Are you sure the signal is set in the script (make sur you output a print to the status bar to make sure). Also, could it be that the same signal is set from another script, or another external client, or another part of your Matlab code?

Cheers

Post Reply