Adding an accelerometer to the femur

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Azarang Asadi
Posts: 14
Joined: Wed Nov 06, 2019 8:36 am

Adding an accelerometer to the femur

Post by Azarang Asadi » Wed Oct 21, 2020 5:17 pm

Hey all,

I'm trying to add an accelerometer to the right femur. I'm having a problem with the editing. I want to use the WeldJoint and I don't know if the following is enough for a weld joint:
<Joint>
<WeldJoint name="r_thigh_imu">
<parent_body>femur_r</parent_body>
<location_in_parent> 0.0 -0.25 0.1 </location_in_parent>
<orientation_in_parent> 1.57 0.0 0.0 </orientation_in_parent>
</WeldJoint>
</Joint>

Or do I need to prescribe a motion as well? I just want the accelerometer follows exactly the kinematics of femur at the point it's attached to.

Tags:

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

Re: Adding an accelerometer to the femur

Post by Carmichael Ong » Fri Oct 23, 2020 11:12 am

You do not need to prescribe the motion. Since it's welded to the femur, it will move with the femur.

User avatar
Wan Zihao
Posts: 5
Joined: Sun Jul 12, 2020 1:57 am

Re: Adding an accelerometer to the femur

Post by Wan Zihao » Sat Oct 24, 2020 2:43 am

You do not need to get the precise position.
I have another question to ask: How do you add the accelerometer to the body? How do you get the accelerate of body. Do you have an example?
Thank you!

User avatar
Daan de Kanter
Posts: 3
Joined: Tue Feb 11, 2020 2:51 am

Re: Adding an accelerometer to the femur

Post by Daan de Kanter » Mon Oct 26, 2020 10:20 am

Dear Wan,

You can model an accelerometer as follows:
Femur = osimModel.getBodySet.get('Femur');

Accelero = PhysicalOffsetFrame();
Accelero.setName('FirstAccelero');
Accelero.setParentFrame(Femur);

Then use the following code to obtain the output:
IMU1linacc = IMU1.getLinearAccelerationInGround(state); % Get the values
IMU1LinAcc = [IMU1linacc.get(0) IMU1linacc.get(1) IMU1linacc.get(2)]' % X Y Z accelerations

You possibly might want to use a reporter.

Hope this helps!

Best,
Daan

User avatar
Hide Kimpara
Posts: 135
Joined: Mon Sep 19, 2016 5:12 am

Re: Adding an accelerometer to the femur

Post by Hide Kimpara » Tue Aug 03, 2021 1:57 am

Hello,
I'm also seeking a method to obtain accelerometer data from model kinematics.
When I use Analysis Tool to get acceleration data of body kinematics, it does not contain gravity acceleration. It is exact 'kinematics' acceleration.
Is there any methods to get accelerometer outputs from Analysis Tool?
Otherwise, I need to make up an C++ or Python codes to export accelerometer data from state variable input.

Best regards,
Hide

User avatar
Bas Van Hooren
Posts: 30
Joined: Fri Jan 29, 2016 10:59 am

Re: Adding an accelerometer to the femur

Post by Bas Van Hooren » Fri Mar 01, 2024 4:13 am

Is there anyone that has an example weld joint that mimics an accelerometer attached to a tibia or femur he or she can share? I have been trying several variations but the model keeps producing an error when I attempt to load it into OpenSim.

User avatar
Nicos Haralabidis
Posts: 187
Joined: Tue Aug 16, 2016 1:46 am

Re: Adding an accelerometer to the femur

Post by Nicos Haralabidis » Mon Mar 04, 2024 10:29 am

Hello Bas,

Have you seen the IMU class? https://simtk.org/api_docs/opensim/api_ ... 658fa7a052

I believe you need to create a PhysicalOffsetFrame(specify the body, position and orientation), create an IMU object, connect the frame to the IMU and then call finalizeConnections. Perhaps you also need to add the physicalOffsetFrame component too.

Let me know if that helps.

Best wishes,

Nicos Haralabidis

User avatar
Nicos Haralabidis
Posts: 187
Joined: Tue Aug 16, 2016 1:46 am

Re: Adding an accelerometer to the femur

Post by Nicos Haralabidis » Mon Mar 04, 2024 11:11 am

This is somewhat of a minimum working example for adding an IMU to the femur_r using Matlab scripting... assuming you have already loaded your model as 'myModel':
pos_vector = Vec3(0); % where you wish to position the IMU eventually in the body of interest
pos_vector.setToZero();
pos_vector.set(1,-0.1); % set the vertical position for example

my_transform = Transform(pos_vector);
my_frame = PhysicalOffsetFrame('my_frame', femur_r, my_transform) % femur_r is the femur_r body from BodySet
femur_r.addComponent(my_frame);
myModel = finalizeConnections();

my_IMU = IMU();
my_IMU.connectSocket_frame(my_frame);
femur_r_addComponent(my_IMU);
myModel.finalizeConnections();
myModel.print('model_wIMU.osim');

This should open in OpenSim, I just quickly tested, you should see the IMU as yellow

Nicos

POST REPLY