Browse Source

Map F1/F3 controller buttons to IMU pitch offset adjustment

F1 = -1 deg, F3 = +1 deg, F1+F3 together = reset to 0 deg.
Removes temporary button debug logger.
Keeps 9/0 tmux keys as secondary control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
main
Joe DiPrima 1 month ago
parent
commit
8bfe11b3a3
  1. 39
      gear_sonic_deploy/src/g1/g1_deploy_onnx_ref/include/input_interface/gamepad_manager.hpp

39
gear_sonic_deploy/src/g1/g1_deploy_onnx_ref/include/input_interface/gamepad_manager.hpp

@ -395,24 +395,27 @@ class GamepadManager : public InputInterface {
// Process gamepad inputs for planner controls (called from update())
void processGamepadPlannerControls() {
// === TEMPORARY BUTTON DEBUG — press any button to see its code name ===
if (R1_.on_press) std::cout << "[BTN] R1 pressed" << std::endl;
if (L1_.on_press) std::cout << "[BTN] L1 pressed" << std::endl;
if (start_.on_press) std::cout << "[BTN] start pressed" << std::endl;
if (select_.on_press) std::cout << "[BTN] select pressed" << std::endl;
if (R2_.on_press) std::cout << "[BTN] R2 pressed" << std::endl;
if (L2_.on_press) std::cout << "[BTN] L2 pressed" << std::endl;
if (F1_.on_press) std::cout << "[BTN] F1 pressed" << std::endl;
if (F2_.on_press) std::cout << "[BTN] F2 pressed" << std::endl;
if (A_.on_press) std::cout << "[BTN] A pressed" << std::endl;
if (B_.on_press) std::cout << "[BTN] B pressed" << std::endl;
if (X_.on_press) std::cout << "[BTN] X pressed" << std::endl;
if (Y_.on_press) std::cout << "[BTN] Y pressed" << std::endl;
if (up_.on_press) std::cout << "[BTN] up pressed" << std::endl;
if (right_.on_press) std::cout << "[BTN] right pressed" << std::endl;
if (down_.on_press) std::cout << "[BTN] down pressed" << std::endl;
if (left_.on_press) std::cout << "[BTN] left pressed" << std::endl;
// === END BUTTON DEBUG ===
// F1/F3 IMU pitch offset control
// F1 (physical) = F1_ (code): offset -1°
// F3 (physical) = F2_ (code): offset +1°
// F1+F3 together: reset to 0°
if (F1_.on_press && F2_.pressed) {
// Both held — reset to 0
g_imu_pitch_offset_deg.store(0.0);
std::cout << "[IMU] Pitch offset RESET to 0 deg" << std::endl;
} else if (F2_.on_press && F1_.pressed) {
// Both held — reset to 0 (catches whichever is pressed second)
g_imu_pitch_offset_deg.store(0.0);
std::cout << "[IMU] Pitch offset RESET to 0 deg" << std::endl;
} else if (F1_.on_press) {
double val = g_imu_pitch_offset_deg.load() - 1.0;
g_imu_pitch_offset_deg.store(val);
std::cout << "[IMU] Pitch offset: " << val << " deg" << std::endl;
} else if (F2_.on_press) {
double val = g_imu_pitch_offset_deg.load() + 1.0;
g_imu_pitch_offset_deg.store(val);
std::cout << "[IMU] Pitch offset: " << val << " deg" << std::endl;
}
// Start/Stop buttons
if (start_.on_press) {

Loading…
Cancel
Save