Launching V-Rep from Java

Typically: "How do I... ", "How can I... " questions
Post Reply
Rodrigo
Posts: 29
Joined: 25 Aug 2014, 16:33

Launching V-Rep from Java

Post by Rodrigo »

Hi

I am trying to launch V-Rep from a java application using the ProcessBuilder class in java like this:

Code: Select all

try {
    ProcessBuilder qq=new ProcessBuilder("./vrep.sh","-h");
    qq.directory(new File("/home/.../V-REP_PRO_EDU_V3_1_3_64_Linux/"));
    File log = new File("log");
    qq.redirectErrorStream(true);
    qq.redirectOutput(Redirect.appendTo(log));
    Process p = qq.start();
    } catch(Exception e) {
            System.out.println(e.toString());
            e.printStackTrace();
    }
Which basically starts a new process and appends the stdout and stderr of the opened simulator to a file called "log". The simulator opens as expected but, after the java program is done and the simulator is closed the log file looks like this (I have removed some plugins):

Code: Select all

Add-on script 'vrepAddOnScript-addOnScriptDemo.lua' was loaded.
Simulator launched.
Plugin 'Dynamics': loading...
Plugin 'Dynamics': load succeeded.
Plugin 'RemoteApi': loading...
Starting a remote API server on port 19997
As opposed to when I open it in a linux terminal:

Code: Select all

Add-on script 'vrepAddOnScript-addOnScriptDemo.lua' was loaded.
Simulator launched.
Plugin 'Dynamics': loading...
Plugin 'Dynamics': load succeeded.
Plugin 'RemoteApi': loading...
Starting a remote API server on port 19997
Plugin 'RemoteApi': load succeeded.
Using the internal 'MeshCalc' functionality.
Using the 'Dynamics' plugin.
Using the internal 'PathPlanning' functionality.
Is the remote API plugin waiting for some signal to continue with the loading process? I know the remote API server is running because I can control the simulator from java, so is there a way to tell the simulator that the remote Api has been loaded for it to continue initializing?

Also can this affect the performance of the simulator? This is because I have noticed that simulations take more time to complete if I launch the simulator from java compared to when I launch it from a terminal so I am trying to find the reason for this.

Thanks!

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

Re: Launching V-Rep from Java

Post by coppelia »

Hello,

as far as I understood it, V-REP operates normally also when launched from Java. The only problem is that the console stops printing information after some time, and also appears slightly slowlier.

So if V-REP runs, then this means that the console simply stopped printing information (for whatever reason). Also, if Java launches the process for V-REP, maybe the process priority is not the same as when launched from the console. I am really not sure about this.

Cheers

Post Reply