Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update command limiter of diff_drive_controller #1315

Merged
merged 19 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup cmath includes
  • Loading branch information
christophfroehlich committed Dec 1, 2024
commit a7f6c94d9b5b5206d7e93f17502f5656b597679a
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define DIFF_DRIVE_CONTROLLER__DIFF_DRIVE_CONTROLLER_HPP_

#include <chrono>
#include <cmath>
#include <memory>
#include <queue>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#ifndef DIFF_DRIVE_CONTROLLER__ODOMETRY_HPP_
#define DIFF_DRIVE_CONTROLLER__ODOMETRY_HPP_

#include <cmath>

#include "rclcpp/time.hpp"
// \note The versions conditioning is added here to support the source-compatibility with Humble
#if RCPPUTILS_VERSION_MAJOR >= 2 && RCPPUTILS_VERSION_MINOR >= 6
Expand Down
10 changes: 6 additions & 4 deletions diff_drive_controller/src/odometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* Author: Enrique Fernández
*/

#include <cmath>

#include "diff_drive_controller/odometry.hpp"

namespace diff_drive_controller
Expand Down Expand Up @@ -134,8 +136,8 @@ void Odometry::integrateRungeKutta2(double linear, double angular)
const double direction = heading_ + angular * 0.5;

/// Runge-Kutta 2nd order integration:
x_ += linear * cos(direction);
y_ += linear * sin(direction);
x_ += linear * std::cos(direction);
y_ += linear * std::sin(direction);
heading_ += angular;
}

Expand All @@ -151,8 +153,8 @@ void Odometry::integrateExact(double linear, double angular)
const double heading_old = heading_;
const double r = linear / angular;
heading_ += angular;
x_ += r * (sin(heading_) - sin(heading_old));
y_ += -r * (cos(heading_) - cos(heading_old));
x_ += r * (std::sin(heading_) - std::sin(heading_old));
y_ += -r * (std::cos(heading_) - std::cos(heading_old));
}
}

Expand Down