Skip to content

Conversation

@thedevmystic
Copy link

@thedevmystic thedevmystic commented Nov 29, 2025

Hello! Respected Maintainers and Reviewers!
Again, this is Surya!

This PR addresses the issue #2029 opened in ros2_controllers.

It fixes,
The promise of description: "Maximum deceleration in reverse direction. If not set, -max_deceleration will be used." given in diff_drive_controller.

min_first_derivative_pos_ = -min_first_derivative_neg_;
}
if (has_first_derivative_limits_ && min_first_derivative_pos_ > max_first_derivative_neg_)
if (has_first_derivative_limits_ && asym_given &&
Copy link
Author

Choose a reason for hiding this comment

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

I didn't removed it, instead I patched it.

But I suggest this is redundant. As we already has set the min_first_derivative_pos_ and, max_first_derivative_neg_.

This is just my opinion, and I welcome yours too.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the new criterion is necessary?

Copy link
Member

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Can you please add tests for this?

min_first_derivative_pos_ = -min_first_derivative_neg_;
}
if (has_first_derivative_limits_ && min_first_derivative_pos_ > max_first_derivative_neg_)
if (has_first_derivative_limits_ && asym_given &&
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (has_first_derivative_limits_ && asym_given &&
if (asym_given &&

Isn't this redundant, too? (L208)

min_first_derivative_pos_ = -min_first_derivative_neg_;
}
if (has_first_derivative_limits_ && min_first_derivative_pos_ > max_first_derivative_neg_)
if (has_first_derivative_limits_ && asym_given &&
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the new criterion is necessary?

@thedevmystic
Copy link
Author

I think it is necessary, because without this we got failure in tests, where failure shouldn't be expected. Like,

Without asym_given:

/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/rate_limiter.cpp:23
    Expected: control_toolbox::RateLimiter limiter( -1.0, std::numeric_limits<double>::quiet_NaN(), -1.0, 1.0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), -1.0, 1.0) doesn't throw an exception.
      Actual: it throws.
    /home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/rate_limiter.cpp:28
    Expected: control_toolbox::RateLimiter limiter( std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), -1.0, 1.0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), -1.0, 1.0) doesn't throw an exception.
      Actual: it throws.
    /home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/rate_limiter.cpp:33
    Expected: control_toolbox::RateLimiter limiter( std::numeric_limits<double>::quiet_NaN(), 1.0, -1.0, 1.0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), -1.0, 1.0) doesn't throw an exception.
      Actual: it throws.

And so on...

Test Summary:

Summary: 90 tests, 0 errors, 6 failures, 0 skipped

The reason:

>>>
- control_toolbox.RateLimiterTest testValueLimits
  <<< failure message
    unknown file
    C++ exception with description "Invalid first derivative limits" thrown in the test body.

This arises because we are using asymmetric limits, but the validation expects symmetric (This is my assumption).

The validation check itself seems logically flawed. So, I added the asym_given check. After this check all tests passed.

I also think, I'm just delegating the error. But I don't have any other plan under my sleeves. So, if you have any ideas or plans, please share it with me.

Thanks, @christophfroehlich!

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.88%. Comparing base (91ef18a) to head (c9472fc).

Files with missing lines Patch % Lines
...l_toolbox/include/control_toolbox/rate_limiter.hpp 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #549      +/-   ##
==========================================
+ Coverage   83.85%   83.88%   +0.03%     
==========================================
  Files          30       30              
  Lines        2094     2098       +4     
  Branches      112      112              
==========================================
+ Hits         1756     1760       +4     
  Misses        268      268              
  Partials       70       70              
Flag Coverage Δ
unittests 83.88% <85.71%> (+0.03%) ⬆️

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

Files with missing lines Coverage Δ
...l_toolbox/include/control_toolbox/rate_limiter.hpp 74.62% <85.71%> (+1.61%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants