unitree_sdk2_python_offer/unitree_sdk2py/test/helloworld/subscriber.py
2025-07-08 17:29:02 +08:00

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()