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

Added LWA frame convention in Contact1D #1172

Merged
merged 2 commits into from
Oct 28, 2023

Conversation

skleff1994
Copy link
Contributor

@skleff1994 skleff1994 commented Oct 16, 2023

This PR just adds the LWA / WORLD convention in the Contact1D. I also updated the bindings & unittests accordingly (the Contact1D model was only available in LOCAL).

Note: This completes the unfinished work of #1054

@cmastalli
Copy link
Member

Hi @skleff1994,

Thanks for creating again this PR!

Could you check locally that all tests pass before pushing the code?
The reason is that a few jobs are running using Github action, and we don't want to reach the limits for free accounts.

@cmastalli cmastalli self-requested a review October 19, 2023 11:02
@skleff1994
Copy link
Contributor Author

Hi @cmastalli

Thank you for reviewing this PR.

Sorry about that, but I don't understand why the CI is not passing. All unittests pass locally on my machine (in Debug mode) as seen below

Test project /home/skleff/libs/crocoddyl/build_v2
      Start  1: test_states
 1/37 Test  #1: test_states ......................   Passed    2.23 sec
      Start  2: test_actuation
 2/37 Test  #2: test_actuation ...................   Passed    1.36 sec
      Start  3: test_activations
 3/37 Test  #3: test_activations .................   Passed    0.02 sec
      Start  4: test_residuals
 4/37 Test  #4: test_residuals ...................   Passed  718.71 sec
      Start  5: test_costs
 5/37 Test  #5: test_costs .......................   Passed  1193.45 sec
      Start  6: test_costs_noFF
 6/37 Test  #6: test_costs_noFF ..................   Passed    4.84 sec
      Start  7: test_costs_collision
 7/37 Test  #7: test_costs_collision .............   Passed   12.25 sec
      Start  8: test_cost_sum
 8/37 Test  #8: test_cost_sum ....................   Passed    6.30 sec
      Start  9: test_constraints
 9/37 Test  #9: test_constraints .................   Passed  259.61 sec
      Start 10: test_constraint_manager
10/37 Test #10: test_constraint_manager ..........   Passed    5.60 sec
      Start 11: test_contacts
11/37 Test #11: test_contacts ....................   Passed   79.38 sec
      Start 12: test_controls
12/37 Test #12: test_controls ....................   Passed    0.02 sec
      Start 13: test_impulses
13/37 Test #13: test_impulses ....................   Passed    3.46 sec
      Start 14: test_multiple_contacts
14/37 Test #14: test_multiple_contacts ...........   Passed    1.67 sec
      Start 15: test_multiple_impulses
15/37 Test #15: test_multiple_impulses ...........   Passed    1.93 sec
      Start 16: test_contact_costs
16/37 Test #16: test_contact_costs ...............   Passed  149.07 sec
      Start 17: test_impulse_costs
17/37 Test #17: test_impulse_costs ...............   Passed  118.53 sec
      Start 18: test_contact_constraints
18/37 Test #18: test_contact_constraints .........   Passed   38.73 sec
      Start 19: test_impulse_constraints
19/37 Test #19: test_impulse_constraints .........   Passed   17.77 sec
      Start 20: test_actions
20/37 Test #20: test_actions .....................   Passed  548.25 sec
      Start 21: test_diff_actions
21/37 Test #21: test_diff_actions ................   Passed   30.67 sec
      Start 22: test_problem
22/37 Test #22: test_problem .....................   Passed  391.49 sec
      Start 23: test_cop_support
23/37 Test #23: test_cop_support .................   Passed    0.01 sec
      Start 24: test_friction_cone
24/37 Test #24: test_friction_cone ...............   Passed    0.01 sec
      Start 25: test_wrench_cone
25/37 Test #25: test_wrench_cone .................   Passed    0.02 sec
      Start 26: test_boxqp
26/37 Test #26: test_boxqp .......................   Passed    0.02 sec
      Start 27: test_solvers
