Skip to content

diff_drive_controller: set parameters as read_only#2293

Merged
christophfroehlich merged 7 commits intoros-controls:masterfrom
kamal2730:fix/diff-drive-read-only-params
Apr 25, 2026
Merged

diff_drive_controller: set parameters as read_only#2293
christophfroehlich merged 7 commits intoros-controls:masterfrom
kamal2730:fix/diff-drive-read-only-params

Conversation

@kamal2730
Copy link
Copy Markdown
Contributor

Add read_only: true to all 36 parameters in diff_drive_controller for consistency with other drive controllers.
Fixes #1696

Description

Right now I added read_only: true for all params because currently, the controller does not support runtime parameter updates for SpeedLimiter-related parameters. This would require adding try_update_params() to the RT loop and implementing a set_params() method in the SpeedLimiter class. If needed, I will address this in a follow-up PR.

Fixes #1696

Is this user-facing behavior change?

NO

Did you use Generative AI?

No

Additional Information

TODOs

To send us a pull request, please:

  • Fork the repository.
  • Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
  • Ensure local tests pass. (colcon test and pre-commit run (requires you to install pre-commit by pip3 install pre-commit)
  • Commit to your fork using clear commit messages.
  • Send a pull request, answering any default questions in the pull request interface.
  • Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.

Add read_only: true to all 36 parameters in diff_drive_controller
for consistency with other drive controllers.
Fixes ros-controls#1696
Copy link
Copy Markdown
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.

Please evaluate which parameters make sense to be reconfigured at runtime, see my comment here
#2074 (review)

@kamal2730 kamal2730 changed the title diff_drive_controller: set all parameters as read_only diff_drive_controller: set parameters as read_only Apr 14, 2026
@kamal2730
Copy link
Copy Markdown
Contributor Author

I evaluated which parameters make sense to be reconfigured at runtime and identified 19 parameters that can be made dynamic:
Member variable updates:

  • cmd_vel_timeout

Direct from params_ (auto-updates):

  • publish_limited_velocity
  • enable_odom_tf'

SpeedLimiter set_params() updates:

  • linear.x.max_velocity
  • linear.x.min_velocity
  • linear.x.max_acceleration
  • linear.x.max_deceleration
  • linear.x.max_acceleration_reverse
  • linear.x.max_deceleration_reverse
  • linear.x.max_jerk
  • linear.x.min_jerk
  • angular.z.max_velocity
  • angular.z.min_velocity
  • angular.z.max_acceleration
  • angular.z.max_deceleration
  • angular.z.max_acceleration_reverse
  • angular.z.max_deceleration_reverse
  • angular.z.max_jerk
  • angular.z.min_jerk

Implementation Plan

I will handle the runtime updates in update_and_write_commands() by:

  1. Adding if (param_listener_->try_update_params(params_)) check
  2. Updating cmd_vel_timeout member variable
  3. Calling set_params() on SpeedLimiter objects for velocity/acceleration/jerk limits
  4. publish_limited_velocity and enable_odom_tf auto-update with params_
    Does this approach look good to you?

@christophfroehlich
Copy link
Copy Markdown
Member

Sounds good. Only, I'm not sure about cmd_vel_timeout, but both options are fine for me.

…arameters

Add set_params() method to SpeedLimiter class for updating parameters
at runtime. Add try_update_params() in RT loop to detect and apply
parameter changes on-the-fly.
Dynamic parameters:
- enable_odom_tf, cmd_vel_timeout, publish_limited_velocity
- linear.x.* (8 params)
- angular.z.* (8 params)
Fixes ros-controls#1696
@kamal2730
Copy link
Copy Markdown
Contributor Author

@christophfroehlich Added parameter handling for runtime updates. Could you review?

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 92.45283% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.01%. Comparing base (27ea539) to head (ba1b901).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...iff_drive_controller/src/diff_drive_controller.cpp 50.00% 2 Missing and 1 partial ⚠️
...ive_controller/test/test_diff_drive_controller.cpp 97.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2293      +/-   ##
==========================================
+ Coverage   84.99%   85.01%   +0.02%     
==========================================
  Files         145      145              
  Lines       15186    15234      +48     
  Branches     1331     1336       +5     
==========================================
+ Hits        12907    12951      +44     
- Misses       1789     1791       +2     
- Partials      490      492       +2     
Flag Coverage Δ
unittests 85.01% <92.45%> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
...er/include/diff_drive_controller/speed_limiter.hpp 100.00% <100.00%> (ø)
...ive_controller/test/test_diff_drive_controller.cpp 95.07% <97.77%> (+0.31%) ⬆️
...iff_drive_controller/src/diff_drive_controller.cpp 79.59% <50.00%> (-0.53%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
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.

looks fine for me, but could you please add a test for the parameter updates at runtime? have a look at existing tests with specified limits, copy it, and extend it with another update call with changed limits.

@kamal2730
Copy link
Copy Markdown
Contributor Author

Sure, even I was thinking the same 😅

@kamal2730
Copy link
Copy Markdown
Contributor Author

@christophfroehlich Added test for runtime parameter updates of speed limiter. Could you please review?

Copy link
Copy Markdown
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.

Thank you! LGTM, I only have 2 nitpicks about readability.

publish(linear, 0.0);
// wait for msg is be published to the system
controller_->wait_for_twist(executor);
const double time_dec = 1.0 / 4.0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const double time_dec = 1.0 / 4.0;
const double time_dec = 1.0 / std::abs(max_deceleration);

Comment thread diff_drive_controller/test/test_diff_drive_controller.cpp Outdated
@kamal2730
Copy link
Copy Markdown
Contributor Author

Hello @christophfroehlich , I’ve addressed the requested changes. Ready for review!

Copy link
Copy Markdown
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.

perfect, thank you!

@christophfroehlich christophfroehlich merged commit ede5b33 into ros-controls:master Apr 25, 2026
15 of 19 checks passed
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.

DiffDrive: Check read_only key for parameters

2 participants