-
Notifications
You must be signed in to change notification settings - Fork 396
Update odometry implementation in diff_drive #1854
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1854 +/- ##
==========================================
- Coverage 85.98% 85.75% -0.24%
==========================================
Files 129 129
Lines 13112 13150 +38
Branches 1144 1148 +4
==========================================
+ Hits 11275 11277 +2
- Misses 1469 1506 +37
+ Partials 368 367 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
bool updateFromVelocity(double left_vel, double right_vel, const rclcpp::Time & time); | ||
[[deprecated( | ||
"Replaced by bool updateOpenLoop(const double & linear_vel, const double & angular_vel, const " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Replaced by bool updateOpenLoop(const double & linear_vel, const double & angular_vel, const " | |
"Replaced by bool tryUpdateOpenLoop(const double & linear_vel, const double & angular_vel, const " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 629cf5e,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss my points first, and merge the outcome. If necessary, let's open a new PR afterwards for the other controllers.
diff_drive_controller/include/diff_drive_controller/odometry.hpp
Outdated
Show resolved
Hide resolved
diff_drive_controller/include/diff_drive_controller/odometry.hpp
Outdated
Show resolved
Hide resolved
bool Odometry::updateFromVel( | ||
const double & left_vel, const double & right_vel, const rclcpp::Time & time) | ||
{ | ||
const double dt = time.seconds() - timestamp_.seconds(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is exactly the pattern mentioned with #271 to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I should have explained this in the PR description.
The reasoning here is the same as that of this #260 (comment).
Additionally, timestamp_
records the last time an update was run; therefore, the correct value of dt
can only be obtained from there.
It is used in this function despite (std::fabs(dt) < 1e-6)
not being used, as it is also called from updateFromPos()
which uses the timestamp_
variable.
linear_ = linear_vel; | ||
angular_ = angular_vel; | ||
|
||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a return value, which is always true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is there to maintain consistency with other update methods, make it easier to add code to this function in the future that may return false, and make the diff_drive_controller.cpp
code simpler.
updateFromVel()
also has this line for the same reason.
I can change everything back to the normal updateOpenLoop()
function if needed, though.
odometry_.updateFromVelocity( | ||
left_feedback_mean * left_wheel_radius * period.seconds(), | ||
right_feedback_mean * right_wheel_radius * period.seconds(), time); | ||
odometry_updated = odometry_.updateFromVel(left_feedback_mean, right_feedback_mean, time); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where did the wheel_radius go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad! This was meant to be multiplied in the updateFromVel()
function. Fixed with d387750.
Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
Fixes #271.
Fixes #357.
I have updated the odometry implementation of the
diff_drive_controller
to fix the above two issues alongside improving the code's readability. This implementation is similar to that ofomni_wheel_drive_controller
.I have created some new methods and deprecated the older ones.
Should I also make similar changes to other controllers? If yes, should I do that in a separate PR?