Browse Source

Remap rotation stick to start at 0 at dead zone edge

Eliminates 2.3 deg/s jump when stick crosses dead zone threshold.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
main
Joe DiPrima 4 weeks ago
parent
commit
7651fab57e
  1. 5
      gear_sonic_deploy/src/g1/g1_deploy_onnx_ref/include/input_interface/gamepad_manager.hpp

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

@ -518,7 +518,10 @@ class GamepadManager : public InputInterface {
// Analog sticks - facing and movement direction // Analog sticks - facing and movement direction
if (std::abs(rx_) > dead_zone_ || std::abs(ry_) > dead_zone_) { if (std::abs(rx_) > dead_zone_ || std::abs(ry_) > dead_zone_) {
planner_facing_angle_ = planner_facing_angle_ - 0.004 * rx_; // ~45°/s max at full stick
// Remap rx_ so dead zone edge = 0, full stick = 1
double rx_sign = (rx_ > 0) ? 1.0 : -1.0;
double rx_remapped = std::max(0.0, (std::abs(rx_) - dead_zone_) / (1.0 - dead_zone_)) * rx_sign;
planner_facing_angle_ = planner_facing_angle_ - 0.004 * rx_remapped; // ~45°/s max at full stick
if constexpr (DEBUG_LOGGING) { if constexpr (DEBUG_LOGGING) {
std::cout << "[GamepadManager DEBUG] Right stick - Facing angle: " << planner_facing_angle_ << " rad" << std::endl; std::cout << "[GamepadManager DEBUG] Right stick - Facing angle: " << planner_facing_angle_ << " rad" << std::endl;
} }

Loading…
Cancel
Save