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

Draft: Fix deprecation warnings in controllers from recent ros2_control variant changes. #1443

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kumar-sanjeeev
Copy link
Contributor

@kumar-sanjeeev kumar-sanjeeev commented Dec 22, 2024

  • Updated get_value and set_value in diff_drive_controller to fix deprecation warnings.

Fixes #1442

Copy link

codecov bot commented Dec 22, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 83.75%. Comparing base (eaeefdf) to head (1044e67).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...iff_drive_controller/src/diff_drive_controller.cpp 57.14% 7 Missing and 2 partials ⚠️
...ontrollers/src/joint_group_velocity_controller.cpp 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1443      +/-   ##
==========================================
- Coverage   83.83%   83.75%   -0.09%     
==========================================
  Files         122      122              
  Lines       11120    11139      +19     
  Branches      944      948       +4     
==========================================
+ Hits         9323     9329       +6     
- Misses       1489     1498       +9     
- Partials      308      312       +4     
Flag Coverage Δ
unittests 83.75% <50.00%> (-0.09%) ⬇️

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

Files with missing lines Coverage Δ
...ontrollers/src/joint_group_velocity_controller.cpp 60.00% <0.00%> (-12.23%) ⬇️
...iff_drive_controller/src/diff_drive_controller.cpp 69.28% <57.14%> (-1.41%) ⬇️

... and 5 files with indirect coverage changes

@saikishor saikishor changed the title Draft: Fix deprecation warnings in controllers from recent ros2_control variant changes. Draft: Fix deprecation warnings in controllers from recent ros2_control variant changes. Fixes: https://github.com/ros-controls/ros2_controllers/issues/1442 Dec 23, 2024
@saikishor saikishor changed the title Draft: Fix deprecation warnings in controllers from recent ros2_control variant changes. Fixes: https://github.com/ros-controls/ros2_controllers/issues/1442 Draft: Fix deprecation warnings in controllers from recent ros2_control variant changes. Dec 23, 2024
@saikishor
Copy link
Member

@kumar-sanjeeev I'm discussing with @christophfroehlich on the best way to address these get_value methods. We will get back to you soon. So, you can apply the same to other controllers

@kumar-sanjeeev
Copy link
Contributor Author

@kumar-sanjeeev I'm discussing with @christophfroehlich on the best way to address these get_value methods. We will get back to you soon. So, you can apply the same to other controllers

Okay, understood. I noticed that we also need to modify the test cases to suppress the warnings there as well.

const double left_feedback = registered_left_wheel_handles_[index].feedback.get().get_value();
const double right_feedback =
registered_right_wheel_handles_[index].feedback.get().get_value();
bool left_success = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we simplify this and use just a single bool variable if we don't use the information of left/right failure?
Please also add a comment here, that we only need the lambda functions here to be able to mark the double left/right_feedback variable as const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  bool success = true;
    // lambda function only to mark `double left_feedback` as `const`.
    const double left_feedback = [&]()
    {
      double temp{};
      success = registered_left_wheel_handles_[index].feedback.get().get_value(temp);
      return temp;
    }();

    // lambda function only to mark `double right_feedback` as `const`.
    const double right_feedback = [&]()
    {
      double temp{};
      success = registered_right_wheel_handles_[index].feedback.get().get_value(temp);
      return temp;
    }();

    if (!success)
    {
      RCLCPP_WARN(
        get_node()->get_logger(),
        "Error while fetching information from the state interfaces for %s wheel at index [%zu]",
        (index % 2 == 0) ? "left" : "right", index);
      return controller_interface::return_type::OK;
    }

@christophfroehlich Is this make sense ?

Copy link
Contributor Author

@kumar-sanjeeev kumar-sanjeeev Dec 23, 2024

Choose a reason for hiding this comment

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

while working on another controller, I noticed that I often need to implement a similar setup for get_value()across multiple places, wouldn't it be a good idea to create a separate reusable function for this? We could then import it wherever needed, which might also be helpful in test files.

for example ( in this case I created single lambda)

    bool success = true;

    // lambda function only to mark return as const
    auto fetch_feedback = [&](const auto & wheel_handles, size_t index) -> double
    {
      double temp{};
      success = wheel_handles[index].feedback.get().get_value(temp);
      return temp;
    };

    for (size_t index = 0; index < static_cast<size_t>(wheels_per_side_); ++index)
    {
      const double left_feedback = fetch_feedback(registered_left_wheel_handles_, index);
      const double right_feedback = fetch_feedback(registered_right_wheel_handles_, index);

      if (!success)
      {
        RCLCPP_WARN(
          get_node()->get_logger(),
          "Error while fetching information from the state interfaces for %s wheel at index [%zu]",
          (index % 2 == 0) ? "left" : "right", index);
        return controller_interface::return_type::OK;
      }

what do you think?

Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

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

We need to discuss API further. Thank you for making these changes on a draft PR @kumar-sanjeeev !

I really don't like what this summary tells us:
+44 -7 to achieve the exact same thing we have now.

We need to add this to the framework before it blows up the codebase.

Ideally it would not increase our overall line of code but allow for failures & error reporting to come through or be reported in the background.

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.

Cleanup all the deprecations warning from the recent ros2_control variant changes
4 participants