DEV Community

Takeo
Takeo

Posted on

Trying VLA (Part 5): Setting Up and Testing a SpaceMouse

In the previous article, I explained how to teleoperate the SO-101 using regular Python commands and verify that the robot moves correctly.

However, collecting demonstration data for imitation learning using this method would be quite difficult.

Since the next goal is to collect data for imitation learning through teleoperation, I would like to try using a SpaceMouse as the teleoperation device.

A common approach is to use a Leader Arm with the same configuration as the Follower Arm. However, I had heard that operating and holding the Leader Arm during teleoperation can sometimes be difficult because of torque and mechanical resistance.

So, instead of starting with a Leader Arm, I decided to try a SpaceMouse first.

The SpaceMouse can also be used via Bluetooth, but for this test I will connect it via USB.

First, let's check the connection and make sure the device is recognized.

$ source ~/pyenv/lerobot/bin/activate
(lerobot)$ lsusb | grep -i -E "3dconnexion|spacemouse"
Bus 001 Device 005: ID 256f:c63a 3Dconnexion SpaceMouse Wireless BT

(lerobot)$ ls -l /dev/hidraw*
crw------- 1 root root 240, 0 Jul 28 08:04 /dev/hidraw0
crw------- 1 root root 240, 1 Sep  3 12:05 /dev/hidraw1
Enter fullscreen mode Exit fullscreen mode

Next, install the required packages for the SpaceMouse.

(lerobot)$ sudo apt install -y libhidapi-hidraw0 libhidapi-dev
(lerobot)$ pip install lerobot-teleoperator-spacemouse
Enter fullscreen mode Exit fullscreen mode

Then configure the permissions.

(lerobot)$ sudo tee /etc/udev/rules.d/99-spacemouse.rules >/dev/null <<'EOF'
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="256f", ATTRS{idProduct}=="c63a", MODE:="0660", GROUP:="plugdev"
EOF

(lerobot)$ sudo usermod -aG plugdev "$USER"
(lerobot)$ sudo udevadm control --reload-rules
(lerobot)$ sudo udevadm trigger
Enter fullscreen mode Exit fullscreen mode

After that, proceed with the following steps:

  • Disconnect the SpaceMouse USB cable
  • Reconnect the SpaceMouse
  • If you are setting it up through SSH, disconnect the current SSH session
  • If you are using SSH, reconnect to the machine
  • Activate the lerobot virtual environment
  • Run the following command
(lerobot)$ lerobot-teleoperator-spacemouse-test
Enter fullscreen mode Exit fullscreen mode

If you encounter a runtime error on a CPU-only machine, explicitly install the CPU version of torchvision.

(lerobot)$ pip uninstall -y torchvision

(lerobot)$ pip install --no-deps \
  torchvision==0.26.0 \
  --index-url https://download.pytorch.org/whl/cpu
Enter fullscreen mode Exit fullscreen mode

Then run the test command again.

(lerobot)$ lerobot-teleoperator-spacemouse-test
Enter fullscreen mode Exit fullscreen mode

If there are no errors and you see output similar to the following, the SpaceMouse is being detected correctly.

