B0-based remote API modus operandi

BlueZero is deprecated. We highly recommend using the ZeroMQ remote API instead.

A B0-based remote API function is called in a similar fashion as a regular API function, however with one major difference:

Most B0-based remote API functions require one additional argument: the topic or communication channel to use for executing the function call. The topic can be the return value of one of following 5 functions:

  • simxServiceCall: this topic allows to execute the function in a blocking mode, i.e. the command will travel to the server (i.e. CoppeliaSim), execute there, and return a response to the client. Use this topic only when fetching command responses from the server as a one-time operation (e.g. simxGetObjectHandle would typically use a service call to execute).
  • simxDefaultPublisher: this topic allows to execute the function in a non-blocking mode, i.e. the function is sent to the server (i.e. CoppeliaSim), and control returns immediately to the client (i.e. the client will not wait for a reply from the server). Use this topic only when sending commands to the server, where you do not expect/need a response from it (e.g. simxSetJointPosition would typically use the default publisher to execute).
  • simxDefaultSubscriber: this topic informs the server to continuously execute the function, and continuously stream the response to the client. The client will be receiving the response inside of a callback function. Use this topic only when you want to receive the response from the same command continuously executed on the server side. (e.g. simxGetJointForce would typically use the default subscriber to execute). Defined callback functions are called via the simxSpinOnce function (when a response is available in the input buffer).
  • simxCreatePublisher: this is very similar to simxDefaultPublisher, with the difference, that a dedicated publisher topic is created, i.e. a dedicated publishing channel is created. It can be useful to assign specific functions/commands to a dedicated publisher, specially with heavy data (e.g. simxSetVisionSensorImage would typically use a dedicated publisher to execute).
  • simxCreateSubscriber: this is very similar to simxDefaultSubscriber, with the difference, that a dedicated subscriber topic is created, i.e. a dedicated subscriber channel is created. It can be useful to assign specific functions/commands to a dedicated subscriber, specially with heavy data (e.g. simxGetVisionSensorImage would typically use a dedicated subscriber to execute).

  • By default, the B0-based remote API client and the server (i.e. CoppeliaSim) will run asynchronously. It is however possible to have the client trigger each simulation step individually, in order to achieve a synchronous operation. Following is a Python example of the stepping mode:

    import b0RemoteApi import time with b0RemoteApi.RemoteApiClient('b0RemoteApi_pythonClient','b0RemoteApi') as client: doNextStep=True def simulationStepStarted(msg): simTime=msg[1][b'simulationTime']; print('Simulation step started. Simulation time: ',simTime) def simulationStepDone(msg): simTime=msg[1][b'simulationTime']; print('Simulation step done. Simulation time: ',simTime); global doNextStep doNextStep=True client.simxSynchronous(True) client.simxGetSimulationStepStarted(client.simxDefaultSubscriber(simulationStepStarted)); client.simxGetSimulationStepDone(client.simxDefaultSubscriber(simulationStepDone)); client.simxStartSimulation(client.simxDefaultPublisher()) startTime=time.time() while time.time()<startTime+5: if doNextStep: doNextStep=False client.simxSynchronousTrigger() client.simxSpinOnce() client.simxStopSimulation(client.simxDefaultPublisher())