-
Notifications
You must be signed in to change notification settings - Fork 106
[Pid] Save i_term
instead of error integral
#294
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,8 +273,8 @@ void PidROS::publish_pid_state(double cmd, double error, rclcpp::Duration dt) | |
{ | ||
Pid::Gains gains = pid_.get_gains(); | ||
|
||
double p_error, i_error, d_error; | ||
get_current_pid_errors(p_error, i_error, d_error); | ||
double p_error, i_term, d_error; | ||
get_current_pid_errors(p_error, i_term, d_error); | ||
|
||
// Publish controller state if configured | ||
if (rt_state_pub_) { | ||
|
@@ -284,7 +284,7 @@ void PidROS::publish_pid_state(double cmd, double error, rclcpp::Duration dt) | |
rt_state_pub_->msg_.error = error; | ||
rt_state_pub_->msg_.error_dot = d_error; | ||
rt_state_pub_->msg_.p_error = p_error; | ||
rt_state_pub_->msg_.i_error = i_error; | ||
rt_state_pub_->msg_.i_error = i_term; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you said you will change the message in a different PR since this is really weighted i-error. |
||
rt_state_pub_->msg_.d_error = d_error; | ||
rt_state_pub_->msg_.p_term = gains.p_gain_; | ||
rt_state_pub_->msg_.i_term = gains.i_gain_; | ||
|
@@ -314,8 +314,8 @@ void PidROS::print_values() | |
{ | ||
Pid::Gains gains = pid_.get_gains(); | ||
|
||
double p_error, i_error, d_error; | ||
get_current_pid_errors(p_error, i_error, d_error); | ||
double p_error, i_term, d_error; | ||
get_current_pid_errors(p_error, i_term, d_error); | ||
|
||
RCLCPP_INFO_STREAM(node_logging_->get_logger(), "Current Values of PID template:\n" | ||
<< " P Gain: " << gains.p_gain_ << "\n" | ||
|
@@ -326,7 +326,7 @@ void PidROS::print_values() | |
<< " Antiwindup: " << gains.antiwindup_ | ||
<< "\n" | ||
<< " P_Error: " << p_error << "\n" | ||
<< " I_Error: " << i_error << "\n" | ||
<< " i_term: " << i_term << "\n" | ||
<< " D_Error: " << d_error << "\n" | ||
<< " Command: " << get_current_cmd();); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why i_term is being clamped again here when it was clamped above when antiwindup is true. Shouldn't it only be clamped when antiwindup is true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left that to keep the current behavior, it was clamped even with antiwindup being true.
from the docstring:
this was already questioned in #276 and I didn't want to change this behavior in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I understand and it shouldn't be changed in this PR. The only minor comment I would make is if antiwindup is false, the iterm is not clamped but the use of it is clamped when calculating output. That is slightly different behavior than before where the iterm was always clamped. Practically, I don't think it makes a difference.
I definitely think the antiwindup behavior needs to be fixed and I guess it will be addressed in #276. With this PR and the earlier behavior, the antiwindup flag, in practical terms, doesn't change anything. Antiwindup is always being implemented regardless of the flag.