Detected devices: ['SpaceMouseWirelessNew', 'SpaceMouseWirelessNew', 'SpaceMouseWirelessNew']
SpaceMouseWirelessNew found
SpaceMouseState(t=-1.0, x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
SpaceMouseState(t=-1.0, x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
SpaceMouseState(t=-1.0, x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
SpaceMouseState(t=-1.0, x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
SpaceMouseState(t=-1.0, x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
SpaceMouseState(t=-1.0, x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
SpaceMouseState(t=-1.0, x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Press Ctrl+C to stop the test.

Next, I will test the six SpaceMouse motions individually.

It is possible to test all six motions in a single run, but I decided to record each motion in a separate log file so that it is easier to verify whether each SpaceMouse axis is working correctly.

Run each command below one at a time. After completing the corresponding motion, press Ctrl+C to stop the process.

Because the output is redirected to a log file using >, nothing may appear on the terminal while the test is running. This is expected.

1. Forward and Backward Horizontal Movement

(lerobot)$ lerobot-teleoperator-spacemouse-test > 01_forward_back.log
Enter fullscreen mode Exit fullscreen mode

Then perform the following sequence:

  • Push the knob forward horizontally and hold it for about one second
  • Return it to the center and hold for about one second
  • Pull the knob backward horizontally and hold it for about one second
  • Return it to the center
  • Press Ctrl+C

2. Left and Right Horizontal Movement

(lerobot)$ lerobot-teleoperator-spacemouse-test > 02_left_right.log
Enter fullscreen mode Exit fullscreen mode

Then:

  • Push the knob to the left and hold it for about one second
  • Return it to the center and hold for about one second
  • Push the knob to the right and hold it for about one second
  • Return it to the center
  • Press Ctrl+C

3. Up and Down Movement

(lerobot)$ lerobot-teleoperator-spacemouse-test > 03_up_down.log
Enter fullscreen mode Exit fullscreen mode

Then:

  • Pull the knob upward and hold it for about one second
  • Return it to the center and hold for about one second
  • Push the knob downward and hold it for about one second
  • Return it to the center
  • Press Ctrl+C

4. Forward and Backward Tilt (Pitch)

(lerobot)$ lerobot-teleoperator-spacemouse-test > 04_pitch.log
Enter fullscreen mode Exit fullscreen mode

Then:

  • Tilt the knob forward and hold it for about one second
  • Return it to the center and hold for about one second
  • Tilt the knob backward and hold it for about one second
  • Return it to the center
  • Press Ctrl+C

5. Left and Right Tilt (Roll)

(lerobot)$ lerobot-teleoperator-spacemouse-test > 05_roll.log
Enter fullscreen mode Exit fullscreen mode

Then:

  • Tilt the knob to the left and hold it for about one second
  • Return it to the center and hold for about one second
  • Tilt the knob to the right and hold it for about one second
  • Return it to the center
  • Press Ctrl+C

6. Horizontal Left and Right Twist (Yaw)

(lerobot)$ lerobot-teleoperator-spacemouse-test > 06_yaw.log
Enter fullscreen mode Exit fullscreen mode

Then:

  • Twist the knob horizontally to the left and hold it for about one second
  • Return it to the center and hold for about one second
  • Twist the knob horizontally to the right and hold it for about one second
  • Return it to the center
  • Press Ctrl+C

Checking the Log Files

Since each motion was recorded in a separate log file, let's look at which values should change for each operation.

The main values reported by the SpaceMouse are:

x
y
z
roll
pitch
yaw
Enter fullscreen mode Exit fullscreen mode

When manually operating the SpaceMouse, small values may also appear on axes other than the one you intended to move.

This is normal.

The important point is that the main axis associated with the intended motion changes significantly, and the sign changes when the SpaceMouse is moved in the opposite direction.

1. Forward and Backward Horizontal Movement

Push Forward Horizontally

SpaceMouseState(x=0.0, y=1.0, z=-0.246..., roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

y = 1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is pushed forward horizontally, y changes significantly in the positive direction. This confirms that the forward input is being detected correctly.

Pull Backward Horizontally

SpaceMouseState(x=0.0, y=-1.0, z=-0.410..., roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

y = -1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is pulled backward horizontally, y changes significantly in the negative direction. This confirms that the backward input is also being detected correctly.

2. Left and Right Horizontal Movement

Push Left Horizontally

SpaceMouseState(x=-0.794..., y=0.0, z=0.0, roll=0.034..., pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

x = -0.794...
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is pushed to the left, x changes significantly in the negative direction. This confirms that the left input is working correctly.

Push Right Horizontally

SpaceMouseState(x=1.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

x = 1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is pushed to the right, x changes strongly in the positive direction. This confirms that the right input is working correctly.

3. Up and Down Movement

Pull Up

SpaceMouseState(x=0.0, y=0.0, z=1.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

z = 1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is pulled upward, z changes to the positive direction. This confirms that the upward input is working correctly.

Push Down

SpaceMouseState(x=0.0, y=0.0, z=-1.0, roll=0.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

z = -1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is pushed downward, z changes to the negative direction. This confirms that the downward input is working correctly.

4. Forward and Backward Tilt (Pitch)

Tilt Forward

SpaceMouseState(x=0.0, y=0.0, z=0.0, roll=0.0, pitch=1.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

pitch = 1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is tilted forward, pitch changes significantly in the positive direction. This confirms that the forward pitch input is detected correctly.

Tilt Backward

SpaceMouseState(x=0.0, y=0.0, z=0.0, roll=0.0, pitch=-1.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

pitch = -1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is tilted backward, pitch changes significantly in the negative direction. This confirms that the backward pitch input is also working correctly.

5. Left and Right Tilt (Roll)

Tilt Left

SpaceMouseState(x=0.0, y=0.0, z=0.0, roll=-1.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

roll = -1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is tilted to the left, roll changes significantly in the negative direction. This confirms that the left roll input is working correctly.

Tilt Right

SpaceMouseState(x=0.0, y=0.0, z=0.0, roll=1.0, pitch=0.0, yaw=0.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

roll = 1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is tilted to the right, roll changes significantly in the positive direction. This confirms that the right roll input is working correctly.

6. Left and Right Twist (Yaw)

Twist Left

SpaceMouseState(x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=-1.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

yaw = -1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is twisted to the left, yaw changes significantly in the negative direction. This confirms that the left yaw input is working correctly.

Twist Right

SpaceMouseState(x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=1.0, buttons=[0, 0])
Enter fullscreen mode Exit fullscreen mode

Value to check:

yaw = 1.0
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ When the knob is twisted to the right, yaw changes significantly in the positive direction. This confirms that the right yaw input is working correctly.

Summary

Based on these tests, the SpaceMouse inputs were mapped as follows:

Forward horizontal  = +Y
Backward horizontal = -Y

Left horizontal     = -X
Right horizontal    = +X

Up                  = +Z
Down                = -Z

Forward tilt        = +Pitch
Backward tilt       = -Pitch

Left tilt           = -Roll
Right tilt          = +Roll

Left twist          = -Yaw
Right twist         = +Yaw
Enter fullscreen mode Exit fullscreen mode

Since both the positive and negative directions were clearly detected for all six axes, we can confirm that the 6DoF input from the SpaceMouse is working correctly.

In the next article, I will explain how these SpaceMouse motions correspond to the actual 6DoF motion of the SO-101 robot arm.

Then I will connect the SpaceMouse input to LeRobot and experimentally teleoperate the SO-101 using the SpaceMouse.

Top comments (0)