@@ -45,9 +45,8 @@ 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 ;
48+ slip_factor_ = _sdf->Get <double >(" slip_factor" , 0.02 ).first ;
49+ lateral_slip_ratio_ = _sdf->Get <double >(" lateral_slip_ratio" , 0.20 ).first ;
5150
5251 gz_node_.Subscribe (gz_cmd_vel_topic_, &NoisyOdometryPlugin::OnCmdVel, this );
5352
@@ -128,18 +127,12 @@ namespace custom_plugins
128127 const double trans_cmd = v_cmd * dt;
129128 const double delta_rot_cmd = w_cmd * dt;
130129
131- // Ratio-based detection: blocked when a commanded axis achieves less than
132- // block_ratio_threshold_ of the expected increment. More robust than a fixed
133- // 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.
137- const bool is_commanded = std::abs (trans_cmd) > 1e-4 || std::abs (delta_rot_cmd) > 1e-4 ;
138- const bool linear_stalled = std::abs (trans_cmd) > 1e-4 &&
139- trans_true < block_ratio_threshold_ * std::abs (trans_cmd);
140- const bool angular_stalled = std::abs (delta_rot_cmd) > 1e-4 &&
141- std::abs (delta_yaw_true) < block_ratio_threshold_ * std::abs (delta_rot_cmd);
142- const bool is_blocked = is_commanded && (linear_stalled || angular_stalled);
130+ // Blocked when something is commanded but the simulator reports no real
131+ // displacement. Single-tick, absolute threshold: ratio-based approaches
132+ // misfire during acceleration because trans_true lags trans_cmd legitimately.
133+ const bool is_blocked =
134+ (std::abs (trans_cmd) > 1e-4 || std::abs (delta_rot_cmd) > 1e-4 ) &&
135+ (trans_true < 1e-4 && std::abs (delta_yaw_true) < 1e-4 );
143136
144137 const double trans = is_blocked ? trans_cmd * slip_factor_ : trans_true;
145138 const double delta_yaw = is_blocked ? delta_rot_cmd * slip_factor_ : delta_yaw_true;
0 commit comments