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

Support variable mass properties #685

Open
chrisdembia opened this issue Feb 27, 2020 · 4 comments
Open

Support variable mass properties #685

chrisdembia opened this issue Feb 27, 2020 · 4 comments

Comments

@chrisdembia
Copy link
Member

chrisdembia commented Feb 27, 2020

@nickbianco and I are hoping to support optimizing a body's mass in Moco. Right now, changing a body's mass require's invoking OpenSim::Model::initSystem() which is too expensive to do during direct collocation.

I had hoped that Simbody would allow editing the mass properties in the state (at stage Instance). I found the following in the source code:

const MassProperties& getBodyMassProperties(const State& s) const {
// TODO: these should come from the state if the body has variable mass props
const SBInstanceVars& iv = getMyMatterSubsystemRep().getInstanceVars(s);
return getMyRigidBodyNode().getMassProperties_OB_B();
}

This indicates that Simbody does not yet support updating mass properties after realizeTopology().

@sherm1, do you have a sense of how difficult it would be implement a MobilizedBody::setMassProperties(SimTK::State&)?

@chrisdembia
Copy link
Member Author

@nickbianco

@sherm1
Copy link
Member

sherm1 commented Feb 27, 2020

Not difficult, I think -- mostly bookkeeping to take care of. We have examples of this already. The first one that came to my mind is Thermostat which has the standard patttern: for example, setDefaultBathTemperature(temp) and setBathTemperature(State&, temp).

Then the code in its realizeTopology() method allocates Model and Instance stage variables that hold the runtime values for those parameters. And those get initialized from the default values.

For mass properties of MobilizedBodies I think I already assumed we would want them to vary so there may be a generic instance stage variable belonging to SimbodyMatterSubsystem that holds them all and could be used to implement the variable ones (been a while since I looked at that).

@sherm1
Copy link
Member

sherm1 commented Feb 27, 2020

Yeah, this state variable is what I was thinking of. That already holds runtime values for all the mass properties and other parameters. Those get initialized to the default values -- I think all you would need to do is add APIs for modifying these (and make sure they don't accidentally get overridden afterwards from the defaults).

@chrisdembia
Copy link
Member Author

Thanks @sherm1 that's very helpful. Maybe we'll give it a shot.

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

No branches or pull requests

2 participants