upload motion_switcher_example and update MotionSwitcherClient class
This commit is contained in:
parent
21e44b7c4c
commit
0d86c54625
|
@ -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)
|
||||||
|
|
|
@ -32,6 +32,15 @@ class MotionSwitcherClient(Client):
|
||||||
else:
|
else:
|
||||||
return code, None
|
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
|
# 1003
|
||||||
def ReleaseMode(self):
|
def ReleaseMode(self):
|
||||||
p = {}
|
p = {}
|
||||||
|
|
Loading…
Reference in New Issue