Project

General

Profile

joystick component

This component exports any connected joystick state.

Additionnaly, it can filter a state reference for controllers by either publishing it as-is (no-op filter) or by overwriting it with a user command, for instance to act as an emergency mode component.

Ports

device (multiple out)

Data structure
  • struct ::or_joystick::state device

    • struct ::or::time::ts ts

      • long sec

      • long nsec

    • sequence< boolean, 16 > buttons

    • sequence< short, 16 > axes

Represents the current buttons and axes state of connected devices.


desired (out)

Data structure
  • struct ::or_pose_estimator::state desired

    • struct ::or::time::ts ts

      • long sec

      • long nsec

    • boolean intrinsic

    • optional< struct ::or::t3d::pos > pos

      • double x

      • double y

      • double z

    • optional< struct ::or::t3d::att > att

      • double qw

      • double qx

      • double qy

      • double qz

    • optional< struct ::or::t3d::vel > vel

      • double vx

      • double vy

      • double vz

    • optional< struct ::or::t3d::avel > avel

      • double wx

      • double wy

      • double wz

    • optional< struct ::or::t3d::acc > acc

      • double ax

      • double ay

      • double az

    • optional< struct ::or::t3d::aacc > aacc

      • double awx

      • double awy

      • double awz

    • optional< struct ::or::t3d::pos_cov > pos_cov

      • double cov[6]

    • optional< struct ::or::t3d::att_cov > att_cov

      • double cov[10]

    • optional< struct ::or::t3d::att_pos_cov > att_pos_cov

      • double cov[12]

    • optional< struct ::or::t3d::vel_cov > vel_cov

      • double cov[6]

    • optional< struct ::or::t3d::avel_cov > avel_cov

      • double cov[6]

    • optional< struct ::or::t3d::acc_cov > acc_cov

      • double cov[6]

    • optional< struct ::or::t3d::aacc_cov > aacc_cov

      • double cov[6]

Reference velocity computed according to user input.

The published reference contains vel, acc, avel and aacc members. intrinsic flag is set according to current coordinates mode (see set_intrinsic_mode (attribute)).

