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.
Adding an accelerometer to the femur
- Azarang Asadi
- Posts: 14
- Joined: Wed Nov 06, 2019 8:36 am
- Carmichael Ong
- Posts: 383
- Joined: Fri Feb 24, 2012 11:50 am
Re: Adding an accelerometer to the femur
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
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!
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!
- Daan de Kanter
- Posts: 3
- Joined: Tue Feb 11, 2020 2:51 am
Re: Adding an accelerometer to the femur
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
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
- Hide Kimpara
- Posts: 135
- Joined: Mon Sep 19, 2016 5:12 am
Re: Adding an accelerometer to the femur
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
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
- Bas Van Hooren
- Posts: 30
- Joined: Fri Jan 29, 2016 10:59 am
Re: Adding an accelerometer to the femur
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.
- Nicos Haralabidis
- Posts: 188
- Joined: Tue Aug 16, 2016 1:46 am
Re: Adding an accelerometer to the femur
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
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
- Nicos Haralabidis
- Posts: 188
- Joined: Tue Aug 16, 2016 1:46 am
Re: Adding an accelerometer to the femur
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
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