Joy Interface

Overview

The raisin_joy_interface is an interface that receives multiple command source topics from a joystick connected to a robot or from a planning plugin. It manipulates these inputs into a single command message that is sent to the raisin_controller and outputs a ROS2 topic. Each command source topic has properties such as the topic name, priority, and a boolean variable called listen status. Except for a few exceptional cases, the interface outputs the message from the command source with the highest priority among those with listen status set to true. The command messages output by the interface are of two types:

  1. raisin/command: Commands the controller to move.

  2. raisin/joy_signal: Commands the transition of the phase or state of the motion.

Additionally, the interface includes safety features such as decaying the command to zero after a certain time if the joystick is disconnected, limiting the maximum rate of change of the desired velocity, and setting the listen status of a disconnected joystick to false. Command Source Types The command sources are divided into two types:

  1. JOY: Generated from a joystick.

  2. VEL_CMD: Generated from a plugin.

To be understood by the joy_interface, the topic names must follow specific naming conventions:

  • JOY type topic names start with joy/….

  • VEL_CMD type topic names start with vel_cmd/….

Configuring Topics to Receive The potential topics and their priorities are defined in the params.yaml file of raisin_raibo2. Lower numbers indicate higher priority.

command_source_topics:
  value: ["joy/gui", "joy/rf", "vel_cmd/path_planning"]
  dtype: vector<string>

command_source_topic_priorities:
  value: [1, 0, 2]
  dtype: vector<int>

raisin/command Topic

The message type for the raisin/command topic is raisin_interfaces::msg::Command, which includes the following fields:

float64 x_pos
float64 y_pos
float64 x_vel
float64 y_vel
float64 yaw_rate

Currently, x_pos and y_pos are fixed at 0. The x_vel, y_vel, and yaw_rate correspond to axes 0, 1, and 2 of the sensor_msgs::msg::Joy message generated by the joystick.

raisin/joy_signal Topic

The message type for the joy_signal topic is std_msgs::msg::Int16. Each value corresponds to a specific signal defined in the JoySignal class. This message is generated only by JOY type command sources. The buttons 0, 1, 2, and 3 of the sensor_msgs::msg::Joy message correspond to the HALT, LISTEN, ACTION0, and ACTION1 signals, respectively.

  • HALT: Transitions the robot’s state to MOTOR_DISABLED.

  • LISTEN: Changes the listen status of the command source.

  • ACTION0 and ACTION1: Can be customized to change the phase in the controller.

enum class JoySignal : int {
  SIGHALT = 0,
  SIGLISTEN,
  SIGACTION0,
  SIGACTION1,
  NUM_JOY_SIGNALS
};

Parameters of raisin_joy_interface (params.yaml)

  • joy_allowable_delay_time: If no communication is received from the joystick for this duration (in seconds), the command starts to decay.

  • joy_axes_to_zero_time: The time (in seconds) it takes to decay the command to zero after starting the decay process.

# Safety settings
joy_allowable_delay_time:
  value: 0.5
  dtype: double

joy_axes_to_zero_time:
  value: 0.5
  dtype: double
  • command_allowable_accel: Defines the maximum rate of change per unit time for the desired velocity commands (x_vel, y_vel, yaw_rate).

command_allowable_accel:
  value: [8.0, 4.0, 4.0]
  dtype: vector<double>
  • listen_default_status: Defines the default listen status for each topic when the Raibo_node starts (default: false).

  • unintended_signal_guard_max_count: To prevent erroneous values from a communication error, the same button must be pressed multiple times to send a JoySignal. This count is defined here.

joy/gui:
  listen_default_status:
    value: true
    dtype: bool
  unintended_signal_guard_max_count:
    value: 0
    dtype: int