unitree_sdk2_python/unitree_sdk2py/test/helloworld/subscriber.py

19 lines
375 B
Python
Raw Normal View History

2024-04-26 21:26:50 +08:00
import time
from unitree_sdk2py.core.channel import ChannelSubscriber, ChannelFactortyInitialize
from helloworld import HelloWorld
ChannelFactortyInitialize()
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()