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

Add the LFController unit tests #46

Open
wants to merge 64 commits into
base: humble-devel
Choose a base branch
from

Conversation

ArthurVal
Copy link
Collaborator

@ArthurVal ArthurVal commented Dec 11, 2024

Base: 43151c1

It adds the unit-tests for the LFController class.

Tests (Test suite = LFControllerTest):

  • LFController()
    • Ctor
  • void initialize(const RobotModelBuilder::SharedPtr&):
    • InitializeNullptr - Nullptr as RobotModelBuilder
      • Seg fault
    • InitializeEmptyModel - Empty RobotModelBuilder
      • Not throwing anything
    • Initialize - Valid RobotModel (Talos)
  • const VectorXd& compute_control(const Sensor& sensor_msg, const Control& control_msg)
    • ComputeControlNotInitialized - Not using .initialize() beforehands
      • Seg fault
    • ComputeControlNoInput - With model but no inputs
      • Aborted -> Asserts coming from Eigen
    • ComputeControlUnknownJoints - Refer to unknown joints w.r.t. initialize()
      • Not reporting any error
    • ComputeControlSizeMismatch - Mismatch sensor/control values (size/joints names/... ?)
      • Eigen assert size mismatch
    • ComputeControlSpecialDouble - Put Nan/Inf inside sensor/control
      • No Free Flyer: No errors
      • With Free Flyer: Eigen assert size mismatch
    • ComputeControl - Valid test

IMPORTANT: All tests that are testing against non-nominal inputs have been DISABLED

@ArthurVal ArthurVal changed the title Add/lf controller unittests Add the LFController unit tests Dec 11, 2024
@ArthurVal ArthurVal added the enhancement New feature or request label Dec 16, 2024
@ArthurVal ArthurVal force-pushed the add/lf_controller_unittests branch from 1766749 to afb73ba Compare January 7, 2025 10:09
@ArthurVal
Copy link
Collaborator Author

ArthurVal commented Jan 7, 2025

NOTE: Rebased onto humble-devel (43151c1)

@ArthurVal
Copy link
Collaborator Author

@Kotochleb / @MaximilienNaveau
I'll need your help to complete the tests of the LF controller, since I don't know how to generate the inputs of the compute_control(...) function in order to make it work/fail.

I added some template, with TOTO tags for it.

@ArthurVal ArthurVal self-assigned this Jan 7, 2025
tests/test_lf_controller.cpp Outdated Show resolved Hide resolved
@ArthurVal
Copy link
Collaborator Author

@Kotochleb / @MaximilienNaveau
I implemented the tests but disabled all but the 'valid' tests (i.e. tests that are taking 'normal' data) since they were crashing due to assert/seg faults.
There is still an issue with compute_control() and free flyer matrices dimensions but I think this is an issue with the LFController code, not the tests (following my discussions on the theory with @Kotochleb).

@ArthurVal ArthurVal marked this pull request as ready for review January 20, 2025 09:45
tests/utils/lf_controller.hpp Show resolved Hide resolved
Comment on lines +130 to +140
wrong_control.feedback_gain.bottomRows<1>() =
::Eigen::VectorXd::Random(wrong_control.feedback_gain.cols());

wrong_control.feedback_gain.rightCols<1>() =
::Eigen::VectorXd::Random(wrong_control.feedback_gain.rows());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
wrong_control.feedback_gain.bottomRows<1>() =
::Eigen::VectorXd::Random(wrong_control.feedback_gain.cols());
wrong_control.feedback_gain.rightCols<1>() =
::Eigen::VectorXd::Random(wrong_control.feedback_gain.rows());
wrong_control.feedback_gain.bottomRows<1>() =
::Eigen::VectorXd::Random(wrong_control.feedback_gain.cols() + 1);
wrong_control.feedback_gain.rightCols<1>() =
::Eigen::VectorXd::Random(wrong_control.feedback_gain.rows());

Shouldn't at least one of those have +1? It seems that you are leaving value in bottom right corner unset. Even though it is very minor issue I think it would be nice to fix it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, because of the Grow() above, the sizes match.
It's the opposite in fact, we are updating the bottom right element twice, but I'd say that it's not very important.

Also I guess Eigen would have report a size mismatch if it was the case (not sure ?).

Copy link
Collaborator

Choose a reason for hiding this comment

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

At this point, I am also not 100% sure, but I wouldn't assume it's all fine. When you compile in RelWithDebInfo or Release I think Eigen is stopping dynamic size checking. Maybe a good idea would to enforce that tests are build in Debug so that all possible asserts will be triggered. From my experience if Debug works all the rest will as well

tests/test_lf_controller.cpp Show resolved Hide resolved
tests/utils/eigen_conversions.hpp Outdated Show resolved Hide resolved
tests/utils/eigen_conversions.hpp Outdated Show resolved Hide resolved
tests/utils/robot_model.hpp Outdated Show resolved Hide resolved
@ArthurVal ArthurVal force-pushed the add/lf_controller_unittests branch from 0c3dc11 to 2049ffe Compare January 31, 2025 07:38
@ArthurVal
Copy link
Collaborator Author

Rebased into humble-devel (DISABLED pd_controller tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants