How to convert Component to IMU?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Junwei Sun
Posts: 12
Joined: Mon Mar 14, 2022 11:05 am

How to convert Component to IMU?

Post by Junwei Sun » Tue Jun 14, 2022 1:15 pm

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?

User avatar
Junwei Sun
Posts: 12
Joined: Mon Mar 14, 2022 11:05 am

Re: How to convert Component to IMU?

Post by Junwei Sun » Tue Jun 14, 2022 1:19 pm

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

User avatar
Carmichael Ong
Posts: 387
Joined: Fri Feb 24, 2012 11:50 am

Re: How to convert Component to IMU?

Post by Carmichael Ong » 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.

User avatar
Junwei Sun
Posts: 12
Joined: Mon Mar 14, 2022 11:05 am

Re: How to convert Component to IMU?

Post by Junwei Sun » Fri Jun 17, 2022 6:45 am

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.

POST REPLY