The mapping from user input to velocity is defined by a set of mappings (see set_mappings (attribute)) and parameters (see set_state_params (attribute).


reference (in)

Data structure
  • struct ::or_pose_estimator::state reference

    • struct ::or::time::ts ts

      • long sec

      • long nsec

    • boolean intrinsic

    • optional< struct ::or::t3d::pos > pos

      • double x

      • double y

      • double z

    • optional< struct ::or::t3d::att > att

      • double qw

      • double qx

      • double qy

      • double qz

    • optional< struct ::or::t3d::vel > vel

      • double vx

      • double vy

      • double vz

    • optional< struct ::or::t3d::avel > avel

      • double wx

      • double wy

      • double wz

    • optional< struct ::or::t3d::acc > acc

      • double ax

      • double ay

      • double az

    • optional< struct ::or::t3d::aacc > aacc

      • double awx

      • double awy

      • double awz

    • optional< struct ::or::t3d::pos_cov > pos_cov

      • double cov[6]

    • optional< struct ::or::t3d::att_cov > att_cov

      • double cov[10]

    • optional< struct ::or::t3d::att_pos_cov > att_pos_cov

      • double cov[12]

    • optional< struct ::or::t3d::vel_cov > vel_cov

      • double cov[6]

    • optional< struct ::or::t3d::avel_cov > avel_cov

      • double cov[6]

    • optional< struct ::or::t3d::acc_cov > acc_cov

      • double cov[6]

    • optional< struct ::or::t3d::aacc_cov > aacc_cov

      • double cov[6]

Reference state published in inactive mode.

In inactive mode, this reference is read and published as is in the desired (out) port. See set_mappings (attribute) for inactive mode activation.


Services

device_list (function)

Outputs
  • sequence< string<32> > device_list

Throws
  • exception ::joystick::e_nomem

Return the list of available devices


rename (activity)

Inputs
  • string<32> name

  • string<32> newname

Throws
  • exception ::joystick::e_sdl

    • string<256> what

  • exception ::joystick::e_noent

Context

Rename an existing device


set_state_params (attribute)

Inputs
  • struct ::joystick::params_s params

    • double drag (default "3") Drag acceleration (m.s⁻²)

    • double amax (default "10") Maximum acceleration (m.s⁻²)

    • double awmax (default "10") Maximum angular acceleration (rad.s⁻²)

    • double slow (default "4") Slowdown factor in slow motion

State integration parameters for desired (out) velocity.

User input is mapped (see set_mappings (attribute)) to a desired acceleration a ranging from -amax to +amax and angular acceleration aw ranging from -awmax to +awmax. In slow motion mode, the range is divided by the slow factor. The drag parameter is a linear friction coefficient acting on the current velocity.

The resulting acceleration is integrated into the published desired velocity by using the following differential equations:

  • ∂v/∂t = a - drag . v

  • ∂w/∂t = aw - drag . w


get_mappings (attribute)

Outputs
  • struct ::joystick::mappings_s mappings

    • struct ::joystick::mappings_s::mappings_axis_s linear[3]

      • short axis

      • double offset

      • double scale

    • struct ::joystick::mappings_s::mappings_axis_s angular[3]

      • short axis

      • double offset

      • double scale

    • struct ::joystick::mappings_s::enable_s enable

      • short on

      • short slow

      • short toggle

    • struct ::joystick::mappings_s::coord_s coords

      • short intrinsic

      • short world

      • short toggle

Get mapping between axes and x, y, z motion.


set_mappings (attribute)

Inputs
  • struct ::joystick::mappings_s mappings: Axis/buttons mappings

    • struct ::joystick::mappings_s::mappings_axis_s linear[3]: Axis number and scaling for x, y, z linear acceleration (-1 to disable)

      • short axis

      • double offset

      • double scale

    • struct ::joystick::mappings_s::mappings_axis_s angular[3]: Axis number and scaling for x, y, z angular acceleration (-1 to disable)

      • short axis

      • double offset

      • double scale

    • struct ::joystick::mappings_s::enable_s enable: Button numbers for enabling motion (-1 means unused)

      • short on (default "-1") Temporary motion enable

      • short slow (default "-1") Temporary slow motion

      • short toggle (default "-1") Toggle permanent enable mode

    • struct ::joystick::mappings_s::coord_s coords: Button numbers for coordinates mode (-1 means unused)

      • short intrinsic (default "-1") Switch to intrinsic motion

      • short world (default "-1") Switch to world frame coordinates motion

      • short toggle (default "-1") Toggle switch between intrinsic or world frame motion

Define mapping between axes and x, y, z motion.

User input on the defined axes is mapped to the corresponding x, y, z coordinates. If an axis is specified as -1, the motion on that coordinate is disabled. User input ranges from -1.0 to 1.0 and is further scaled according to the offset and scale parameters to produce the final command like so:

command = scale . (input + offset)

For instance, to invert an axis, specify scale as -1.0. Some axes have a default position of -1. To map it to [0;1], use an offset equal to 1.0 and a scale equal to 0.5.

Motion can be set to be active only when a button is pressed by defining an enable.on button number. In a similar manner, a enable.slow button can enable a slowed down motion (see set_state_params (attribute) slow parameter). Pressing both enable.on and enable.slow buttons activate an intermediate dynamics mode using half of the slow parameter. Finally, a enable.toggle defines a button to permanently switch between active or deactivated mode. If none of those three buttons is defined, the mode is always active.

coords.intrinsic and coords.world may define a button number selecting one of the corresponding mode (see set_intrinsic_mode (attribute)). Alternatively a coords.toggle button can be used to switch between those two modes.


set_intrinsic_mode (attribute)

Inputs
  • boolean intrinsic Coordinate mode

Select frame of the published desired (out) velocity.

With intrinsic set to true, the velocity is published relative to the robot frame. With false, global coordinates are used.

This flag requires that the readers of the output port actually use the intrinsic flags of the published velocity.


log (activity)

Inputs
  • string<64> path (default "/tmp/joystick.log") Log file name

  • unsigned long decimation (default "1") Reduced logging frequency

Throws
  • exception ::joystick::e_sys

    • short code

    • string<128> what

Context
  • In task state (frequency 200.0 Hz)

Log published state


log_stop (function)

Stop logging


log_info (function)

Outputs
  • unsigned long miss Missed log entries

  • unsigned long total Total log entries

Show missed log entries


Tasks

publish

Context
Throws
  • exception ::joystick::e_sdl

    • string<256> what


state

Context