27/37 Test #27: test_solvers .....................   Passed    9.17 sec
      Start 28: test_pybinds_states
28/37 Test #28: test_pybinds_states ..............   Passed    1.55 sec
      Start 29: test_pybinds_actuations
29/37 Test #29: test_pybinds_actuations ..........   Passed    1.40 sec
      Start 30: test_pybinds_actions
30/37 Test #30: test_pybinds_actions .............   Passed    6.93 sec
      Start 31: test_pybinds_shooting
31/37 Test #31: test_pybinds_shooting ............   Passed    1.41 sec
      Start 32: test_pybinds_solvers
32/37 Test #32: test_pybinds_solvers .............   Passed    4.70 sec
      Start 33: test_pybinds_costs
33/37 Test #33: test_pybinds_costs ...............   Passed    4.22 sec
      Start 34: test_pybinds_contacts
34/37 Test #34: test_pybinds_contacts ............   Passed    1.93 sec
      Start 35: test_pybinds_impulses
35/37 Test #35: test_pybinds_impulses ............   Passed    1.88 sec
      Start 36: test_pybinds_squashing
36/37 Test #36: test_pybinds_squashing ...........   Passed    0.46 sec
      Start 37: test_pybinds_copy
37/37 Test #37: test_pybinds_copy ................   Passed    0.46 sec

100% tests passed, 0 tests failed out of 37

I compiled with the following flags on Ubuntu 20.04
cmake .. -DCMAKE_INSTALL_PREFIX=$VIRTUAL_ENV -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DBUILD_WITH_MULTITHREADS=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

Can you please let me know how I can debug the checks that do not pass?

@olivier-stasse
Copy link
Contributor

olivier-stasse commented Oct 20, 2023

Dear @skleff1994 you can click on Details links related to the checks.

1/ You have formatting problems which are easily fixed by installing pre-commit on your machine. Please see: https://pre-commit.com/ This is allowing an uniform C++ coding style whatever is your favorite IDE.

2/ Checking simply on the Details you will see that for 22.04 on the LAAS CI:
https://gitlab.laas.fr/loco-3d/crocoddyl/-/jobs/215677#L2588
Your PR trigger the following error:

TypeError: No to_python (by-value) converter found for C++ type: crocoddyl::python::ContactModelAbstract_wrap

It is related to test test_deepcopy
This test does not appear in the list you gave.

@cmastalli
Copy link
Member

It is related to test test_deepcopy
This test does not appear in the list you gave.

test_deepcopy is inside test_pybinds_copy.
The issue is we cannot copy abstract classes, i.e., there is an error introduced in the unit test.

