Export pid gains as reference#2020
Export pid gains as reference#2020kumar-sanjeeev wants to merge 11 commits intoros-controls:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2020 +/- ##
==========================================
- Coverage 85.13% 85.06% -0.07%
==========================================
Files 144 144
Lines 13968 14021 +53
Branches 1201 1211 +10
==========================================
+ Hits 11891 11927 +36
- Misses 1670 1685 +15
- Partials 407 409 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
christophfroehlich
left a comment
There was a problem hiding this comment.
In principle, this looks fine for me.
| switch (gain_type) | ||
| { | ||
| case 0: // P gain | ||
| pids_[i]->set_gains( |
There was a problem hiding this comment.
Am I missing something? I think there is no functionality to skip setting the gain by passing a NaN value?
There was a problem hiding this comment.
@christophfroehlich , you are right. I am thinking of following fix. What do you think ?
| pids_[i]->set_gains( | |
| auto current_pid_gains = pids_[i]->get_gains(); | |
| for (size_t j = 0; j < GAIN_INTERFACES.size(); ++j) | |
| { | |
| const size_t buffer_index = gains_start_index + i + j * dof_; | |
| const double new_gain_value = reference_interfaces_[buffer_index]; | |
| if (std::isfinite(new_gain_value)) | |
| { | |
| const size_t gain_type = GAIN_TYPES_INDEX[j]; | |
| switch (gain_type) | |
| { | |
| case 0: // P gain | |
| current_pid_gains.p_gain_ = new_gain_value; | |
| pids_[i]->set_gains(current_pid_gains);``` |
understood. I am trying to understand one thing, in my current implementation, when I set if (params_.export_gain_references)
{
total_reference_size += dof_ * GAIN_INTERFACES.size();
}
reference_interfaces_.resize(total_reference_size, std::numeric_limits<double>::quiet_NaN());Because of this, some of the existing tests are failing. If this implementation is correct, should I update the tests so that they handle both cases Test config that I used to reproduce the failure case, along with the corresponding log: test_pid_controller:
ros__parameters:
dof_names:
- joint1
command_interface: position
reference_and_state_interfaces: ["position"]
export_gain_references: true
gains:
joint1: {p: 1.0, i: 2.0, d: 3.0, u_clamp_max: 5.0, u_clamp_min: -5.0}
/workspaces/ros2_control_rolling_dev_docker_ws/src/ros-controls/ros2_controllers/pid_controller/test/test_pid_controller.cpp:88: Failure
Expected equality of these values:
ref_if_conf.size()
Which is: 4
dof_state_values_.size()
Which is: 1
[ FAILED ] PidControllerTest.check_exported_interfaces (6 ms) |
|
I also think implementation is correct @kumar-sanjeeev, Overall, I think some tests need to be updated, but this is just my assumption. |
9914ad5 to
79473e8
Compare
|
hi @christophfroehlich, I have tried few different ways to fix the ABI check, but still haven’t succeeded. Do you have any recommendations? Or is it okay in this feature request, if it breaks ? |
|
The implementation is complete from my side. Whenever you have time to review it, please let me know if there is anything I may have missed or should improve. |
christophfroehlich
left a comment
There was a problem hiding this comment.
Another quick look and question
| if (std::isfinite(new_gain_value)) | ||
| { | ||
| const size_t gain_type = GAIN_TYPES_INDEX[j]; | ||
| switch (gain_type) | ||
| { | ||
| case 0: // P gain | ||
| current_pid_gains.p_gain_ = new_gain_value; | ||
| pids_[i]->set_gains(current_pid_gains); | ||
| break; | ||
| case 1: // I gain | ||
| current_pid_gains.i_gain_ = new_gain_value; | ||
| pids_[i]->set_gains(current_pid_gains); | ||
| break; | ||
| case 2: // D gain | ||
| current_pid_gains.d_gain_ = new_gain_value; | ||
| pids_[i]->set_gains(current_pid_gains); | ||
| break; | ||
| } |
There was a problem hiding this comment.
This is part is not covered by tests. Can you please think of a testcase in doing so? Friending the class and checking pids_ variable might be possible.
There was a problem hiding this comment.
I was on vacation, will look into comments and get back to you
| description: "Individual state publisher activation for each DOF. If true, the controller will publish the state of each DOF to the topic `/<controller_name>/<dof_name>/pid_state`." | ||
| } | ||
| export_params: | ||
| gain_references: { |
There was a problem hiding this comment.
do we really need this parameter? can't they always be exported, and if they are not claimed they just remain nan?
|
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |
|
This pull request is in conflict. Could you fix it @kumar-sanjeeev? |
|
@kumar-sanjeeev any updates on this? |
This PR includes the following changes:
export_gain_referencesto enable or disable the export of gains (p, i, d) as references.update_and_write_commandsfunction based on the value of export_gain_references.export_gain_references=trueandexport_gain_references=false