[Documentation] [TitleIndex] [WordIndex

(!) 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 ROS

Description: 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:

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:

You can glean the same information from the ROS joystick messages that the Wiimote node transmits:

rostopic echo /joy/buttons

Re-Calibration

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.


2019-12-07 13:17