Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/lerobot/robots/so_follower/so_follower.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,26 @@ def calibrate(self) -> None:
self.bus.write("Operating_Mode", motor, OperatingMode.POSITION.value)

input(f"Move {self} to the middle of its range of motion and press ENTER....")
homing_offsets = self.bus.set_half_turn_homings()

# Attempt to call record_ranges_of_motion with a reduced motor set when appropriate.
full_turn_motor = "wrist_roll"
unknown_range_motors = [motor for motor in self.bus.motors if motor != full_turn_motor]

current_pos = self.bus.read("Present_Position", full_turn_motor, normalize=False)
if isinstance(current_pos, dict):
current_pos = current_pos[full_turn_motor]

other_motors = [motor for motor in self.bus.motors if motor != full_turn_motor]
homing_offsets = self.bus.set_half_turn_homings(other_motors)
homing_offsets[full_turn_motor] = 0

unknown_range_motors = other_motors
print(
f"Move all joints except '{full_turn_motor}' sequentially through their "
"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[full_turn_motor] = 0
range_maxes[full_turn_motor] = 4095
safe_delta = min(current_pos - 0, 4095 - current_pos, 2048)
range_mins[full_turn_motor] = current_pos - safe_delta
range_maxes[full_turn_motor] = current_pos + safe_delta

self.calibration = {}
for motor, m in self.bus.motors.items():
Expand Down
17 changes: 13 additions & 4 deletions src/lerobot/teleoperators/so_leader/so_leader.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,26 @@ def calibrate(self) -> None:
self.bus.write("Operating_Mode", motor, OperatingMode.POSITION.value)

input(f"Move {self} to the middle of its range of motion and press ENTER....")
homing_offsets = self.bus.set_half_turn_homings()

full_turn_motor = "wrist_roll"
unknown_range_motors = [motor for motor in self.bus.motors if motor != full_turn_motor]

current_pos = self.bus.read("Present_Position", full_turn_motor, normalize=False)
if isinstance(current_pos, dict):
current_pos = current_pos[full_turn_motor]

other_motors = [motor for motor in self.bus.motors if motor != full_turn_motor]
homing_offsets = self.bus.set_half_turn_homings(other_motors)
homing_offsets[full_turn_motor] = 0

unknown_range_motors = other_motors
print(
f"Move all joints except '{full_turn_motor}' sequentially through their "
"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[full_turn_motor] = 0
range_maxes[full_turn_motor] = 4095
safe_delta = min(current_pos - 0, 4095 - current_pos, 2048)
range_mins[full_turn_motor] = current_pos - safe_delta
range_maxes[full_turn_motor] = current_pos + safe_delta

self.calibration = {}
for motor, m in self.bus.motors.items():
Expand Down