## Matlab receives empty values from Coppelia using simxGetStringSignal

Typically: "How do I... ", "How can I... " questions
elizakh
Posts: 15
Joined: 20 Feb 2021, 13:27

### Matlab receives empty values from Coppelia using simxGetStringSignal

Hi everyone,

I've a trouble sending data from Coppelia to Matlab. So I've this code in Coppelia:

Code: Select all

time=sim.getSimulationTime()
if time==10 then
position=sim.getObjectPosition(ball,-1)
pos_Y=position[2]
print("pos_Y",pos_Y)
sim.setStringSignal("posicion",pos_Y)

And in Matlab I've:

Code: Select all

[returnCode1,ball]=sim.simxGetStringSignal(clientID,'pos_Y',sim.simx_opmode_streaming);
But when I run the simulation, the variable ball doesn't receive the value of pos_Y, it receives an empty value so : ball=[]
I tried to change sim.simx_opmode_streaming to sim.simx_opmode_buffer but It stills the same.

For the other side, when my robot throws a ball in Coppelia, (I've changed the angular and linear damping of the ball because the ball was moving infinitely) and now the ball stops(but I noticed that the ball continues increasing his position for example: it stops in axis X at 1.250000 but I notice that it stills increasing to 1.250001) and for that the simulation never stops and I don't know how can I fix it.

And finally, I want to know if there is any way for Coppelia to do the same simulation a number 'n' of time. So for example, when the robot performs the process of throwing the ball, the simulation restarts itself and redoes the entire action again during, for example, 30 times or the times that my script in MATLAB wants.

Sorry for my english mistakes!

Cheers:)

coppelia
Posts: 8516
Joined: 14 Dec 2012, 00:25

### Re: Matlab receives empty values from Coppelia using simxGetStringSignal

Hello,

please first read about how to correctly use the streaming mode with the legacy remote API, since following will of course not work:

Code: Select all

[returnCode1,ball]=sim.simxGetStringSignal(clientID,'pos_Y',sim.simx_opmode_streaming);
Cheers

elizakh
Posts: 15
Joined: 20 Feb 2021, 13:27

### Re: Matlab receives empty values from Coppelia using simxGetStringSignal

Thank you for the post,
So I understand now how it works. But, it's normal that the process of receiving the data from Coppelia to MATLAB takes aproximately 30 seconds? I know that it takes time to receive the values, but I think it's a little slow.

Is there a way to do it a little bit faster?

Cheers!

coppelia