Skip to content

Commit 0d86c54

Browse files
committed
upload motion_switcher_example and update MotionSwitcherClient class
1 parent 21e44b7 commit 0d86c54

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import time
2+
import sys
3+
4+
from unitree_sdk2py.core.channel import ChannelFactoryInitialize
5+
from unitree_sdk2py.comm.motion_switcher.motion_switcher_client import MotionSwitcherClient
6+
7+
8+
class Custom:
9+
def __init__(self):
10+
self.msc = MotionSwitcherClient()
11+
self.msc.SetTimeout(5.0)
12+
self.msc.Init()
13+
14+
def selectMode(self,name):
15+
ret = self.msc.SelectMode(name)
16+
return ret
17+
18+
19+
if __name__ == '__main__':
20+
21+
print("WARNING: Please ensure there are no obstacles around the robot while running this example.")
22+
input("Press Enter to continue...")
23+
24+
if len(sys.argv)>1:
25+
ChannelFactoryInitialize(0, sys.argv[1])
26+
else:
27+
ChannelFactoryInitialize(0)
28+
29+
custom = Custom()
30+
selectMode = "ai"
31+
# selectMode = "normal"
32+
# selectMode = "advanced"
33+
# selectMode = "ai-w" # for wheeled robot
34+
ret = custom.selectMode(selectMode)
35+
print("ret: ",ret)
36+

unitree_sdk2py/comm/motion_switcher/motion_switcher_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ def CheckMode(self):
3232
else:
3333
return code, None
3434

35+
# 1002
36+
def SelectMode(self, nameOrAlias):
37+
p = {}
38+
p["name"] = nameOrAlias
39+
parameter = json.dumps(p)
40+
code, data = self._Call(MOTION_SWITCHER_API_ID_SELECT_MODE, parameter)
41+
42+
return code, None
43+
3544
# 1003
3645
def ReleaseMode(self):
3746
p = {}

0 commit comments

Comments
 (0)