@@ -78,6 +78,9 @@ bool SteeringKinematics::update_odometry(
7878bool SteeringKinematics::update_from_position (
7979 const double traction_wheel_pos, const double steer_pos, const double dt)
8080{
81+
82+ if (std::fabs (dt) < std::numeric_limits<double >::epsilon () || !std::isfinite (traction_wheel_pos) || !std::isfinite (steer_pos)) return false ;
83+
8184 const double traction_wheel_est_pos_diff = traction_wheel_pos - traction_wheel_old_pos_;
8285
8386 // / Update old position with current:
@@ -90,6 +93,11 @@ bool SteeringKinematics::update_from_position(
9093 const double traction_right_wheel_pos, const double traction_left_wheel_pos,
9194 const double steer_pos, const double dt)
9295{
96+
97+ if (std::fabs (dt) < std::numeric_limits<double >::epsilon () || !std::isfinite (traction_right_wheel_pos)
98+ || !std::isfinite (traction_left_wheel_pos) || !std::isfinite (steer_pos))
99+ return false ;
100+
93101 const double traction_right_wheel_est_pos_diff =
94102 traction_right_wheel_pos - traction_right_wheel_old_pos_;
95103 const double traction_left_wheel_est_pos_diff =
@@ -107,6 +115,11 @@ bool SteeringKinematics::update_from_position(
107115 const double traction_right_wheel_pos, const double traction_left_wheel_pos,
108116 const double right_steer_pos, const double left_steer_pos, const double dt)
109117{
118+
119+ if (std::fabs (dt) < std::numeric_limits<double >::epsilon () || !std::isfinite (traction_right_wheel_pos)
120+ || !std::isfinite (traction_left_wheel_pos) || !std::isfinite (right_steer_pos) || !std::isfinite (left_steer_pos))
121+ return false ;
122+
110123 const double traction_right_wheel_est_pos_diff =
111124 traction_right_wheel_pos - traction_right_wheel_old_pos_;
112125 const double traction_left_wheel_est_pos_diff =
@@ -124,6 +137,9 @@ bool SteeringKinematics::update_from_position(
124137bool SteeringKinematics::update_from_velocity (
125138 const double traction_wheel_vel, const double steer_pos, const double dt)
126139{
140+
141+ if (std::fabs (dt) < std::numeric_limits<double >::epsilon () || !std::isfinite (traction_wheel_vel) || !std::isfinite (steer_pos)) return false ;
142+
127143 steer_pos_ = steer_pos;
128144 double linear_velocity = traction_wheel_vel * wheel_radius_;
129145 const double angular_velocity = std::tan (steer_pos) * linear_velocity / wheel_base_;
@@ -156,6 +172,9 @@ bool SteeringKinematics::update_from_velocity(
156172 const double right_traction_wheel_vel, const double left_traction_wheel_vel,
157173 const double steer_pos, const double dt)
158174{
175+
176+ if (std::fabs (dt) < std::numeric_limits<double >::epsilon () || !std::isfinite (right_traction_wheel_vel) || !std::isfinite (left_traction_wheel_vel) || !std::isfinite (steer_pos)) return false ;
177+
159178 steer_pos_ = steer_pos;
160179 double linear_velocity = get_linear_velocity_double_traction_axle (
161180 right_traction_wheel_vel, left_traction_wheel_vel, steer_pos_);
@@ -169,6 +188,11 @@ bool SteeringKinematics::update_from_velocity(
169188 const double right_traction_wheel_vel, const double left_traction_wheel_vel,
170189 const double right_steer_pos, const double left_steer_pos, const double dt)
171190{
191+
192+ if (std::fabs (dt) < std::numeric_limits<double >::epsilon () || !std::isfinite (right_traction_wheel_vel) ||
193+ !std::isfinite (left_traction_wheel_vel) || !std::isfinite (right_steer_pos) || !std::isfinite (left_steer_pos)) return false ;
194+
195+
172196 // overdetermined, we take the average
173197 const double right_steer_pos_est = std::atan (
174198 wheel_base_ * std::tan (right_steer_pos) /
@@ -187,14 +211,29 @@ bool SteeringKinematics::update_from_velocity(
187211
188212void SteeringKinematics::update_open_loop (const double v_bx, const double omega_bz, const double dt)
189213{
214+ if (std::fabs (dt) < std::numeric_limits<double >::epsilon () || !std::isfinite (v_bx) || !std::isfinite (omega_bz)) return ;
190215 // / Save last linear and angular velocity:
191216 linear_ = v_bx;
217+
192218 angular_ = omega_bz;
193219
194220 // / Integrate odometry:
195221 integrate_fk (v_bx, omega_bz, dt);
196222}
197223
224+ bool SteeringKinematics::try_update_open_loop (const double v_bx, const double omega_bz, const double dt)
225+ {
226+ if (std::fabs (dt) < std::numeric_limits<double >::epsilon () || !std::isfinite (v_bx) || !std::isfinite (omega_bz)) return false ;
227+ // / Save last linear and angular velocity:
228+ linear_ = v_bx;
229+
230+ angular_ = omega_bz;
231+
232+ // / Integrate odometry:
233+ integrate_fk (v_bx, omega_bz, dt);
234+ return true ;
235+ }
236+
198237void SteeringKinematics::set_wheel_params (
199238 double wheel_radius, double wheel_base, double wheel_track)
200239{
@@ -393,38 +432,4 @@ void SteeringKinematics::reset_accumulators()
393432 linear_acc_ = RollingMeanAccumulator (velocity_rolling_window_size_);
394433 angular_acc_ = RollingMeanAccumulator (velocity_rolling_window_size_);
395434}
396-
397- bool SteeringKinematics::try_update_open_loop (double linear, double angular, double delTime)
398- {
399- if (std::fabs (delTime) < std::numeric_limits<double >::epsilon ()) return false ;
400- update_open_loop (linear, angular, delTime);
401- return true ;
402- }
403-
404- bool SteeringKinematics::try_update_from_position (
405- double right_traction, double left_traction, double right_steering, double left_steering,
406- double delTime)
407- {
408- if (std::fabs (delTime) < std::numeric_limits<double >::epsilon ()) return false ;
409- if (
410- !std::isfinite (right_traction) || !std::isfinite (left_traction) ||
411- !std::isfinite (right_steering) || !std::isfinite (left_steering))
412- return false ;
413- update_from_position (right_traction, left_traction, right_steering, left_steering, delTime);
414- return true ;
415- }
416-
417- bool SteeringKinematics::try_update_from_velocity (
418- double right_traction, double left_traction, double right_steering, double left_steering,
419- double delTime)
420- {
421- if (std::fabs (delTime) < std::numeric_limits<double >::epsilon ()) return false ;
422- if (
423- !std::isfinite (right_traction) || !std::isfinite (left_traction) ||
424- !std::isfinite (right_steering) || !std::isfinite (left_steering))
425- return false ;
426- update_from_velocity (right_traction, left_traction, right_steering, left_steering, delTime);
427- return true ;
428- }
429-
430435} // namespace steering_kinematics
0 commit comments