|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
Pairing and Using a Wiimote with ROSDescription: Explains how to start a ROS Wiimote node, pair the wiimote with your computer, how the Wiimote device is calibrated, and how to test whether the node functions properly.
Keywords: Wiimote, Nintendo, IMU, Joy, Joystick
Tutorial Level: BEGINNER
Next Tutorial: Making the Wiimote Blink and Rumble
Dependencies and Compiling
$ rosdep install wiimote $ rosmake wiimote
Starting the Wiimote Node
To calibrate and pair the Wiimote with the wiimote ROS node, rest the device on a flat surface. Then start the node like this:
$ rosrun wiimote wiimote_node.py
You will be prompted on the command line to press the Wiimote buttons 1 and 2 at the same time. You need to perform this action within 6 seconds of starting the Wiimote node. Hold the two buttons until all or some of the Wiimote's blue LEDs start blinking. Then let go of the buttons, being careful not to move the device as you let go. The prompt for these actions looks like this:
Press buttons 1 and 2 together to pair (within 6 seconds). (If no blinking lights, press power button for ~3 seconds.)
We have observed that the Bluetooth connection can occasionally enter a confused state where pressing the two buttons does not work (no blinking LEDs). In that case press the Wiimote's power button for about 3 seconds. The LEDs should start blinking.
Once the Bluetooth pairing and calibration are complete, you will see the following on your terminal display:
Pairing successful. Wimotion activated. Calibration successful. Wiimote IMU publisher starting (topic /imu/data). Wiimote joystick publisher starting (topic /joy). Wiimote state publisher starting (topic /wiimote/state). Wiimote Nunchuk joystick publisher starting (topic /wiimote/nunchuk). Wiimote rumble listener starting (topic /wiimote/rumble). Wiimote LED control listener starting (topic /wiimote/leds). Wiimote calibration service starting (topic /imu/calibrate). Wiimote latched is_calibrated publisher starting (topic /imu/is_calibrated).
Your Wiimote node is now active.
See it Working
The wiimote node publishes three types of sensor-related messages: the standard ROS Inertial Measurement Unit (IMU) messages (topic /imu/data), the ROS standard Joy joystick messages (/joy), and a Wiimote-special message type /wiimote/state.
Please refer to the respective type definitions for detail. The state message is described in wiimote.
In a new terminal window try the following:
rostopic echo /wiimote/state
The flow of state type messages will run continuously on your terminal screen. To see all of at least one message, you may need to enlarge the terminal window vertically.
You can also monitor just one field. Exit the running rostopic display with ctrl-c, and try:
rostopic echo /wiimote/state/buttons
You will see arrays of boolean values that represent the Wiimote's button states. Press some of the device's buttons to see the values change on the screen.The output will look similar to:
header: seq: 3749 stamp: secs: 1295985659 nsecs: 475502014 frame_id: '' angular_velocity_zeroed: x: 0.0 y: 0.0 z: 0.0 angular_velocity_raw: x: 0.0 y: 0.0 z: 0.0 angular_velocity_covariance: [-1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] linear_acceleration_zeroed: x: 0.0 y: 0.0 z: 9.80665 linear_acceleration_raw: x: 120.0 y: 120.0 z: 145.0 linear_acceleration_covariance: [418.30270321418675, 0.0, 0.0, 0.0, 14.194748711241013, 0.0, 0.0, 0.0, 77.811457874424846] nunchuk_acceleration_zeroed: x: 0.0 y: 0.0 z: 0.0 nunchuk_acceleration_raw: x: 0.0 y: 0.0 z: 0.0 nunchuk_joystick_zeroed: [0.0, 0.0] nunchuk_joystick_raw: [0.0, 0.0] buttons: [False, False, False, False, False, False, False, False, False, False, False] nunchuk_buttons: [False, False] LEDs: [False, False, False, False] rumble: False ir_tracking: - x: -1.0 y: -1.0 ir_size: -1 - x: -1.0 y: -1.0 ir_size: -1 - x: -1.0 y: -1.0 ir_size: -1 - x: -1.0 y: -1.0 ir_size: -1 raw_battery: 100.0 percent_battery: 48.0769233704 zeroing_time: secs: 0 nsecs: 0 errors: 0
You can glean the same information from the ROS joystick messages that the Wiimote node transmits:
rostopic echo /joy/buttons
The Wiimote device is automatically calibrated during the pairing process. If you wish to re-calibrate, place the device on a flat surface, and ensure that it is not moving. Then type the following to a terminal shell:
rosservice call /imu/calibrate
The call will return after a few seconds. If you wish to monitor the result of the calibration, open a second terminal window and monitor the imu/is_calibrated topic:
rostopic echo /imu/is_calibrated
After each calibration, you will see True or False in the terminal window to indicate success or failure of the calibration. The calibration fails if device movement is detected.