|Note: This tutorial assumes that you have completed the previous tutorials: Starting a Wiimote Node.|
|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.|
Making the Wiimote Blink and RumbleDescription: How to use ROS messages to make a Wiimote device rumble (vibrate), and blink its LEDs. With this tutorial you will be able to use ROS command line tools to control rumble and LED states of a Wiimote device.
Keywords: Wiimote, Nintendo, IMU, Joy, Joystick
Tutorial Level: BEGINNER
Controlling the Four LEDs and Rumble (Vibrator)
The Wiimote device includes two output modes for signaling to its user. One output is an array of four LEDs that may be switched on and off. The second output is called rumble, which is a built-in vibrator that also may be switched on or off.
The wiimote node listens for two message topics that allow publishers to operate these output facilities: /wiimote/rumble, and /wiimote/led. The respective message types are RumbleControl and LEDControl.
All four LEDs, and rumble can be operated in two modes. The above two message types are used for both modes. The first operating mode is simply to turn the respective output on or off.
For LEDs this is done through the LEDControl message's timed_switch_array field of four integers. These integers should be set to either 1 or 0, for on and off, respectively (True/False when working in Python). The array positions correspond to the LEDs on the Wiimote device, counted from left to right.
The second operating mode is to have the Wiimote node turn the respective output on and off according to given time durations. The time durations are provided in an array, which may be arbitrarily long. The first time duration determines how long the output is on, the second duration governs the off time, the third determines the next on state duration, etc. One could, for example, define a pattern that corresponds to a Morse code signal.
The Wiimote node can be asked to output the respective pattern any number of times, or continuously, until it receives a second message to turn the output off.
morseDi = 0.2 morsePause = 0.1 morseDa = 0.6 morseLongPause = 1.0 msg = RumbleControl(TimedSwitch(switch_mode=TimedSwitch.REPEAT, num_cycles = 2, pulse_pattern=[morseDi, morsePause, morseDa, morsePause, morseDi, morsePause, morseDi, morseLongPause])) pub.publish(msg)
This example is not to imply that vibrating Morse code is an appropriate user interaction.