File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import time
2+ import sys
3+
4+ from unitree_sdk2py .core .channel import ChannelPublisher , ChannelFactoryInitialize
5+ from unitree_sdk2py .core .channel import ChannelSubscriber , ChannelFactoryInitialize
6+ from unitree_sdk2py .idl .std_msgs .msg .dds_ import String_
7+ from unitree_sdk2py .idl .default import std_msgs_msg_dds__String_
8+
9+ class Custom :
10+ def __init__ (self ):
11+ # create publisher #
12+ self .publisher = ChannelPublisher ("rt/utlidar/switch" , String_ )
13+ self .publisher .Init ()
14+ self .low_cmd = std_msgs_msg_dds__String_ ()
15+
16+ def go2_utlidar_switch (self ,status ):
17+ if status == "OFF" :
18+ self .low_cmd .data = "OFF"
19+ elif status == "ON" :
20+ self .low_cmd .data = "ON"
21+
22+ self .publisher .Write (self .low_cmd )
23+
24+
25+ if __name__ == '__main__' :
26+
27+ print ("WARNING: Please ensure there are no obstacles around the robot while running this example." )
28+ input ("Press Enter to continue..." )
29+
30+ if len (sys .argv )> 1 :
31+ ChannelFactoryInitialize (0 , sys .argv [1 ])
32+ else :
33+ ChannelFactoryInitialize (0 )
34+
35+ custom = Custom ()
36+ custom .go2_utlidar_switch ("OFF" )
37+
38+
39+
You can’t perform that action at this time.
0 commit comments