Drake
Drake C++ Documentation
Meshcat::Gamepad Struct Reference

Detailed Description

Status of a gamepad obtained from the Meshcat javascript client.

#include <drake/geometry/meshcat.h>

Public Member Functions

template<typename Archive >
void Serialize (Archive *a)
 Passes this object to an Archive. More...
 

Public Attributes

std::optional< intindex
 An an integer that is auto-incremented to be unique for each device currently connected to the system. More...
 
std::vector< doublebutton_values
 An array of floating point values representing analog buttons, such as the triggers on many modern gamepads. More...
 
std::vector< doubleaxes
 An array of floating point values representing e.g. More...
 

Member Function Documentation

◆ Serialize()

void Serialize ( Archive *  a)

Passes this object to an Archive.

Refer to YAML Serialization for background.

Member Data Documentation

◆ axes

std::vector<double> axes

An array of floating point values representing e.g.

analog thumbsticks. Each entry in the array is a floating point value in the range -1.0 – 1.0, representing the axis position from the lowest value (-1.0) to the highest value (1.0).

In the standard gamepad mapping, we have:

  • axes[0] Left stick x (negative left/positive right)
  • axes[1] Left stick y (negative up/positive down)
  • axes[2] Right stick x (negative left/positive right)
  • axes[3] Right stick y (negative up/positive down)

Note that a stick that is left alone may not output all zeros. https://beej.us/blog/data/javascript-gamepad/ gives some useful advice for applying a deadzone to these values.

◆ button_values

std::vector<double> button_values

An array of floating point values representing analog buttons, such as the triggers on many modern gamepads.

The values are normalized to the range [0.0, 1.0], with 0.0 representing a button that is not pressed, and 1.0 representing a button that is fully pressed.

See https://w3c.github.io/gamepad/#dfn-standard-gamepad for the standard mapping of gamepad buttons to this vector.

◆ index

std::optional<int> index

An an integer that is auto-incremented to be unique for each device currently connected to the system.

If index.has_value() == false, then we have not yet received any gamepad status from the Meshcat browser.


The documentation for this struct was generated from the following file: