Fix visualize_motors_bus
This commit is contained in:
parent
6ccf083127
commit
9644e2b086
|
@ -31,22 +31,26 @@ def visualize_motors_bus(motors_bus: MotorsBus):
|
||||||
motors_bus.connect()
|
motors_bus.connect()
|
||||||
|
|
||||||
# Disable torque on all motors so you can move them freely by hand
|
# Disable torque on all motors so you can move them freely by hand
|
||||||
values_dict = {idx: 0 for idx in motors_bus.motor_ids}
|
for id_ in motors_bus.ids:
|
||||||
motors_bus.write("Torque_Enable", values_dict)
|
motors_bus.write("Torque_Enable", id_, 0)
|
||||||
|
|
||||||
print("Torque disabled on all joints.")
|
print("Torque disabled on all joints.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print("\nPress Ctrl+C to quit.\n")
|
print("\nPress Ctrl+C to quit.\n")
|
||||||
while True:
|
while True:
|
||||||
# Read *raw* positions (no calibration).
|
# Read *raw* positions (no calibration).
|
||||||
raw_positions = motors_bus.read("Present_Position")
|
start = time.perf_counter()
|
||||||
|
raw_positions = motors_bus.sync_read("Present_Position", raw_values=True)
|
||||||
|
read_s = time.perf_counter() - start
|
||||||
|
|
||||||
# # Read *already-homed* positions
|
# # Read *already-homed* positions
|
||||||
# homed_positions = motor_bus.read("Present_Position")
|
# homed_positions = motor_bus.read("Present_Position")
|
||||||
|
|
||||||
|
print(f"read_s: {read_s * 1e3:.2f}ms ({1 / read_s:.0f} Hz)")
|
||||||
for name, raw_ticks in raw_positions.items():
|
for name, raw_ticks in raw_positions.items():
|
||||||
idx = motors_bus.motors[name][0]
|
idx = motors_bus.motors[name].id
|
||||||
model = motors_bus.motors[name][1]
|
model = motors_bus.motors[name].model
|
||||||
|
|
||||||
# homed_val = homed_positions[i] # degrees or % if linear
|
# homed_val = homed_positions[i] # degrees or % if linear
|
||||||
|
|
||||||
|
@ -70,7 +74,7 @@ def visualize_motors_bus(motors_bus: MotorsBus):
|
||||||
f"INV_TICKS={inv_ticks:4d} "
|
f"INV_TICKS={inv_ticks:4d} "
|
||||||
)
|
)
|
||||||
print("----------------------------------------------------")
|
print("----------------------------------------------------")
|
||||||
time.sleep(0.25)
|
# time.sleep(0.25)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue