How can I access Simscape Multibody solid properties calculated via geometry in a script?

25 visualizzazioni (ultimi 30 giorni)
Hey everyone. I've been using Simscape Multibody and I made a very basic model. I wanted to make a .m script that would be able to access the inertial properties of the solids I make which are set to "calculate from geometry" based on the dimensions and densities I set. So far I figured out how to use the "get_param" function to access properties of my model, but when I try to get something like "MomentsOfInertia" of a rod that I made, I get [0 0 0], which is the default of the manual input for moments of inertia. So there must be a different way to access the inertia properties that were calculated from the geometry of the solid. I would really like to be able to access this data in my script somehow.
Is there a way to do this? I would greatly appreciate some guidance.

Risposte (1)

Divyajyoti Nayak
Divyajyoti Nayak il 20 Dic 2024 alle 6:54
Accessing the derived values, such as center of mass, moments of inertia, etc. that are calculated from geometry in a Simscape model, through MATLAB scripts directly is not supported as of MATLAB R2024b. The ‘MomentsOfInertia’ property that you are getting from ‘get_param’ is the custom ‘MomentsOf Inertia’ property. Here’s a link to its documentation
A workaround for this could be to add an ‘Inertia Sensor’ block to your solid and output the calculated values to your workspace on running the simulation. Here’s some documentation to help you out:
  1 Commento
Alejandro
Alejandro il 21 Dic 2024 alle 20:41
Thank you so much for your time, Mr. Nayak. Perhaps I should provide some more context in case there's an easy way to do what I'm trying to do overall.
I'm trying to control my system with a Linear Quadratic Regulator, and I did my linearization and system equations from first principles. I used a Simulink "Gain" block to multiply the system state by a gains matrix. In the "Gain:" spot I put:
-get_analytic_K()
So that when I run the simulation, the new K is generated. In the "get_analytic_K()" function, I have all my system's masses and inertias and such, which I had to manually go and look at and type in. It would be super nice to be able to access this data so that my LQR gain matrix can be compiled before simulations, but as you said, this isn't possible. Is there a different way to achieve what I'm doing altogether? Thanks

Accedi per commentare.

Prodotti


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by