- Ubuntu 22.04
- CoppeliaSim v4.5.1 (rev4)
- ZmQRemoteApi
I launch 5 programs simultaneously in headless mode like:
Code: Select all
coppeliaSim.sh -GzmqRemoteApi.rpcPort=port -h -gnamespace model_path
I'm using ROS2 in each of my program, so I gave my node namespace to the simulation with the -g argument.
All of the programs are launched following this type of code below. One thread for the ROS node, one thread to communicate with the simulator API.
Code: Select all
rclpy.init(args=args)
simulator_node = simx()
executor = MultiThreadedExecutor()
executor.add_node(simulator_node)
# Start the ROS2 node on a separate thread
# thread = Thread(target=spin_node,args=(executor,)) # communinication not working if doing like that
thread = Thread(target=executor.spin)
# Let the app running on the main thread
try:
thread.start()
simulator_node.get_logger().info("Spinned ROS2 Node . . .")
simulator_node.exec()
except SystemExit as e:
rclpy.logging.get_logger("Quitting").error(
"Error happened of type: {}\n msg: {} \nEnd of testing grasp!".format(
type(e), e
)
)
except KeyboardInterrupt:
rclpy.logging.get_logger("Quitting").info("End of testing grasp!")
finally:
simulator_node.get_logger().info("Shutting down ROS2 Node . . .")
simulator_node.destroy_node()
executor.shutdown()
try:
thread.join()
except KeyboardInterrupt:
pass
I created a service that is called every 30sec to check if the server is UP:
Code: Select all
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
open = sock.connect_ex((SimCheckerService.ip,request.port))
Have you already seen something like that ? Or am I using the Remote Api in a wrong manner ?