@@ -317,7 +317,13 @@ class ContactsTest(CopyModelTestCase):
MODEL.append(crocoddyl.ContactModelMultiple(state, actuation.nu))
COLLECTOR.append(pdata)
MODEL.append(
crocoddyl.ContactModel1D(state, frame_id, 1.0, actuation.nu, np.zeros(2))
crocoddyl.ContactModelAbstract(state, pinocchio.LOCAL, 3, actuation.nu)
Copy link
Member

Choose a reason for hiding this comment

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

Remove this line. This should fix errors in the CI.

Copy link
Member

@cmastalli cmastalli left a comment

Choose a reason for hiding this comment

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

Thanks for writing a clear PR, @skleff1994

Everything looks alright to me.
However, I highly suggest extending this contact model to an arbitrary constraint axis.
What do you think? See my comment below.

include/crocoddyl/multibody/contacts/contact-1d.hpp Outdated Show resolved Hide resolved
include/crocoddyl/multibody/contacts/contact-1d.hpp Outdated Show resolved Hide resolved
}
switch (type_) {
case pinocchio::ReferenceFrame::LOCAL:
d->da0_dx.row(0) = d->da0_local_dx.row(2);
Copy link
Member

Choose a reason for hiding this comment

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

Should we always assume constraints in Z?

It would be useful if this could be configured via a rotation matrix moving the z-axis.
This will require

  • including this information in the constructors and
  • writing unit tests with random rotation matrix.

Could you handle this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree . I can handle this

Copy link
Member

Choose a reason for hiding this comment

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

Please ping me when this is done. Thanks!

@skleff1994 skleff1994 force-pushed the skleff/contact1d branch 2 times, most recently from 4165ad0 to 8cdecdb Compare October 25, 2023 23:10
Copy link
Member

@cmastalli cmastalli left a comment

Choose a reason for hiding this comment

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

The summary of actions is:

  1. Revert the proposed change in the constructor API to a vector
  2. Include a new constructor where the rotation matrix is assumed to be the identity matrix.
  3. Clean up some added files.
  4. Adapt the unit-test and Python contact models as suggested in points 1 and 2.

Please ping me when you're done.
Thanks!

Testing/Temporary/CTestCostData.txt Outdated Show resolved Hide resolved
bindings/python/crocoddyl/utils/__init__.py Outdated Show resolved Hide resolved
include/crocoddyl/multibody/contacts/contact-1d.hpp Outdated Show resolved Hide resolved
include/crocoddyl/multibody/contacts/contact-1d.hxx Outdated Show resolved Hide resolved
include/crocoddyl/multibody/contacts/contact-1d.hpp Outdated Show resolved Hide resolved
include/crocoddyl/multibody/contacts/contact-1d.hpp Outdated Show resolved Hide resolved
include/crocoddyl/multibody/contacts/contact-1d.hpp Outdated Show resolved Hide resolved
@skleff1994
Copy link
Contributor Author

skleff1994 commented Oct 26, 2023

@cmastalli I addressed the changes you requested, however I'm not sure what happened - my 2 local commits turned into thousands of commits in this PR . Is it related to the rewriting of the git history you suggested in your comment #1172 (comment) ?

I did :
git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch Testing/Temporary/CTestCostData.txt' HEAD

I will try a git rebase

@cmastalli
Copy link
Member

@cmastalli I addressed the changes you requested, however I'm not sure what happened - my 2 local commits turned into thousands of commits in this PR . Is it related to the rewriting of the git history you suggested in your comment #1172 (comment) ?

I did : git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch Testing/Temporary/CTestCostData.txt' HEAD

I will try a git rebase

I understand. Please remove this commit and then make a commit that removes the file. This should solve the problem.

@skleff1994
Copy link
Contributor Author

skleff1994 commented Oct 27, 2023

@cmastalli I deleted the commit but it didn't solve the issue

I will squash my commits and cherry-pick after a git reset --hard onto devel

… unittests

fixed Contact1D unittests in LWA / WORLD

fixed contact1d in python test

remove ContactModelAbstract from copy test + changed HAL link to paper ref in contact models 1d, 3d, 6d

added rotation matrix for contact1D + updated bindings + unittests accordingly

fixed 1d force derivatives

fixed 1D force derivatives with rotation

fixed bindings and unittests for contact1d

removed content of __init__.py and fixed import in contact python test
@skleff1994
Copy link
Contributor Author

Ok I believe the rebase + reset + cherry-pick fixed the issue @cmastalli

Copy link
Member

@cmastalli cmastalli left a comment

Choose a reason for hiding this comment

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

Thanks, @skleff1994 !

It looks like everything is alright.
Let's merge this if the CI passes.

@cmastalli cmastalli merged commit 06feac6 into loco-3d:devel Oct 28, 2023
8 checks passed
nim65s added a commit to nim65s/robotpkg that referenced this pull request Jan 27, 2024
Upstream changes:

    ## [2.0.2] - 2023-12-07

    * Added nu, ng, and nh setters for Python bindings in loco-3d/crocoddyl#1192
    * Added CHANGELOG.md in loco-3d/crocoddyl#1188
    * Supported nu==0 in actuation models in loco-3d/crocoddyl#1188
    * Included Python bindings for Crocoddyl exceptions by cmastalli in loco-3d/crocoddyl#1186
    * Updated cmake submodule update by jcarpentier in loco-3d/crocoddyl#1186
    * Fixed getters for contraints bounds by skleff1994 in loco-3d/crocoddyl#1180
    * Extended solver abstract and callbacks for arbitrary solvers by cmastalli in loco-3d/crocoddyl#1179
    * Fixed the check of pair_id in collision residual by ArthurH91 in loco-3d/crocoddyl#1178
    * Exploited control-residual structure when computing Lu, Luu by cmastalli in loco-3d/crocoddyl#1176
    * Added LWA fram convention and introduced different axis for 1d contacts by skleff1994 in loco-3d/crocoddyl#1172
    * Python bindings for setting control bounds by cmastalli in loco-3d/crocoddyl#1171
    * Fixed missed scalar in cost sum and activation data by cmastalli in loco-3d/crocoddyl#1165
    * Added actuation unit tests by cmastalli in loco-3d/crocoddyl#1161
    * Introduced method for obtaining the dimension of floating-bases by cmastalli in loco-3d/crocoddyl#1160
    * Fixed set_reference in state residual by cmastalli in loco-3d/crocoddyl#1158
    * Enabled CONDA CI jobs with CppADCodeGen by cmastalli in loco-3d/crocoddyl#1156
    * Added other CI jobs by cmastalli in loco-3d/crocoddyl#1152
    * Fixed compiltation issue when building with CppADCodeGen by cmastalli in loco-3d/crocoddyl#1151
    * Fixed include order used in frames.cpp by ManifoldFR in loco-3d/crocoddyl#1150
nim65s added a commit to nim65s/robotpkg that referenced this pull request Jan 29, 2024
Upstream changes:

    ## [2.0.2] - 2023-12-07

    * Added nu, ng, and nh setters for Python bindings in loco-3d/crocoddyl#1192
    * Added CHANGELOG.md in loco-3d/crocoddyl#1188
    * Supported nu==0 in actuation models in loco-3d/crocoddyl#1188
    * Included Python bindings for Crocoddyl exceptions by cmastalli in loco-3d/crocoddyl#1186
    * Updated cmake submodule update by jcarpentier in loco-3d/crocoddyl#1186
    * Fixed getters for contraints bounds by skleff1994 in loco-3d/crocoddyl#1180
    * Extended solver abstract and callbacks for arbitrary solvers by cmastalli in loco-3d/crocoddyl#1179
    * Fixed the check of pair_id in collision residual by ArthurH91 in loco-3d/crocoddyl#1178
    * Exploited control-residual structure when computing Lu, Luu by cmastalli in loco-3d/crocoddyl#1176
    * Added LWA fram convention and introduced different axis for 1d contacts by skleff1994 in loco-3d/crocoddyl#1172
    * Python bindings for setting control bounds by cmastalli in loco-3d/crocoddyl#1171
    * Fixed missed scalar in cost sum and activation data by cmastalli in loco-3d/crocoddyl#1165
    * Added actuation unit tests by cmastalli in loco-3d/crocoddyl#1161
    * Introduced method for obtaining the dimension of floating-bases by cmastalli in loco-3d/crocoddyl#1160
    * Fixed set_reference in state residual by cmastalli in loco-3d/crocoddyl#1158
    * Enabled CONDA CI jobs with CppADCodeGen by cmastalli in loco-3d/crocoddyl#1156
    * Added other CI jobs by cmastalli in loco-3d/crocoddyl#1152
    * Fixed compiltation issue when building with CppADCodeGen by cmastalli in loco-3d/crocoddyl#1151
    * Fixed include order used in frames.cpp by ManifoldFR in loco-3d/crocoddyl#1150
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.

3 participants