This weekend I added a wireless Xbox controller to the list of devices I can use to control the Mecanumbot. Before now I’ve been able to use a standard RC transmitter, a computer keyboard, and a Wiimote. I again used the ROS framework to integrate the controller. Built into ROS is a joystick node to interface with the wireless USB dongle and I had already built a node to listen to the “cmd_vel” Twist messages. The teleop_joy node (posted in the downloads section) takes care of scaling specific channels from the controller and produces the required velocity commands.
One interesting feature of the Xbox controller is that it doesn’t send the controller state when state hasn’t changed, presumably to save battery life. (The Wiimote does not have this feature.) Since I have a failsafe in my motor controller code that requires velocity messages to be sent at least every 2Hz, I had to add a feature in the teleop_joy node to force the cmd_vel publication every-so-often even if there wasn’t a new message from the Xbox controller.