Skip to content

Commit a003e7c

Browse files
change wheel setup in kinematics (#811)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a274110 commit a003e7c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

lerobot/common/robot_devices/robots/mobile_manipulator.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,19 @@ def teleop_step(
392392
for name in self.leader_arms:
393393
pos = self.leader_arms[name].read("Present_Position")
394394
pos_tensor = torch.from_numpy(pos).float()
395-
# Instead of pos_tensor.item(), use tolist() to convert the entire tensor to a list
396395
arm_positions.extend(pos_tensor.tolist())
397396

398-
# (The rest of your code for generating wheel commands remains unchanged)
399-
x_cmd = 0.0 # m/s forward/backward
400-
y_cmd = 0.0 # m/s lateral
397+
y_cmd = 0.0 # m/s forward/backward
398+
x_cmd = 0.0 # m/s lateral
401399
theta_cmd = 0.0 # deg/s rotation
402400
if self.pressed_keys["forward"]:
403-
x_cmd += xy_speed
401+
y_cmd += xy_speed
404402
if self.pressed_keys["backward"]:
405-
x_cmd -= xy_speed
403+
y_cmd -= xy_speed
406404
if self.pressed_keys["left"]:
407-
y_cmd += xy_speed
405+
x_cmd += xy_speed
408406
if self.pressed_keys["right"]:
409-
y_cmd -= xy_speed
407+
x_cmd -= xy_speed
410408
if self.pressed_keys["rotate_left"]:
411409
theta_cmd += theta_speed
412410
if self.pressed_keys["rotate_right"]:
@@ -584,8 +582,8 @@ def body_to_wheel_raw(
584582
# Create the body velocity vector [x, y, theta_rad].
585583
velocity_vector = np.array([x_cmd, y_cmd, theta_rad])
586584

587-
# Define the wheel mounting angles with a -90° offset.
588-
angles = np.radians(np.array([240, 120, 0]) - 90)
585+
# Define the wheel mounting angles (defined from y axis cw)
586+
angles = np.radians(np.array([300, 180, 60]))
589587
# Build the kinematic matrix: each row maps body velocities to a wheel’s linear speed.
590588
# The third column (base_radius) accounts for the effect of rotation.
591589
m = np.array([[np.cos(a), np.sin(a), base_radius] for a in angles])
@@ -641,8 +639,8 @@ def wheel_raw_to_body(
641639
# Compute each wheel’s linear speed (m/s) from its angular speed.
642640
wheel_linear_speeds = wheel_radps * wheel_radius
643641

644-
# Define the wheel mounting angles with a -90° offset.
645-
angles = np.radians(np.array([240, 120, 0]) - 90)
642+
# Define the wheel mounting angles (defined from y axis cw)
643+
angles = np.radians(np.array([300, 180, 60]))
646644
m = np.array([[np.cos(a), np.sin(a), base_radius] for a in angles])
647645

648646
# Solve the inverse kinematics: body_velocity = M⁻¹ · wheel_linear_speeds.

0 commit comments

Comments
 (0)