Long responses via remote API

Report crashes, strange behaviour, or apparent bugs
Post Reply
krzmi
Posts: 8
Joined: 01 Nov 2014, 19:07

Long responses via remote API

Post by krzmi »

Hello

I have been developing some code using remote API and I noticed that whenever I use simx_opmode_oneshot_wait flag for remote calls my application hangs for 5 seconds (+/- some milis) and gets novalue and timeout flag. I tested even on the most basic function such as simxStartSimulation(). I can see that V-REP starts simulation (so the call succeeded), but remote application is hanging for no reason.

I use 3.1.2 V-REP version. Windows 7. Java 7 32bit on 64bit machine, update 71.

Thanks for help

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

Re: Long responses via remote API

Post by coppelia »

Hello,

first of all, try to update to the last V-REP version. Then, it is normal that when you estabilsh the connection, it takes a little bit of time, but this is usually under one second.

Have you tried to run some very simple code? Can you show us that code? What does simxGetPingTime return?

Cheers

krzmi
Posts: 8
Joined: 01 Nov 2014, 19:07

Re: Long responses via remote API

Post by krzmi »

I have downloaded the latest version. I ran simpleTest.java that is in V-REP directory. I added line that calls ping and received
result: 3 ping: 5000 ms

full code:

Code: Select all

package robust.pc.examples;

import coppelia.IntW;
import coppelia.remoteApi;

public class VRepTest {

    static remoteApi vrep = new remoteApi();

    public static void main (String [] args)
    {
        System.out.println("connect");
        int clientId = vrep.simxStart("127.0.0.1", 33333, true, true, 5000, 5);
        if (clientId == -1)
        {
            throw new RuntimeException("Connection error");
        }

        System.out.println("start simulation");
        vrep.simxStartSimulation(clientId, vrep.simx_opmode_oneshot);

        System.out.println("get distance handle");
        IntW distanceHandle = new IntW(0);

        int result = vrep.simxGetDistanceHandle(clientId, "sensingNose", distanceHandle, remoteApi.simx_opmode_oneshot);
        System.out.println(result);

        result = vrep.simxGetPingTime(clientId, distanceHandle);
        System.out.println(String.format("[PING] result: %d ping: %d ms", result, distanceHandle.getValue()));

        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        vrep.simxStopSimulation(clientId, vrep.simx_opmode_oneshot_wait);

        vrep.simxFinish(clientId);
    }
}

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

Re: Long responses via remote API

Post by coppelia »

A return value of 3 means (that value is bit-coded):
  • No value (1)
  • Timeout (2)
Also it gives you a ping time of 5000, which is exactly the timeout you specified for the simxStart function.

That means your connection to V-REP is not running correctly.
Then, looking at your code, it also seems you haven't understood how the remote API works: you cannot use simx_opmode_oneshot to retrieve a value!

Cheers

krzmi
Posts: 8
Joined: 01 Nov 2014, 19:07

Re: Long responses via remote API

Post by krzmi »

I think I have found the cause of the problem: I used old dll . After updating V-REP version I had to replace with new dll and problem with long responses are gone

Post Reply