Joystick: Twist messages

You can use either a physical controller (gamepad), the keyboard, or virtual joysticks to remotely control your device.

This guide will teach you how to configure your teleoperation interface to use a joystick for control.

📘

This page refers to Twist message types. If you need to use a Joy message type, reach out to our Customer Success team via the Intercom messenger in the bottom-right corner of this page, or at [email protected].

Prerequisites (optional)

Test gamepad

If you are using a gamepad, first test its compatibility and button mapping using the following tool: Hardware Tester: Gamepad Tester.

Make a note of the button mapping. The gamepad Button 0 will correspond to your teleoperation interface Button 0, etc.

Gamepad button mapping.

Gamepad button mapping.

Create buttons

If you want the buttons on your gamepad to operate virtual buttons on your teleoperation interface, you'll have to create virtual buttons first. For more information, see Add buttons to your teleoperation interface.

Step 1: Navigate to device teleoperation settings

  1. In Formant, in the upper-left corner, open the menu and click Settings.
  2. Click Devices, and then click on the device you want to configure.
  3. Click on the Teleoperation tab to open the teleoperation configuration page.

Step 2: Add a joystick stream

ROS

Formant will send joystick coordinate data as a geometry_msgs/Twist stream.

  1. In the teleoperation configuration page, scroll down to Joystick and click the plus (+) icon.
  2. Click Add ROS Topic.
  3. Enter the ROS topic to which you want to post joystick coordinate data.
  4. Click Done to bring up the Joystick configuration screen.

API

You can also handle joystick input through the Agent SDK.

  1. In the teleoperation configuration page, scroll down to Joystick and click the plus (+) icon.
  2. Click Add from API.
  3. Enter the name of the function which handles joystick input. For an example of how to handle joystick input in the Agent SDK, see GitHub: teleop.py.
  4. Click Done to bring up the Joystick configuration screen.

📘

For a complete reference for the Agent SDK, see Agent SDK Reference.

Step 3: Configure joystick settings

You can configure up to four axes across two joysticks. Each axis is mapped to a particular axis in a standard Twist message. A Twist message has linear x,y,z axes, and angular x,y,z axes.

joystick configuration window

PropertyUsage
Enable toggleToggle the right or left joystick on or off. The right joystick maps to the arrow keys on your keyboard, and the left joystick maps to the WASD keys.
Twist DimensionSelect the twist dimension to which this axis maps.
Gamepad AxisIf using a gamepad, map the gamepad axis to the joystick axis.
ScaleSet the value the twist command should report when this axis is at 100%.
ExponentSet the exponential curve by which intermediate twist values (i.e., between 0 and max, or scale,) are calculated.

Step 4: Configure global settings

At the bottom of the Joystick configuration window, you'll see a list of global settings for both joysticks:

universal joystick settings

PropertyUsage
Disable Gamepad Trigger Axis MappingWhen set to Enabled, trigger buttons on your gamepad will be disabled. Gamepad triggers map to Buttons 6 and 7 in the teleoperation interface.

If you have more than six buttons on your teleoperation interface, Enable this setting. If you do not Enable this setting, using the trigger will simultaneously send axis data and push a button.
Disable Gamepad Input and Keyboard InputWhen set to Enabled, joysticks will be controllable only by mouse input in the teleoperation interface. All keyboard and gamepad input will be ignored.
Reduce Joystick Filter TimeoutWhen set to Disabled, twist messages will publish at 10 Hz for new values, and at 2 Hz for repeated values (i.e., holding down "forward").

When set to Enabled, twist messages will publish at 20 Hz for new values, and 10 Hz for repeated values.

Step 5: Preview your joystick output

You can use the Preview window to generate sample joystick data based on mouse, gamepad, or keypad input. Sample data will be shown in the Output section.

generating sample joystick data

Step 6: Verify your work in teleoperation mode

  1. In your device view, in the upper-right corner, click the three dots >> Teleop, or enter Shift + T.
  2. Verify that your joystick input is working properly.

👋

If you notice an issue with this page or need help, please reach out to us! Use the 'Did this page help you?' buttons below, or get in contact with our Customer Success team via the Intercom messenger in the bottom-right corner of this page, or at [email protected].