Skip to content

Commit a035ade

Browse files
authored
Merge pull request unitreerobotics#120 from wjbbupt/master
feat(go2): add some new supported go2 obstacles avoid APIs,
2 parents 18b9ef8 + a6074e8 commit a035ade

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

example/obstacles_avoid/obstacles_avoid_move.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
time.sleep(1.0) # move 1s
2828
client.Move(0.0, 0.0, 0.0)
2929
client.UseRemoteCommandFromApi(False)
30+
time.sleep(1.0)
31+
client.MoveToAbsolutePosition(0.0, 0.0, 0.0)
32+
client.MoveToIncrementPosition(0.0, 0.0, 0.0)
3033

3134
except KeyboardInterrupt:
3235
client.Move(0.0, 0.0, 0.0)

unitree_sdk2py/go2/obstacles_avoid/obstacles_avoid_client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,24 @@ def UseRemoteCommandFromApi(self, isRemoteCommandsFromApi: bool):
5757
p["is_remote_commands_from_api"] = isRemoteCommandsFromApi
5858
parameter = json.dumps(p)
5959
code, data = self._Call(OBSTACLES_AVOID_API_ID_USE_REMOTE_COMMAND_FROM_API, parameter)
60+
return code
61+
62+
def MoveToAbsolutePosition(self, vx: float, vy: float, vyaw: float):
63+
p = {}
64+
p["x"] = vx
65+
p["y"] = vy
66+
p["yaw"] = vyaw
67+
p["mode"] = 2
68+
parameter = json.dumps(p)
69+
code = self._CallNoReply(OBSTACLES_AVOID_API_ID_MOVE, parameter)
70+
return code
71+
72+
def MoveToIncrementPosition(self, vx: float, vy: float, vyaw: float):
73+
p = {}
74+
p["x"] = vx
75+
p["y"] = vy
76+
p["yaw"] = vyaw
77+
p["mode"] = 1
78+
parameter = json.dumps(p)
79+
code = self._CallNoReply(OBSTACLES_AVOID_API_ID_MOVE, parameter)
6080
return code

0 commit comments

Comments
 (0)