upload motion_switcher_example and update MotionSwitcherClient class

This commit is contained in:
xiaoliangstd 2025-01-02 21:37:07 +08:00
parent 21e44b7c4c
commit 0d86c54625
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,36 @@
import time
import sys
from unitree_sdk2py.core.channel import ChannelFactoryInitialize
from unitree_sdk2py.comm.motion_switcher.motion_switcher_client import MotionSwitcherClient
class Custom:
def __init__(self):
self.msc = MotionSwitcherClient()
self.msc.SetTimeout(5.0)
self.msc.Init()
def selectMode(self,name):
ret = self.msc.SelectMode(name)
return ret
if __name__ == '__main__':
print("WARNING: Please ensure there are no obstacles around the robot while running this example.")
input("Press Enter to continue...")
if len(sys.argv)>1:
ChannelFactoryInitialize(0, sys.argv[1])
else:
ChannelFactoryInitialize(0)
custom = Custom()
selectMode = "ai"
# selectMode = "normal"
# selectMode = "advanced"
# selectMode = "ai-w" # for wheeled robot
ret = custom.selectMode(selectMode)
print("ret: ",ret)

View File

@ -32,6 +32,15 @@ class MotionSwitcherClient(Client):
else:
return code, None
# 1002
def SelectMode(self, nameOrAlias):
p = {}
p["name"] = nameOrAlias
parameter = json.dumps(p)
code, data = self._Call(MOTION_SWITCHER_API_ID_SELECT_MODE, parameter)
return code, None
# 1003
def ReleaseMode(self):
p = {}