Page 1 of 1

How to convert Component to IMU?

Posted: Tue Jun 14, 2022 1:15 pm
by wscr92
Hi, I was able to run IMU placer with script in GUI and added an IMU on the calibrated model. I was able to access the IMU component via name (e.g. "hand_l_imu"), yet I was not able to convert the Component type to IMU type, as I get the error "1st arg can't be coerced to org.opensim.modeling.IMU".

Could you please help?

Re: How to convert Component to IMU?

Posted: Tue Jun 14, 2022 1:19 pm
by wscr92
I found this post https://github.com/opensim-org/opensim-core/pull/3002

But I don't understand how to convert the component into IMU type so I can run functions in IMU class

Re: How to convert Component to IMU?

Posted: Thu Jun 16, 2022 2:36 pm
by ongcf
Conversion to a more specific type can be done using `safeDownCast()`. This is a method in MATLAB/Python to help scripting users change the type.

See the Common Scripting Commands page, and then there's an example under the "Exploring and Editing Models and Model Components" section.

Re: How to convert Component to IMU?

Posted: Fri Jun 17, 2022 6:45 am
by wscr92
Many thanks!
ongcf wrote:
Thu Jun 16, 2022 2:36 pm
Conversion to a more specific type can be done using `safeDownCast()`. This is a method in MATLAB/Python to help scripting users change the type.

See the Common Scripting Commands page, and then there's an example under the "Exploring and Editing Models and Model Components" section.