@@ -45,10 +45,9 @@ namespace custom_plugins
4545 alpha3_ = _sdf->Get <double >(" alpha3" , gaussian_noise_coeff_).first ;
4646 alpha4_ = _sdf->Get <double >(" alpha4" , gaussian_noise_coeff_).first ;
4747
48- slip_factor_ = _sdf->Get <double >(" slip_factor" , 0.02 ).first ;
49- block_ratio_threshold_ = _sdf->Get <double >(" block_ratio_threshold" , 0.15 ).first ;
50- lateral_slip_ratio_ = _sdf->Get <double >(" lateral_slip_ratio" , 0.20 ).first ;
51- blocked_hysteresis_ticks_ = _sdf->Get <int > (" blocked_hysteresis_ticks" , 3 ).first ;
48+ slip_factor_ = _sdf->Get <double >(" slip_factor" , 0.02 ).first ;
49+ block_ratio_threshold_ = _sdf->Get <double >(" block_ratio_threshold" , 0.15 ).first ;
50+ lateral_slip_ratio_ = _sdf->Get <double >(" lateral_slip_ratio" , 0.20 ).first ;
5251
5352 gz_node_.Subscribe (gz_cmd_vel_topic_, &NoisyOdometryPlugin::OnCmdVel, this );
5453
@@ -132,19 +131,15 @@ namespace custom_plugins
132131 // Ratio-based detection: blocked when a commanded axis achieves less than
133132 // block_ratio_threshold_ of the expected increment. More robust than a fixed
134133 // absolute threshold, which can misfire on slow robots or tiny commands.
134+ // Single-tick detection (no hysteresis): the physics engine makes the robot
135+ // bounce on alternate ticks against a wall, so any multi-tick accumulator
136+ // would never trigger.
135137 const bool is_commanded = std::abs (trans_cmd) > 1e-4 || std::abs (delta_rot_cmd) > 1e-4 ;
136138 const bool linear_stalled = std::abs (trans_cmd) > 1e-4 &&
137139 trans_true < block_ratio_threshold_ * std::abs (trans_cmd);
138140 const bool angular_stalled = std::abs (delta_rot_cmd) > 1e-4 &&
139141 std::abs (delta_yaw_true) < block_ratio_threshold_ * std::abs (delta_rot_cmd);
140- const bool blocked_raw = is_commanded && (linear_stalled || angular_stalled);
141-
142- // Hysteresis: require several consecutive blocked detections before
143- // activating slip, and reset immediately when motion resumes.
144- blocked_ticks_ = blocked_raw
145- ? std::min (blocked_ticks_ + 1 , blocked_hysteresis_ticks_)
146- : 0 ;
147- const bool is_blocked = (blocked_ticks_ >= blocked_hysteresis_ticks_);
142+ const bool is_blocked = is_commanded && (linear_stalled || angular_stalled);
148143
149144 const double trans = is_blocked ? trans_cmd * slip_factor_ : trans_true;
150145 const double delta_yaw = is_blocked ? delta_rot_cmd * slip_factor_ : delta_yaw_true;
0 commit comments