Closed adamkewley closed 4 months ago
Downstream PR of opensim-creator
with this change, for basic sanity checks:
Binary builds available via Actions
StationDefinedFrames_Advanced.osim
is a much more comprehensive test of how chains of PhysicalOffsetFrame
s and StationDefinedFrame
s can interplay:
Not obvious from this screenshot, but the topology here is something like:
ground <-- pof
pof <-- pof2
pof2 <-- FreeJoint
FreeJoint --> StationDefinedFrame
StationDefinedFrame
defined via stations on 3 RGB spheres as stationX --> mesh_pof --> body`StationDefinedFrame <-- FreeJoint2
FreeJoint2 --> StationDefinedFrame2
StationDefinedFrame2
defined via a mixture of stations defined on RG cubes defined via chains of PoFs onto a cylnder model and a station that's directly defined on the body frameLittle bit pathological, but the idea is that users might be combining mesh data, landmarks, etc. to build frames dynamically, so the engine needs to handle mixed-, chained-, etc. frames.
The implementation was updated to mean that there's now no user-facing API changes at all: what was protected
is still protected
. The only changes are additions extendSetMobilizedBodyIndex
and setMobilizedBodyIndexOf(someotherframe)
, which are the bare-minimum necessary to ensure that downstream PhysicalFrame
implementations can customize their own index behavior and also set indices on other frames when it makes sense.
Thanks @pepbos
Fixes an issue found during #3694 where chaining
PhysicalOffsetFrame
s orStationDefinedFrame
s does not work.The reason it doesn't work is because the previous implementation does things like
dynamic_cast
ing toPhysicalOffsetFrame
followed by hard-setting its parent'sMobilizedBodyIndex
. That approach doesn't take into account that (e.g.) the parent may, itself, be aPhysicalOffsetFrame
(a correct implementation should also iterate through the whole chain). It also doesn't account for other dependent frame types (e.g.StationDefinedFrame
).To work around this, the following changes were necessary:
PhysicalOffsetFrame
'sextendAddToSystem
to instead set its own body index based on the base frame it's attached to (previously, it would usegetParentFrame
, which doesn't account for chains of frames)PhysicalOffsetFrame
with a new extension member method,extendSetMobilizedBodyIndex
:Frame
implementations transitively set body indices based on what they know about their frame topology (e.g. aPhysicalOffsetFrame
"knows" it has a parent)dynamic_cast
ing toPhysicalOffsetFrame
from joint:setMobilizedBodyIndex
PhysicalOffsetFrame
/StationDefinedFrame
now use the extension point to (e.g.) ensure that theMobilizedBodyIndex
is set on frames that they are transitively attached tosetMobilizedBodyIndex
on each element in the chain, rather than just the parent)API CHANGES (NONE)
setMobilizedBodyIndexis now
public, rather than
protected` (it is still labelled as advanced, though).A new method was added,
setMobilizedBodyIndexOf
, which keeps the existing API backwards-compatible but lets frames set eachovers indices (required)Testing I've completed
StationDefinedFrame
then failedStationDefinedFrame
tests were re-enabled/reversed (as documented)CHANGELOG.md (choose one)
This change is![Reviewable](https://reviewable.io/review_button.svg)