Browse Source

Fix rotation and ramp rates for 100Hz input loop

Input thread runs at 100Hz not 200Hz. Corrected:
- Rotation: 0.008 rad/frame = 45 deg/s at full stick
- Speed ramp: 0.002/frame = 4s to reach 0.8 m/s

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

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

@ -521,7 +521,7 @@ class GamepadManager : public InputInterface {
// 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
planner_facing_angle_ = planner_facing_angle_ - 0.008 * rx_remapped; // 45°/s max at full stick (100Hz input loop)
if constexpr (DEBUG_LOGGING) {
std::cout << "[GamepadManager DEBUG] Right stick - Facing angle: " << planner_facing_angle_ << " rad" << std::endl;
}
@ -712,7 +712,7 @@ class GamepadManager : public InputInterface {
double normalized = std::min((planner_stick_magnitude_ - dead_zone_) / (1.0 - dead_zone_), 1.0);
double target_speed = normalized * 0.8; // 0.0 at dead zone edge, 0.8 at full stick
// Rate-limit acceleration only (decel is instant)
constexpr double max_accel_per_frame = 0.001; // ~4s ramp 0→0.8 at 200Hz
constexpr double max_accel_per_frame = 0.002; // 4s ramp 0→0.8 (100Hz input loop)
if (target_speed > smoothed_speed_) {
smoothed_speed_ = std::min(target_speed, smoothed_speed_ + max_accel_per_frame);
} else {

Loading…
Cancel
Save