Arm fixes and add config
This commit is contained in:
@@ -100,7 +100,7 @@ class HopeJrArm(Robot):
|
|||||||
if self.is_connected:
|
if self.is_connected:
|
||||||
raise DeviceAlreadyConnectedError(f"{self} already connected")
|
raise DeviceAlreadyConnectedError(f"{self} already connected")
|
||||||
|
|
||||||
self.bus.connect()
|
self.bus.connect(handshake=False)
|
||||||
if not self.is_calibrated:
|
if not self.is_calibrated:
|
||||||
self.calibrate()
|
self.calibrate()
|
||||||
|
|
||||||
@@ -121,21 +121,20 @@ class HopeJrArm(Robot):
|
|||||||
for motor in self.bus.motors:
|
for motor in self.bus.motors:
|
||||||
self.bus.write("Operating_Mode", motor, OperatingMode.POSITION.value)
|
self.bus.write("Operating_Mode", motor, OperatingMode.POSITION.value)
|
||||||
|
|
||||||
full_turn_motor = self.shoulder_pitch
|
|
||||||
unknown_range_motors = self.other_motors
|
unknown_range_motors = self.other_motors
|
||||||
|
|
||||||
input("Move arm to the middle of its range of motion and press ENTER....")
|
input("Move arm to the middle of its range of motion and press ENTER....")
|
||||||
homing_offsets_full_turn = self.bus.set_half_turn_homings(full_turn_motor)
|
homing_offsets_full_turn = self.bus.set_half_turn_homings(self.shoulder_pitch)
|
||||||
homing_offsets_unknown_range = self.bus.set_half_turn_homings(unknown_range_motors)
|
homing_offsets_unknown_range = self.bus.set_half_turn_homings(unknown_range_motors)
|
||||||
homing_offsets = {**homing_offsets_full_turn, **homing_offsets_unknown_range}
|
homing_offsets = {**homing_offsets_full_turn, **homing_offsets_unknown_range}
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Move all joints except '{full_turn_motor}' sequentially through their "
|
f"Move all joints except '{self.shoulder_pitch}' sequentially through their "
|
||||||
"entire ranges of motion.\nRecording positions. Press ENTER to stop..."
|
"entire ranges of motion.\nRecording positions. Press ENTER to stop..."
|
||||||
)
|
)
|
||||||
range_mins, range_maxes = self.bus.record_ranges_of_motion(unknown_range_motors)
|
range_mins, range_maxes = self.bus.record_ranges_of_motion(unknown_range_motors)
|
||||||
range_mins[full_turn_motor] = 0
|
range_mins[self.shoulder_pitch] = 1024
|
||||||
range_maxes[full_turn_motor] = 4095
|
range_maxes[self.shoulder_pitch] = 3071
|
||||||
|
|
||||||
self.calibration = {}
|
self.calibration = {}
|
||||||
for motor, m in self.bus.motors.items():
|
for motor, m in self.bus.motors.items():
|
||||||
@@ -153,8 +152,10 @@ class HopeJrArm(Robot):
|
|||||||
|
|
||||||
def configure(self) -> None:
|
def configure(self) -> None:
|
||||||
with self.bus.torque_disabled():
|
with self.bus.torque_disabled():
|
||||||
self.bus.configure_motors()
|
for motor in self.bus.motors:
|
||||||
# TODO
|
self.bus.write("Return_Delay_Time", motor, 0)
|
||||||
|
self.bus.write("Maximum_Acceleration", motor, 50)
|
||||||
|
self.bus.write("Acceleration", motor, 50)
|
||||||
|
|
||||||
def setup_motors(self) -> None:
|
def setup_motors(self) -> None:
|
||||||
for motor in reversed(self.bus.motors):
|
for motor in reversed(self.bus.motors):
|
||||||
|
|||||||
Reference in New Issue
Block a user