Remote API
The remote API is one of several ways an application can connect with CoppeliaSim. It allows communication between CoppeliaSim and an external application (i.e. an application running in a different process, or on a different machine), is cross-platform, and supports the exact same API function calls as from within a CoppeliaSim script. It comes in two distinct versions/frameworks:
The ZeroMQ remote API: with support of Python, C++, Matlab, Octave, Java and Lua clients.
The WebSocket remote API: with support of JavaScript clients.
As an example, a Python ZeroMQ remote API client receiving and applying back a vision sensor image could look like:
from time import sleep
from zmqRemoteApi import RemoteAPIClient
client = RemoteAPIClient('localhost',23000)
sim = client.getobject('sim')
sensor1Handle=sim.getObject('/VisionSensor')
sensor2Handle=sim.getObject('/PassiveVisionSensor')
sim.startSimulation()
while True:
image,resolution=sim.getVisionSensorImg(sensor1Handle)
sim.setVisionSensorImg(sensor2Handle,image)
sleep(0.01)
sim.stopSimulation()
(for backward compatibility, see here for the deprecated legacy remote API)
|