update server_v2

This commit is contained in:
wwj718 2020-04-06 21:38:14 +08:00
parent 74cc41d5f1
commit 93bbaad4c2
3 changed files with 11 additions and 4 deletions

View File

@ -13,7 +13,7 @@ from codelab_adapter_client import AdapterNode
class HCINode(AdapterNode):
'''
Everything Is Message
ref: https://github.com/Scratch3Lab/codelab_adapter_extensions/blob/master/extensions_v2/extension_python_kernel.py
ref: https://github.com/CodeLabClub/codelab_adapter_extensions/blob/master/extensions_v2/extension_python_kernel.py
'''
def __init__(self):

View File

@ -26,6 +26,7 @@ class CozmoNode(AdapterNode):
self.terminate()
def cozmo_program(self, robot):
self.pub_notification("Vector Connected!", type="SUCCESS")
while self._running:
time.sleep(0.05)
if not self.q.empty():
@ -54,5 +55,6 @@ if __name__ == "__main__":
node = CozmoNode()
node.receive_loop_as_thread()
node.run()
except KeyboardInterrupt:
except Exception as e:
node.logger.error(str(e))
node.terminate()

View File

@ -14,7 +14,9 @@ from codelab_adapter_client import AdapterNode
class VectorNode(AdapterNode):
'''
Everything Is Message
ref: https://github.com/Scratch3Lab/codelab_adapter_extensions/blob/master/extensions_v2/extension_python_kernel.py
ref: https://github.com/CodeLabClub/codelab_adapter_extensions/blob/master/extensions_v2/extension_python_kernel.py
node pub it's status: pid
'''
def __init__(self):
@ -33,6 +35,7 @@ class VectorNode(AdapterNode):
def run(self):
with anki_vector.Robot() as robot:
self.pub_notification("Vector Connected!", type="SUCCESS")
while self._running:
time.sleep(0.05)
if not self.q.empty():
@ -60,5 +63,7 @@ if __name__ == "__main__":
node.receive_loop_as_thread(
) # run extension_message_handle, noblock(threaded)
node.run()
except KeyboardInterrupt:
# except KeyboardInterrupt:
except Exception as e:
node.logger.error(str(e))
node.terminate() # Clean up before exiting.