Skip to content

Commit e6dfdb1

Browse files
committed
odometry fix
1 parent 767d983 commit e6dfdb1

2 files changed

Lines changed: 8 additions & 19 deletions

File tree

Industrial/gz_noisy_odometry/include/gz_noisy_odometry/NoisyOdometryPlugin.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ namespace custom_plugins
8888
// Typical range: 0.01 – 0.05.
8989
double slip_factor_{0.02};
9090

91-
// Ratio of actual/commanded motion below which a robot is considered blocked.
92-
// Avoids the fixed absolute threshold misfiring on slow robots or low-speed commands.
93-
double block_ratio_threshold_{0.15};
94-
9591
// Fraction of longitudinal slip applied as zero-mean lateral noise when blocked.
9692
// Models imperfect wheel-wall contact (small perpendicular micro-displacements).
9793
double lateral_slip_ratio_{0.2};

Industrial/gz_noisy_odometry/src/gz_noisy_odometry/NoisyOdometryPlugin.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)