Skip to content

User Input and Communication Interface

The input layer is uniformly encapsulated in UserCommandInterface, responsible for converting user operations into commands recognizable by the state machine.

virtual void Start() = 0;
virtual void Stop() = 0;
virtual UserCommand* GetUserCommand() = 0;
uc_ptr_->SetMotionStateFeedback(&StateBase::msfb_);

The keyboard input mode corresponds to KeyboardInterface, based on libevdev for direct reading of /dev/input devices.

std::make_shared<q::QStateMachine>(RobotName::Lite3, RemoteCommandType::kKeyBoard);
KeyFunctionValid State
zStanding upOnly in WaitingForStand state
cRL controlOnly in StandingUp state
rJoint dampingAny state
wasdMovement (ramp-up velocity increment)RL control state
qeRotationRL control state
ESCExitAny state

The Retroid gamepad input is based on RetroidGamepadInterface, receiving gamepad data by subscribing to the /GAMEPAD_DATA topic. Gamepad data is published by RetroidGamepadPublisher in lite3_transfer.

uc_ptr_ = std::make_shared<RetroidGamepadInterface>(robot_name_, ri_ptr_->get_node());
gamepad_sub_ = node_->create_subscription<drdds::msg::GamepadData>(
"/GAMEPAD_DATA", 10,
std::bind(&RetroidGamepadInterface::GamepadDataCallback, this, std::placeholders::_1));

Button handling in RetroidGamepadInterface (based on bitmask):

  • Y button (rising edge) → Standing Up
  • A button (rising edge) → RL Control
  • Left joystick button + Right joystick button pressed simultaneously → Joint Damping (emergency damping)