ComputationalBiomechanicsLab / opensim-creator

A UI for building OpenSim models
https://opensimcreator.com
Apache License 2.0
150 stars 17 forks source link

Add point-force visualizations for `GeometryPath` #907

Closed adamkewley closed 1 month ago

adamkewley commented 2 months ago

Similar to #904

We've already got body-force vector arrows in 0.5.13, which is what OpenSim::Force ultimately emits, but users probably want to see the point-force version of these forces, which may not be available via the existing APIs.

adamkewley commented 2 months ago

This is now implemented, but it should be noted that it's very very noisy to work with these force vectors on models with many muscles.

The force vector visualization probably needs to be modified such that it obeys the "Display only" actions in the UI. E.g. if the user opts to "display only this muscle" it should only show the force arrows for that muscle, but the implementation currently doesn't filter this correctly.

adamkewley commented 2 months ago

The integration works but there's a problem: OpenSim::GeometryPath emits twice as many PointForceDirections as expected, because it emits both the inbound and outbound forces due to tension along the path. Those two vectors need to be added together, so that users only end up seeing the total point effective point force (seeing two large vectors that ultimately cancel out isn't useful UX).

adamkewley commented 2 months ago

Related: https://github.com/opensim-org/opensim-core/pull/3891 (doesn't address the double-force adding things but does solve the having to hard-code against various components problem)

adamkewley commented 1 month ago

The ForceProducer/ForceConsumer API is now integrated into main, but the new problem is that the point forces emitted through the API don't sum together equal and opposite tension forces. I've created a separate upstream issue to resolve that:

https://github.com/opensim-org/opensim-core/pull/3903

adamkewley commented 1 month ago

The upstream PR has been merged and verified to work with OSC. However, the visualization still shows two opposite vectors because there are two vectors, one for each body, applied equal-and-oppositely to a point in the model.

Not much we can do about this, because it's fundamentally what the engine is doing: adding them together or filtering them in some way isn't strictly accurate (Newton would be furious :wink:).

So, with that in mind, I'll close this until someone comes up with a physically-relevant way of visualizing the forces. How it is right now is good enough (i.e. better than nothing!).