GetSimulationTime

Typically: "How do I... ", "How can I... " questions
Post Reply
DavideIng
Posts: 39
Joined: 21 Sep 2017, 17:27

GetSimulationTime

Post by DavideIng » 24 Oct 2017, 11:09

Hello,
I am trying to get the simulation time about vrep scene and send it to Matlab.
I am using the following statements:

Vrep Non-Threaded Child Script:

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then
simExtRemoteApiStart(20001)
handleCuboid = simGetObjectHandle('Cuboid')
simulationTime=simGetSimulationTime()
PackStringTime = simPackFloatTable({simulationTime})
end


if (sim_call_type==sim_childscriptcall_actuation) then
SentStringSignal=simSetStringSignal('PackStringTime',1)
end

if (sim_call_type==sim_childscriptcall_sensing) then
end

if (sim_call_type==sim_childscriptcall_cleanup) then
Matlab Statement:

Code: Select all

dbstop if error
disp('Program started');
vrep=remApi('remoteApi'); 
vrep.simxFinish(-1); 
clientID=vrep.simxStart('127.0.0.1',20001,true,true,5000,5); 
if (clientID>-1)
disp('Connected to remote Api server');

[returnCode,Cuboid]=vrep.simxGetObjectHandle(clientID,'Cuboid',vrep.simx_opmode_blocking);

[returnCode,simulationTime]=vrep.simxGetStringSignal(clientID,'SentStringSignal',vrep.simx_opmode_streaming);

end
The issue is that the variable simulationTime has the following properties:
Name Size Bytes Class
simulationTime 0x0 0 double
That might means that this variable is not retrieved by the function simxGetStringSignal.

Someone could help me to fix this issue and get the simulation time in Matlab.

Thanks in advance

Davide

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

Re: GetSimulationTime

Post by coppelia » 25 Oct 2017, 19:15

Hello,

use simxGetLastCmdTime instead.

Cheers

Post Reply