-
Notifications
You must be signed in to change notification settings - Fork 14
/
zero.py
executable file
·49 lines (37 loc) · 1.13 KB
/
zero.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
import sys
import os
import re
from utils import *
print("retrieving robot's name throught rhio...")
ip: str = "10.0.0.1" if len(sys.argv) == 1 else sys.argv[1]
hostname: str = rhio_get_value(ip, "/server/hostname")
print(ip,hostname)
motors=["hip_pitch","hip_yaw","hip_roll","knee","ankle_pitch","ankle_roll"]
def print_zero(sides):
for side in sides:
for m in motors:
print(rhio(ip, f"/lowlevel/{side}_{m}/position"))
# setting parameters to zero
def update_zero(sides):
for side in sides:
for m in motors:
rhio(ip, f"/lowlevel/{side}_{m}/parameters/zero=0")
for side in sides:
for m in motors:
p=rhio(ip, f"/lowlevel/{side}_{m}/position").split('=')[1]
rhio(ip, f"/lowlevel/{side}_{m}/parameters/zero={p}")
def save_zero():
rhio(ip,"rhalSaveConf rhal.json")
sides=["left","right"]
while True:
a=input("(p)rint/(u)pdate/(s)ave/(q)uit?")
a=a.strip()
if a=="p":
print_zero(sides)
elif a=="u":
update_zero(sides)
elif a=="s":
save_zero()
elif a=="q":
sys.exit(1)