Skip to content

fix(lcs-factory-options) : breaking python tests using plant for number of contacts resolution#52

Merged
Meow404 merged 6 commits intomainfrom
stephen/fix-breaking-python-tests
Apr 13, 2026
Merged

fix(lcs-factory-options) : breaking python tests using plant for number of contacts resolution#52
Meow404 merged 6 commits intomainfrom
stephen/fix-breaking-python-tests

Conversation

@Meow404
Copy link
Copy Markdown
Collaborator

@Meow404 Meow404 commented Apr 9, 2026

This change is Reviewable

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

LCOV of commit e34bbc9 during C3 Coverage #144

Summary coverage rate:
  lines......: 92.2% (2078 of 2253 lines)
  functions..: 80.3% (192 of 239 functions)
  branches...: 49.0% (1696 of 3462 branches)

Files changed coverage rate:
                                                          |Lines       |Functions  |Branches    
  Filename                                                |Rate     Num|Rate    Num|Rate     Num
  ==============================================================================================
  multibody/lcs_factory.cc                                | 4.7%    359|3671%    17|    -      0
  multibody/lcs_factory.h                                 |33.3%      6| 600%     2|    -      0
  systems/c3_controller.cc                                | 4.2%    143|3833%     6|    -      0
  systems/lcs_factory_system.cc                           |15.2%     33|1450%     4|    -      0

@Meow404 Meow404 marked this pull request as ready for review April 9, 2026 13:22
@Meow404 Meow404 requested a review from xuanhien070594 April 9, 2026 13:22
@Meow404 Meow404 force-pushed the stephen/fix-breaking-python-tests branch from 6cdfc1d to 1f67187 Compare April 9, 2026 18:40
@Meow404 Meow404 marked this pull request as draft April 9, 2026 18:46
@Meow404 Meow404 force-pushed the stephen/fix-breaking-python-tests branch from 1f67187 to 6add83d Compare April 9, 2026 18:47
@Meow404 Meow404 force-pushed the stephen/fix-breaking-python-tests branch from 6add83d to 3e95b11 Compare April 9, 2026 19:19
@Meow404 Meow404 marked this pull request as ready for review April 9, 2026 20:14
@xuanhien070594
Copy link
Copy Markdown
Contributor

multibody/lcs_factory.cc line 820 at r1 (raw file):

int LCSFactory::GetNumContactVariables(
    const LCSFactoryOptions& options,
    const drake::multibody::MultibodyPlant<double>* plant) {

What if the users use different plant than the one passed to LCSFactory constructor?
I think we can create an utility function that is separate from LCSFactory class.
Also, do we have way to cache the computed values (expanded configs, n_contacts) as we don't want to recompute them?

Copy link
Copy Markdown
Contributor

@xuanhien070594 xuanhien070594 left a comment

Choose a reason for hiding this comment

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

I have only one comment. Otherwise, LGTM.

@xuanhien070594 reviewed 19 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on Meow404).

Copy link
Copy Markdown
Collaborator Author

@Meow404 Meow404 left a comment

Choose a reason for hiding this comment

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

@Meow404 made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on xuanhien070594).


multibody/lcs_factory.cc line 820 at r1 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

What if the users use different plant than the one passed to LCSFactory constructor?
I think we can create an utility function that is separate from LCSFactory class.
Also, do we have way to cache the computed values (expanded configs, n_contacts) as we don't want to recompute them?

  1. right now there isn't anything preventing the user to using a different plant. Isnt this desirable?
  2. Does'nt LCSFactory determine how many lamnda's will be present in the LCS?
  3. I had tried working on caching, the issue is then I realized I need a mechanism to check if variables use to calculate the values may have changed over time. Not sure if this added overhead is worth the change. eg. for num_of_friction_direction, once the user calls ResolveNumFrictionDirections and we cache the value, then we need to monitor contact_model, num\_friction\_directions\_per\_contact and num\_friction\_directions for changes.

@xuanhien070594
Copy link
Copy Markdown
Contributor

multibody/lcs_factory.cc line 820 at r1 (raw file):

Previously, Meow404 (Thomas Stephen Felix) wrote…
  1. right now there isn't anything preventing the user to using a different plant. Isnt this desirable?
  2. Does'nt LCSFactory determine how many lamnda's will be present in the LCS?
  3. I had tried working on caching, the issue is then I realized I need a mechanism to check if variables use to calculate the values may have changed over time. Not sure if this added overhead is worth the change. eg. for num_of_friction_direction, once the user calls ResolveNumFrictionDirections and we cache the value, then we need to monitor contact_model, num\_friction\_directions\_per\_contact and num\_friction\_directions for changes.

That's fair, but if the users pass a plant that is different from the one in the constructor without noticing, the results might cause confusion.
I understand that we want to keep this function as static, so users can use without constructing LCSFactory object, so do you think we should provide another function that use internal options and plant

Code snippet:

static int ComputeNumContactVariables(
    const LCSFactoryOptions& options,
    const MultibodyPlant<double>* plant);

int LCSFactory::GetNumContactVariables() const {
  return ComputeNumContactVariable(options_, plant_);
}

Copy link
Copy Markdown
Collaborator Author

@Meow404 Meow404 left a comment

Choose a reason for hiding this comment

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

@Meow404 made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on xuanhien070594).


multibody/lcs_factory.cc line 820 at r1 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

That's fair, but if the users pass a plant that is different from the one in the constructor without noticing, the results might cause confusion.
I understand that we want to keep this function as static, so users can use without constructing LCSFactory object, so do you think we should provide another function that use internal options and plant

Done.

@Meow404 Meow404 requested a review from xuanhien070594 April 13, 2026 17:47
Copy link
Copy Markdown
Contributor

@xuanhien070594 xuanhien070594 left a comment

Choose a reason for hiding this comment

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

:lgtm:

@xuanhien070594 reviewed 2 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Meow404).

@Meow404 Meow404 merged commit e217037 into main Apr 13, 2026
4 checks passed
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.

2 participants