-
Notifications
You must be signed in to change notification settings - Fork 11
Add the 'LinearFeedbackController' unit-tests #49
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
Add the 'LinearFeedbackController' unit-tests #49
Conversation
|
NOTE: Looking at the code of the |
|
Also, testing this is extremely redundant with the tests of both |
|
|
Rebased into humble-devel (includes #62) |
MaximilienNaveau
left a comment
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.
Unit-tests passing I approve!
| << (gravity_compensation ? "TRUE"sv : "FALSE"sv)); | ||
|
|
||
| // First call always calls PDController | ||
| EXPECT_EQ( |
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.
Is there a way to force formatter to do something better?
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.
If you use a loop inside a test, SCOPED_TRACE() is one way to provide a trace for user to what was the looped variable value when a test failed (see gtest).
I can also forward the string at the end each EXPECT_* call (EXPECT_EQ(...) << gravity_compensation;), but it would be cumbersome and very repetitive.
At the beginning, I used EXPECT_PRED*() in order to let GTest format the inputs parameters automatically when an expectation failed (the same one that I used to check for double vectors equality with rounding errors), but I chosed the revert to the simpler and more explicit way to ease the review process (with the direct .compute_control() method calls).
In fact, it could have looked something like this:
EXPECT_PRED4(
ComputeControlOn(
ctrl
EqualsNear(5e-6, ((1.0 - ratio) * expected.pd) + (ratio * expected.lf)))
),
when, sensor, control, gravity_compensation
);
And it would have output something along the lines of:
ComputeControlOn(
ctrl
EqualsNear(5e-6, ((1.0 - ratio) * expected.pd) + (ratio * expected.lf)))
)(when, sensor, control, gravity_compensation) is false, where
when is ...
sensor is ...
control is ...
gravity_compensation is ...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 think you misunderstood me. I meant to force clang format to format the text in a more readable way
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.
Ah, for this I don't know unfortunately, especially since we don't have any control over the format config file.
The only way I can think of is by encapsulating the code between clang-format off/on and do the formatting ourselves.
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.
Or just abbreviate the variables more in order to have a single line expression.
It adds the unit-tests for the LinearFeedbackController class.
Tests (TestSuite = LinearFeedbackControllerTest):
LinearFeedbackController()load(const ControllerParameters&) -> bool:set_initial_state(VectorXd const&,VectorXd const&) -> bool:compute_control(const TimePoint&, const Sensor&, const Control&, bool) -> const VectorXd&:IMPORTANT: All tests that are testing against non-nominal inputs have been DISABLED