Here's how I'm currently handling it: Since ZMQ is not thread-safe, each thread has its own client. I manage communication between threads simply using global variables. Example:
Code: Select all
# python
from coppeliasim_zmqremoteapi_client import RemoteAPIClient
import threading
global currentGoal
def control_loop():
client = RemoteAPIClient()
sim = client.require('sim')
> getting handles
while True:
> starts control loop
> drive robot to currentGoal
def other_thread():
client = RemoteAPIClient()
sim = client.require('sim')
> getting handles
while True:
> do something
if __name__ == '__main__':
client = RemoteAPIClient()
sim = client.require('sim')
> getting handles
> starts threads
while True:
> update currentGoal