Skip to content

Fix invalid PathWrapPoint locations leading to incorrect moment arm calculations - #4485

Merged
nickbianco merged 1 commit into
mainfrom
moment_arm_bug
Nov 16, 2026
Merged

nickbianco merged 1 commit into
mainfrom
moment_arm_bug

Conversation

@nickbianco

@nickbianco nickbianco commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes an issue raised by Ross Miller on the forum. Possibly related: #3805.

Brief summary of changes

This change fixes a bug where changes to the parent-frame location of a PathWrapPoint did not invaldiate the point's ground-frame location stored in the Point cache. This fixes an issue where a GeometryPath with two or more wrapping obstacles could produce moment arms about unexpected coordinates (e.g., pelvis rotational coordinates) due to outdated path point information.

Note that this change also fixes issues with path length calculations, so muscle paths with two or more wrapping obstacles may see slight changes in lengths going forward.

Testing I've completed

Added test case "GeometryPath with multiple wrap objects" to testGeometryPathWrapping.cpp.

The reference files std_testGeometryPathWrapping_subject_walk_armless_muscles_lengths.sto and std_testMocoInverse_subject_18musc_solution.sto (used by testMocoInverse.cpp) needed to be updated since path length calculations have been updated (re: fixed) when two or more wrap surfaces are present. Additionally, a few TODOs in testMocoInverse.cpp that existed because of this bug were resolved.

Looking for feedback on...

AI/LLM use

Used Claude Code to identify the bug and implement an initial solution.

CHANGELOG.md (choose one)

  • updated.

Please review the CONTRIBUTING.md file for detailed contributing guidelines.


This change is Reviewable

@nickbianco
nickbianco force-pushed the moment_arm_bug branch 2 times, most recently from 4d09ed6 to a01ec3d Compare November 12, 2026 01:11

@tkuchida tkuchida left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch 👍. Minor comment below.

markCacheVariableValid(s, _location);
// The location in the parent frame has changed, so we must invalidate the
// Point's cached ground-frame quantities.
invalidateCache(s);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems like Point::invalidateCache() would only ever be called from here, so perhaps just put the three markCacheVariableInvalid() lines here. Alternatively, for readability, the method could be called something more descriptive like invalidateLocalCacheVariables() or similar.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Calling markCacheVariableInvalid() directly would be nice, but the Point cache variables (e.g., _locationCV) are private so something like markCacheVariableValid(s, _locationCV) will not compile. I don't think we should promote those cache variables those cache variables to protected, so I've opted for this method.

I've renamed to invalidateGroundKinematicsCache(), let me know what you think.

@nickbianco
nickbianco requested a review from tkuchida November 14, 2026 20:01
…alculations

Fixes a bug where changes to the parent-frame location of a PathWrapPoint did not invaldiate the point's ground-frame location stored in the Point cache. This fixes an issue where a GeometryPath with two or more wrapping obstacles could produce moment arms about unexpected coordinates (e.g., pelvis rotational coordinates) due to outdated path point information.
@nickbianco
nickbianco merged commit ad2584d into main Nov 16, 2026
6 checks passed
@nickbianco
nickbianco deleted the moment_arm_bug branch November 16, 2026 14:20
@nickbianco

Copy link
Copy Markdown
Member Author

Thanks @tkuchida!

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