Troxid / vrep-api-python

Simple for use Python binding for Coppelia Robotics V-REP simulator (remote API)
GNU General Public License v2.0
29 stars 10 forks source link

Connecting to server #3

Open psychemedia opened 7 years ago

psychemedia commented 7 years ago

Trying to connect to the server using with VRep.connect(domain, 19997) as api:, the connection works if I use domain="127.0.0.1" but fails if I use an alias such as domain="localhost" or domain="mydomain":

---------------------------------------------------------------------------
ReturnCommandError                        Traceback (most recent call last)
<ipython-input-7-90f793041880> in <module>()
     31 
     32 
---> 33 with VRep.connect("localhost", 19997) as api:
     34     r = lineFollower(api)
     35     r.fwd_right()

/usr/local/lib/python3.5/dist-packages/pyrep/api.py in connect(ip, port)
     26             return VRepApi(res)
     27         else:
---> 28             raise ReturnCommandError(res)
     29 
     30     def close_connection(self):

ReturnCommandError: Undefined return code: -1
Troxid commented 7 years ago

Hello @psychemedia. This binding is based on the official remote v-rep api. Method VRep.connect just call simxStart. The exception in you case was occur because simxStart return -1 code ( ReturnCommandError: Undefined return code: -1) The documentation say, that function can return -1 code if

the connection to the server was not possible (i.e. a timeout was reached)

I tried to connect to the simulator, which work on my laptop in my local network and all works fine. Check reachability of your domain (port forwarding, dns and etc).
If you are sure, that all is fine on your side, you can report about this error directly to the coppeliarobotics forum.

psychemedia commented 7 years ago

Hmm... okay.. I was trying to connect to the server from a Jupyter notebook running inside the same VM as the simulator (VM build file here: https://github.com/psychemedia/ou-robotics-vrep/tree/master/robotVM ), albeit with the notebook accessed via a browser on host (but I think the addressing should all be relative to the insides of the VM).

Troxid commented 7 years ago

It's very strange behavior. I will check it later.