The JoyPlugin connects to a joystick or gamepad, and transmits data from the joystick over an Ignition Transport topic.
The default topic name is /joy, and the message type is ignition.msgs.Joy.
Another plugin or application can listen to the joystick messages, and then take actions based on the data.
Example
- Connect a joystick to the computer.
- Run the Gazebo demo: gazebo worlds/joy_demo.world
Echo the joy data to a terminal: ign topic -e -t /joy
Note: You will need ign-tools
Usage
The plugin is loaded via a world plugin. In SDF this looks like:
<plugin name=
"joy" filename=
"libJoyPlugin.so">
<sticky_buttons>false</sticky_buttons>
<dead_zone>0.05</dead_zone>
<rate>60</rate>
<accumulation_rate>1000</accumulation_rate>
</plugin>
See worlds/joy_demo.world for an example.
Configuration
Options that can be specified in the plugin include:
- <dev>(string): Name of the joystick device. The default value is /dev/input/js0.
- <topic>(string): Name of the topic on which to publish joy messages. The default is /joy.
- <sticky_buttons>(true/false): When true the buttons values change state only on a transition from 0 to 1. This makes the button act like toggle buttons. False is the default
- <dead_zone>(float between 0 and 0.9): A larger number increases the distance the joystick has to move before registering a value. The default is 0.05;
- <rate>(float): The rate at which joystick messages are published, in Hz. The default value is 1Hz.
- <accumulation_rate>(float): The rate at which data is collected from the joystick device. The default value is 1000Hz.
Troubleshooting
- Playstation joysticks may require a press of the center "Ps" button before they work.