Page 1 of 1

Setup zmqRemoteApi

Posted: 30 Sep 2021, 13:22
by kamtah
Hello,

I want to use zmqRemoteApi in order to communicate with python. So I tried to set it up as indicated on the ZeroMQ-based remote API page.
For CoppeliaSim V4.2.0, follow this procedure: clone the ZeroMQ-based remote API repository into your CoppeliaSim/programming folder. Then use this compatibility add-on and that script, and place them into your CoppeliaSim/ and CoppeliaSim/Lua folders respectively.
When I follow this procedure, Coppelia adds ZMQ remote API in the add-ons list but with an (error)
And the command tab shows me the following error:

[string "ZMQ remote API@addOnScript"]:120: attempt to call a nil value (field '__raiseErrors')
stack traceback:
[string "ZMQ remote API@addOnScript"]:120: in function 'sysCall_init'
[ZMQ remote API@addOnScript:error] 142: read in arg 1 (socket): expected string (in function 'simZMQ.close@simExtZMQ')
stack traceback:
[C]: in function 'simZMQ-typecheck.close'
[string "ZMQ remote API@addOnScript"]:142: in function 'sysCall_cleanup'

To describe more precisely what I did:
- I cloned the ZeroMQ-based remote API repository in CoppeliaSim/programming
- I downloaded the add-on and the script and placed them in their corresponding folder
- I converted the add-on and the script from .txt to .lua files
- I launched Coppelia and I got the error I showed above, so I tried to follow the procedure from ZeroMQ-based remote API github.
$ mkdir zmqRemoteApi/build
$ cd zmqRemoteApi/build
$ cmake ..
$ cmake --build .
$ cmake --install .
- but I get the following error at the "cmake .." step:
CMake Error at C:/Program Files/CoppeliaRobotics/CoppeliaSimPro/programming/libPlugin/cmake/FindCoppeliaSim.cmake:17 (message):
Found CoppeliaSim version 4.2.0.5 but 4.3.0.0 required.
But obviously, 4.3.0 is not out yet, so something else should have gone wrong

I'm using v4.2.0 rev5 with windows 10.

Re: Setup zmqRemoteApi

Posted: 01 Oct 2021, 08:24
by coppelia
Hello,

you are right, we recently modified something, and now a third file is required: simZMQ.lua
Just replace the existing simZMQ.lua with above one.

The ZeroMQ-based remote API page was updated.

Cheers

Re: Setup zmqRemoteApi

Posted: 12 Jan 2022, 14:00
by r_dhak
Hello,
I am also trying to install the zmqRemoteApi, however I am also getting the same error.
CMake Error at /home/rohit/rohit/CoppeliaSim_4.2.0_rev5/CoppeliaSim_Edu_V4_2_0_Ubuntu18_04/programming/libPlugin/cmake/FindCoppeliaSim.cmake:17 (message):
Found CoppeliaSim version 4.2.0.5 but 4.3.0.0 required.
Call Stack (most recent call first):
/home/rohit/rohit/CoppeliaSim_4.2.0_rev5/CoppeliaSim_Edu_V4_2_0_Ubuntu18_04/programming/libPlugin/cmake/FindCoppeliaSim.cmake:136 (coppeliasim_find_error)
CMakeLists.txt:15 (find_package)
I checked the requirements for libPlugin

Minimum versions:

C++17 compiler (Visual C++ 2019, gcc-7, clang-3.9) ------ gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
CMake 3.16.3 ---------------------------------------- cmake version 3.22.1
Python 3.8 ------------------------------------------ Python 3.9.7

I followed the exact steps:
$ git clone --recursive https://github.com/CoppeliaRobotics/zmqRemoteApi
$ mkdir zmqRemoteApi/build
$ cd zmqRemoteApi/build
$ cmake .. -------------------> Where error is occuring
$ cmake --build .
$ cmake --install .

Not sure what the problem is.
Any suggestion is greatly appreciated.

Thank You.

Re: Setup zmqRemoteApi

Posted: 12 Jan 2022, 14:34
by coppelia
Hello,

you do not need to compile the repository. You actually only need the repository for the client side Python items (i.e. in programming/zmqRemoteApi/clients/python)
But make sure you download the other required items, for CoppeliaSim V4.2.0 as explained on this page.

You can also have a look at the beta version of next CoppeliaSim. It should already have everything in place.

Cheers

Re: Setup zmqRemoteApi

Posted: 03 Feb 2022, 11:08
by Rufio2790
Dear all,

We are trying to connect to Coppelia using a python script by executing the ZeroMQ remote API example code in your web. The lua scripts required have been included and the packages required have been installed. We added the third script commented in this topic.

When executing the code, the following error appears in the python terminal:

Code: Select all

Traceback (most recent call last):
File "C:\Workspace\pyRobotics\app\scripts\tracker_calibration\coppelia_remote_api.py", line 20, in <module>
sim = client.getObject('sim')
File "C:\Program Files\CoppeliaRobotics\CoppeliaSimEdu\programming\zmqRemoteApi\clients\python\zmqRemoteApi\__init__.py", line 75, in getObject
_info = self.call('zmqRemoteApi.info', [name])
File "C:\Program Files\CoppeliaRobotics\CoppeliaSimEdu\programming\zmqRemoteApi\clients\python\zmqRemoteApi\__init__.py", line 69, in call
return self._process_response(self._recv())
File "C:\Program Files\CoppeliaRobotics\CoppeliaSimEdu\programming\zmqRemoteApi\clients\python\zmqRemoteApi\__init__.py", line 59, in _process_response
raise Exception(resp.get('error'))
Exception: None
Apparently, resp variable inside RemoteAPIClient._recv function has a field success == True, which is the reason of launching an exception. Could you give any advice to solve this problem?

Thanks in advance,

Re: Setup zmqRemoteApi

Posted: 03 Feb 2022, 13:37
by coppelia
Hello,

please download and use CoppeliaSim V4.3, there it should work out of the box.
Additionally, are you using CoppeliaSim V4.2? Are you sure you have installed zmq and cbor Python modules?

Cheers

Re: Setup zmqRemoteApi

Posted: 03 Feb 2022, 22:54
by Rufio2790
Thanks for the answer.
With respect to your questions, yes I'm sure I've installed the required packages, the problem persist in version 4.2.

In Coppelia 4.3, it works just fine.
However, the documentation (https://www.coppeliarobotics.com/helpFi ... rview.htm ) should be updated with the following code:

Code: Select all

import time
from zmqRemoteApi import RemoteAPIClient
client = RemoteAPIClient()
sim = client.getObject('sim')
client.setStepping(True)

sim.startSimulation()
while (t := sim.getSimulationTime()) < 3:
    s = f'Simulation time: {t:.2f} [s]'
    print(s)
    client.step()
sim.stopSimulation()
I just fixed some incorrect function call that prevent the code to run smothly.

Last question: the ZmqRemoteApi is thought to run scripts directly from the folder "programming/zmqRemoteApi/clients/python/", or can I somehow use it from an external project?

Re: Setup zmqRemoteApi

Posted: 04 Feb 2022, 06:50
by coppelia
Thanks for the typo fixes!

I unfortunately can't reproduce the problem on CoppeliaSim V4.2. Which platform are you running on?

You can also run scripts from a different folder, you just need to make sure the zmqRemoteApi module can be found, e.g. by setting the PYTHONPATH environment variable before running the script:

Code: Select all

#shell
$ export PYTHONPATH="path/to/module/folder"
$ python3 yourClient.py
Cheers