Skip to content

Commit 5f42f60

Browse files
committed
1 parent 9916ab4 commit 5f42f60

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

mecanum_drive_controller/include/mecanum_drive_controller/odometry.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#ifndef MECANUM_DRIVE_CONTROLLER__ODOMETRY_HPP_
2828
#define MECANUM_DRIVE_CONTROLLER__ODOMETRY_HPP_
2929

30-
#include <cmath>
31-
3230
#include "rclcpp/time.hpp"
3331
#include "rcpputils/rolling_mean_accumulator.hpp"
3432

mecanum_drive_controller/src/odometry.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// Based on: https://ecam-eurobot.github.io/Tutorials/mechanical/mecanum.html
2222
// Author: Maciej Stępień
2323

24+
#include <cmath>
25+
2426
#include "mecanum_drive_controller/odometry.hpp"
2527

2628
namespace mecanum_drive_controller
@@ -94,7 +96,11 @@ bool Odometry::updateFromVelocity(
9496
const rclcpp::Time & time)
9597
{
9698
const double dt = time.seconds() - timestamp_.seconds();
97-
99+
if (dt < 0.0001)
100+
{
101+
return false; // Interval too small to integrate with
102+
}
103+
// Compute linear and angular diff:
98104
const double linear_x = (front_left_vel + front_right_vel + rear_left_vel + rear_right_vel) / 4.;
99105
const double linear_y = (-front_left_vel + front_right_vel + rear_left_vel - rear_right_vel) / 4.;
100106
const double angular = (-front_left_vel + front_right_vel - rear_left_vel + rear_right_vel) /

0 commit comments

Comments
 (0)