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

Rework PID class API #246

Merged
merged 54 commits into from
Jan 29, 2025
Merged

Rework PID class API #246

merged 54 commits into from
Jan 29, 2025

Conversation

christophfroehlich
Copy link
Contributor

@christophfroehlich christophfroehlich commented Dec 7, 2024

While fixing the clang errors I realized that lots of implicit casts to computeCommand were used, and the typical usage was to pass something like period.nanoseconds() and convert it internally to seconds. Because introducing an overload with double dt as argument is ambiguous and might silently break user code, I decided to convert the class methods from camelCase to snake_case (the ros2_control standard), remove the uint64_t version but introduce the following new overloads which converts dt to seconds in a consistent way

  • double dt
  • rcl_duration_value_t dt_ns
  • rclcpp::Duration dt
  • std::chrono::nanoseconds dt_ns

I converted the method names of PidROS accordingly as well, but left the only rclcpp::Duration version there.

The old methods remain deprecated, this should not break anything in downstream packages.
AFAIK adding non-virtual methods should not be a problem regarding ABI break?

@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2024

Codecov Report

Attention: Patch coverage is 71.31474% with 72 lines in your changes missing coverage. Please review.

Project coverage is 72.47%. Comparing base (beb9767) to head (2a336f1).

Files with missing lines Patch % Lines
src/pid_ros.cpp 49.00% 51 Missing ⚠️
src/pid.cpp 63.15% 21 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           ros2-master     #246      +/-   ##
===============================================
- Coverage        75.02%   72.47%   -2.55%     
===============================================
  Files               24       24              
  Lines             1133     1239     +106     
  Branches            89       89              
===============================================
+ Hits               850      898      +48     
- Misses             236      294      +58     
  Partials            47       47              
Flag Coverage Δ
unittests 72.47% <71.31%> (-2.55%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/control_toolbox/pid.hpp 77.77% <ø> (ø)
include/control_toolbox/pid_ros.hpp 100.00% <ø> (ø)
test/pid_ros_parameters_tests.cpp 100.00% <100.00%> (ø)
test/pid_ros_publisher_tests.cpp 95.23% <100.00%> (ø)
test/pid_tests.cpp 100.00% <100.00%> (ø)
src/pid.cpp 78.18% <63.15%> (-15.07%) ⬇️
src/pid_ros.cpp 58.55% <49.00%> (-12.48%) ⬇️

Copy link

mergify bot commented Dec 7, 2024

This pull request is in conflict. Could you fix it @christophfroehlich?

@christophfroehlich christophfroehlich changed the title Add computeCommand with double dt_s argument Rework PID class API Dec 13, 2024
include/control_toolbox/pid.hpp Outdated Show resolved Hide resolved
include/control_toolbox/pid.hpp Outdated Show resolved Hide resolved
include/control_toolbox/pid.hpp Outdated Show resolved Hide resolved
include/control_toolbox/pid_ros.hpp Outdated Show resolved Hide resolved
include/control_toolbox/pid_ros.hpp Outdated Show resolved Hide resolved
include/control_toolbox/pid_ros.hpp Outdated Show resolved Hide resolved
src/pid.cpp Outdated Show resolved Hide resolved
src/pid_ros.cpp Outdated Show resolved Hide resolved
src/pid_ros.cpp Outdated Show resolved Hide resolved
src/pid_ros.cpp Outdated Show resolved Hide resolved
src/pid_ros.cpp Outdated Show resolved Hide resolved
Copy link

@ViktorCVS ViktorCVS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! All variable and function names have been appropriately replaced in every instance where they appear.

Copy link

mergify bot commented Jan 23, 2025

This pull request is in conflict. Could you fix it @christophfroehlich?

saikishor
saikishor previously approved these changes Jan 28, 2025
Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This reverts commit 15c94a4.
@christophfroehlich christophfroehlich merged commit 33cacae into ros2-master Jan 29, 2025
19 checks passed
@christophfroehlich christophfroehlich deleted the pid_double branch January 29, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants