Omni wheel drive odometry update - #2286
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2286 +/- ##
==========================================
- Coverage 86.83% 86.73% -0.11%
==========================================
Files 148 149 +1
Lines 16273 16338 +65
Branches 1368 1374 +6
==========================================
+ Hits 14131 14171 +40
- Misses 1635 1654 +19
- Partials 507 513 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |
|
This pull request is in conflict. Could you fix it @Devdoot57? |
There was a problem hiding this comment.
Pull request overview
This PR modernizes omni_wheel_drive_controller odometry to integrate using an explicit double dt (instead of deriving it from rclcpp::Time in the core update path), and adds a new gtest/gmock suite to validate holonomic kinematics and integration behavior for an omni-wheel base.
Changes:
- Added new
dt-based odometry update APIs (update_from_pos,update_from_vel,update_open_loop) and deprecated the priorrclcpp::Time-based methods. - Updated the controller update loop to call the new
dt-based odometry APIs usingperiod.seconds(). - Added
test_odometry.cppto validate straight-line motion, pure rotation, and exact-arc integration.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| omni_wheel_drive_controller/test/test_odometry.cpp | Adds unit tests for omni-wheel odometry integration and kinematics. |
| omni_wheel_drive_controller/src/omni_wheel_drive_controller.cpp | Switches controller loop to new dt-based odometry APIs. |
| omni_wheel_drive_controller/src/odometry.cpp | Implements new dt-based odometry updates and refactors integration to accept velocities + dt. |
| omni_wheel_drive_controller/include/omni_wheel_drive_controller/odometry.hpp | Deprecates old APIs and declares the new dt-based methods. |
| omni_wheel_drive_controller/CMakeLists.txt | Adds the odometry unit test target. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ament_add_gmock(test_odometry | ||
| test/test_odometry.cpp | ||
| src/odometry.cpp | ||
| ) |
| // Disable deprecated warnings | ||
| #pragma GCC diagnostic push | ||
| #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||
| if (updateFromVel(wheels_vel, time)) | ||
| #pragma GCC diagnostic pop | ||
| { | ||
| return true; | ||
| } | ||
| return false; | ||
| } |
| // Estimate angular velocity of wheels using old and current position [rads/s]: | ||
| std::vector<double> wheels_vel(wheels_pos.size()); | ||
| for (size_t i = 0; i < static_cast<size_t>(wheels_pos.size()); ++i) | ||
| { | ||
| wheels_vel[i] = (wheels_pos[i] - wheels_old_pos_[i]) / dt; | ||
| wheels_old_pos_[i] = wheels_pos[i]; | ||
| } |
| if (std::fabs(dt) < 1e-6) | ||
| { | ||
| return false; | ||
| } |
| bool Odometry::update_open_loop( | ||
| const double & linear_x_vel, const double & linear_y_vel, const double & angular_vel, double dt) | ||
| { | ||
| // Integrate odometry: | ||
| integrate(linear_x_vel, linear_y_vel, angular_vel, dt); | ||
|
|
||
| // Save last linear and angular velocity: | ||
| linear_x_vel_ = linear_x_vel; | ||
| linear_y_vel_ = linear_y_vel; | ||
| angular_vel_ = angular_vel; | ||
|
|
||
| return true; | ||
| } |
| #include "gmock/gmock.h" | ||
| #include "omni_wheel_drive_controller/odometry.hpp" |
| bool update_from_pos(const std::vector<double> & wheels_pos, double dt); | ||
| bool update_from_vel(const std::vector<double> & wheels_vel, double dt); | ||
| bool update_open_loop( | ||
| const double & linear_x_vel, const double & linear_y_vel, const double & angular_vel, | ||
| double dt); |
christophfroehlich
left a comment
There was a problem hiding this comment.
Changes LGTM, but copilot has some valid suggestions. Please address them, and we can merge this soon!
Description
This PR updates the
omni_wheel_drive_controllerodometry implementation to usedouble dtfor integration instead of relying onrclcpp::Time(matching #1854). It also introduces a comprehensivegtestsuite to verify the holonomic kinematics and integration math (matching #2099).This rolls out the architectural improvements requested in #2039 for the omni-wheel base.
Changes:
updateFromPos,updateFromVel, andupdateOpenLoop. Replaced withupdate_from_pos,update_from_vel, andupdate_open_loop.test_odometry.cppcovering:dtrejection.