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

Response to #40 #42

Merged
merged 1 commit into from
Apr 15, 2016
Merged

Response to #40 #42

merged 1 commit into from
Apr 15, 2016

Conversation

carlosjoserg
Copy link
Contributor

Could be that #40 happened mainly due to 2 things (well, 3, if you count my awkwardness):

  1. Lack of tests on command computation, as already requested by @adolfo-rt in Increase coverage of PID class test suite #41
  2. The computeCommand method has two signatures with almost a replica of code within -> Same code in two places requires update in two places -> The chance of making a mistake when updating increases.

In this initial PR both are addressed, there are 2 separated commits to easy the review.

First, in 9dc84fd, the coverage of the PID class test suite is increased with the following modification of current tests:

  • zeroITermBadIBoundsTest: I think that entering i_max < i_min should be prevented, or at least warned. A suggested change to avoid bad i-bounds is there commented because it would require a change in the setGains method return type to bool instead of void and the current implementation wouldn't pass the test. Another posibility would be to leave that return type and just throw a warning if i_max < i_min is passed.
  • integrationWindupTest: Now upper and lower bounds are tested.
  • integrationWindupZeroGainTest: Untouched. However, it looks to me it is useless with the current integral contribution implementation.
  • gainSettingCopyPIDTest: Makeup in names for readability + Added test on reset() method.

And the following additions, a new set of tests under the name CommandTest, hopefully well described with comments:

  • proportionalOnlyTest, integralOnlyTest, derivativeOnlyTest: Check that the command computed using each contribution independently is correct. Note that, they depend on the integral and differentiation schemes, and if they change, the tests might not be valid anymore.
  • completePIDTest: Few checks on the sum up of contributions. Same here, the test depends on the integral and differentiation schemes.

Second, in 7fe5e12, only one method does the PID command computation and writes to class members (except for p_error_last_), which is the one with the signature that allows users to pass a pre-computed error derivative. The other one calls this method passing the error derivative computed with an internal differentiation scheme. I couldn't find whether this is ROS-style compliant or not, and not sure if it affects critically the performance, but surely it will reduce the chance of making a mistake if the implementation is to be updated again.

PS: I didn't do anything with the DEPRECATED command computation methods.

@carlosjoserg
Copy link
Contributor Author

To make issue 2 in this PR clearer, check that, in #38, only one of the computeCommand methods is updated. So, if someone uses the other signature, the added feature wouldn't be available.

@paulbovbel
Copy link

+1, this supercedes #44 with more unit tests, so #44 can be closed if this is merged


Pid pid(1.0, 0.0, 0.0, -1.0, 0.0);
//// Do not allow this construction
Copy link
Member

Choose a reason for hiding this comment

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

Please either remove dead code, or bring it to a functional state.

@adolfo-rt
Copy link
Member

Could you please rebase against indigo-devel. I think it should be straightforward (or fast-forward, to be more precise ;-).

Many thanks for the extra tests.

@carlosjoserg
Copy link
Contributor Author

Sure.

I'll also delete 7fe5e12 since #44 was already merged, it was exactly the same.

@carlosjoserg
Copy link
Contributor Author

[update]

  • Rebased to indigo-devel (all tests passed)
  • Minor, changed the name of zeroITermBadIBoundsTest to ITermBadIBoundsTest
  • Deleted 7fe5e12 from PR

@carlosjoserg carlosjoserg changed the title [FOR DISCUSSION] Response to #40 Response to #40 Jul 16, 2015
@bmagyar
Copy link
Member

bmagyar commented Apr 14, 2016

I'm about to press some green buttons here. It seems that this PR got a bit forgotten, please raise a thumb if you also think it should be merged.


// If call again with same arguments
cmd = pid.computeCommand(-0.5, ros::Duration(1.0));
// Then expect the integration do it part doubling the command

Choose a reason for hiding this comment

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

Then expect the integral part doubles the command

Choose a reason for hiding this comment

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

or
Then expect the integration do its part doubling the command

@efernandez
Copy link

LGTM, but I've added a few comments regarding typos on the comments. @bmagyar Maybe you can fix them before merging.

All the tests look good. Thanks for the contribution.

@bmagyar
Copy link
Member

bmagyar commented Apr 15, 2016

Well I don't really have access to Carlos' branch, but I can fix it after I merged it! :)

Oh btw, merging...

@bmagyar bmagyar merged commit 2f90843 into ros-controls:indigo-devel Apr 15, 2016
@bmagyar
Copy link
Member

bmagyar commented Apr 15, 2016

Oh shoot, should have rebased this one... Nothing serious though, only that the history is not that pretty on this one.

@carlosjoserg
Copy link
Contributor Author

Hey, sorry I'm late for the party... thanks for the review and the merge!

@bmagyar
Copy link
Member

bmagyar commented Apr 18, 2016

No problem, thanks for your contribution!

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.

5 participants