unitree_sdk2_python/unitree_sdk2py/test/helloworld/subscriber.py

19 lines
373 B
Python

import time
from unitree_sdk2py.core.channel import ChannelSubscriber, ChannelFactoryInitialize
from helloworld import HelloWorld
ChannelFactoryInitialize()
sub = ChannelSubscriber("topic", HelloWorld)
sub.Init()
while True:
msg = sub.Read()
if msg is None:
print("subscribe error.")
else:
print("subscribe success. msg:", msg)
pub.Close()