-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path馬達0校準.txt
37 lines (33 loc) · 1.03 KB
/
馬達0校準.txt
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
import odrive
import time
motor_calibration_time = 10
encoder_calibration_time = 15
input("請確保電機沒有附載,不要試圖用手去碰輪子以免受傷")
print("Searching for ODrive...")
odrv0 = odrive.find_any()
print("Odrive detected!")
print("馬達即將運轉")
odrv0.axis0.requested_state = 4
time.sleep(motor_calibration_time)
if odrv0.axis0.motor.is_calibrated == 1 and odrv0.axis0.motor.is_calibrated == 1:
print("馬達驅動成功!")
else:
print("錯誤!檢查配置")
quit()
print("Saving motor calibration")
odrv0.axis0.motor.config.pre_calibrated = True
odrv0.axis0.requested_state = 7
time.sleep(encoder_calibration_time)
if odrv0.axis0.encoder.is_ready == 1 and odrv0.axis0.encoder.is_ready == 1:
print("編碼器校準成功!")
else:
print("錯誤!檢查配置")
quit()
print("儲存當前配置")
odrv0.axis0.encoder.config.pre_calibrated = True
print("Reboot! it may take some time")
odrv0.save_configuration()
try:
odrv0.reboot()
except:
print("馬達0校準完成")