compas-rrc / compas_rrc

Online control for ABB robots over a simple-to-use Python interface.
https://compas-rrc.github.io/compas_rrc/
MIT License
22 stars 6 forks source link

Add the possibility to wait_for_robot to connect #7

Open gonzalocasas opened 3 years ago

gonzalocasas commented 3 years ago

Summary

As an RRC user, I want be able to send an instruction even before the robot has connected, and have the code wait until robot connection to execute it so that I can simplify the client code.

Details

Will this change the current API? How? One option would be to have a method abb.wait_for_robot() so that client code could be:

ros = RosClient()
ros.run()

abb = AbbClient(ros,'/')
abb.wait_for_robot()
current_pose = abb.send_and_wait(GetFrame())

Additionally, wait_for_robot could take a timeout parameter, but not raise exceptions if it's expired, just like the wait methods of threading.Event, eg:

ros = RosClient()
ros.run()

abb = AbbClient(ros,'/')

while True:
   if not abb.wait_for_robot(timeout=10):
      print('Robot not connected, will retry...')
      continue

   current_pose = abb.send_and_wait(GetFrame())