Page 1 of 1

Adding an accelerometer to the femur

Posted: Wed Oct 21, 2020 5:17 pm
by azarangasadi
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.

Re: Adding an accelerometer to the femur

Posted: Fri Oct 23, 2020 11:12 am
by ongcf
You do not need to prescribe the motion. Since it's welded to the femur, it will move with the femur.

Re: Adding an accelerometer to the femur

Posted: Sat Oct 24, 2020 2:43 am
by wzh1433223
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!

Re: Adding an accelerometer to the femur

Posted: Mon Oct 26, 2020 10:20 am
by daandekanter
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

Re: Adding an accelerometer to the femur

Posted: Tue Aug 03, 2021 1:57 am
by hkimpara
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

Re: Adding an accelerometer to the femur

Posted: Fri Mar 01, 2024 4:13 am
by basvanhooren
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.

Re: Adding an accelerometer to the femur

Posted: Mon Mar 04, 2024 10:29 am
by nicos1993
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

Re: Adding an accelerometer to the femur

Posted: Mon Mar 04, 2024 11:11 am
by nicos1993
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