ZMQ Remote API Problem with Java

Typically: "How do I... ", "How can I... " questions
Andres
Posts: 18
Joined: 06 Oct 2023, 09:06

ZMQ Remote API Problem with Java

Post by Andres »

Hi. I am trying to control CoppeliaSim remotely using the ZMQ Remote API for Java, with: https://github.com/CoppeliaRobotics/zmq ... ree/master

But I am facing many problems.

1. For the CoppeliaSim Stubs generator: https://github.com/CoppeliaRobotics/inc ... /README.md.
I do not know what to do in Usage->CMake. Where can I find the CMake they re talking about? Where should I put that CMake? I am supposed to add the lines of the Read Me into the CMake?
Besides installing the dependencies and doing the things with the CMake, should I do something else for the CoppeliaSim Stubs generator?

2. For the ZeroMQ plugin for CoppeliaSim: https://github.com/CoppeliaRobotics/simZMQ
I am having problems to run the commands, specifically. cmake -DCMAKE_BUILD_TYPE=Release. The error says there is not cmake command. I assume I have to install something in my computer. Could you tell me what should I install or if the solution for that is something else?

3. I am also troubled with the Java client: https://github.com/CoppeliaRobotics/zmq ... ients/java
The class Example.java relies on the classes RemoteAPIObjects.java and RemoteAPIClient.java. However those classes are problematic. RemoteAPIClient.java calls RemoteAPIObjects.java, but RemoteAPIObjects.java has a strange wrapper in Python that does not seem to works. And RemoteAPIObjects.java calls RemoteAPIClient.java, so it is a situation where 2 classes that are not working rely on each other. Besides, Example.java calls a method .sim() from RemoteAPIObjects(), but that method does not exist.

4. In this ZeroMQ Remote API manual for CoppeliaSim: https://www.coppeliarobotics.com/helpFiles/
There is no Java client. So I do not know if actually is possible to generate a functional client for Java or not.

5. In all of the methods of this Regular API Reference: https://www.coppeliarobotics.com/helpFiles/
For all the methods, there is an explanation for C/C++, Lua and Python, but not for Java. So I do not know if actually that Regular API is available for Java or not.

Can someone help my to solve those problems: 1. how to set up the CoppeliaSim Stubs generator, 2. how to run all the ZMQ Plugin commands, 3. how to fix the code of the Java client from the repository, 4. how to generate a Java client according to the manual and 5. to know if the Regular API functions are available for Java or not, and if so, how to call them?

Or tell me if there is any other way to control remotely CoppeliaSim with Java, that already works? If there is no other pure Java solution, I can also switch or make a wrapping with C++ or Python. In any case, I would really appreciate if you could add a functional code to your answer for me to understand better.#

Thank you.

fferri
Posts: 1327
Joined: 09 Sep 2013, 19:28

Re: ZMQ Remote API Problem with Java

Post by fferri »

You don't need to do any of that.

Simply get e.g. CoppeliaSim 4.5.1 rev4, start it, and start the ZMQ remote API server if not already running (Modules > Connectivity > ZMQ remote API server), then in a terminal

Code: Select all

#bash
# set location of your coppeliaSim app:
export COPPELIASIM_ROOT_DIR="$HOME/Downloads/coppeliaSim.app/Contents/Resources"

# download zmqRemoteApi from git
git clone -b coppeliasim-v4.5.1-rev4 https://github.com/CoppeliaRobotics/zmqRemoteApi

cd zmqRemoteApi/clients/java

# in v4.5.1 there is an error in pom.xml, at line 103 replace "libPlugin" with "include"

# build java package
mvn package

Andres
Posts: 18
Joined: 06 Oct 2023, 09:06

Re: ZMQ Remote API Problem with Java

Post by Andres »

In terminal, for the first command of export a get the following error.

'export' is not recognized as an internal or external command,
operable program or batch file.

I don´t know if there is any other command I can use.
I am working on Windows 11.

fferri
Posts: 1327
Joined: 09 Sep 2013, 19:28

Re: ZMQ Remote API Problem with Java

Post by fferri »

on Windows you would use set, e.g:

Code: Select all

set COPPELIASIM_ROOT_DIR=...

Andres
Posts: 18
Joined: 06 Oct 2023, 09:06

Re: ZMQ Remote API Problem with Java

Post by Andres »

Hi fferi. Thanks for your help. I followed all the steps you said, but I am still having problems.

When I run the command: mvn build, I get the error:

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
[ERROR] Command execution failed.

If I run it form NetBeans I get the exact same error.

Besides, there are more problems.
In RemoteAPIClient.java, NetBeans identifies the following lines as errors:

80 this.send(req);
81 this.recv();


153 UnicodeString respFunc = (UnicodeString) rep.get(k_func);


163 co.nstant.in.cbor.model.Array v_args = new co.nstant.in.cbor.model.Array();

443 objs = new RemoteAPIObjects(this);

453 RemoteAPIObjects objs = null;


The last errors are because it is not recogniying RemoteAPIObjects as a data type (which is weird but I can solve). Also, there are other additional problems.



Also, in the class Example.java I still have the same problem in this line:

11 var sim = client.getObject().sim();

Because getObject() does not recogniye a method .sim()

fferri
Posts: 1327
Joined: 09 Sep 2013, 19:28

Re: ZMQ Remote API Problem with Java

Post by fferri »

Python is required to build all the zmqRemoteApi items, including the Java client lib.

Andres
Posts: 18
Joined: 06 Oct 2023, 09:06

Re: ZMQ Remote API Problem with Java

Post by Andres »

Yes, I know that I have Python, In my computer a have a fully Python Coppelia client working. But can you be more specific on how can I make the JAVA client work, because I have not figured out how to make that code work.

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

Re: ZMQ Remote API Problem with Java

Post by coppelia »

Hello,

in CoppeliaSim V4.5.1 and earlier, you should edit zmqRemoteApi/clients/java/pom.xml: replace libPlugin with include. Then make sure that none of your paths contains any space (e.g. on Windows CoppeliaSim is installed to "program Files/..." which is problematic (COPPELIASIM_ROOT_DIR cannot contain any space otherwise mvn will fail)

Cheers

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

Re: ZMQ Remote API Problem with Java

Post by coppelia »

Best is probably you wait a few days until release V4.6, we broke too many things in-between it appears...

Andres
Posts: 18
Joined: 06 Oct 2023, 09:06

Re: ZMQ Remote API Problem with Java

Post by Andres »

Hi, I already tried it with the new version of Coppelia but I still get errors.

This is the process that I followed.

1. I installed CoppeliaSim 4.6.0 rev2.
2. I downloaded the code of the Java client from your Github repository to my computer.
3. Opened CoppeliaSim and the code in NetBeans
4. I try to run Example.java but I still get an error.

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

I still do not figure out how to make that Python use work.
Can you help me, because I really need this Java client.

Post Reply