simulate IK on object added to model
- Stefan Lambrecht
- Posts: 13
- Joined: Tue May 31, 2011 6:43 am
simulate IK on object added to model
Hello
My objective is the following:
I am adding objects to a model and want to know the IK (linear velocity and angular velocity and position) of this object.
Base model: gait2392 with a box added to the foot. Mass of the box is set to (0.8), with inertia tensor [0 0 0 0 0 0]. The parent segment of the box is the calcn, and they are connected by a weldjoint.Input motion is taken from the demo files in OpenSim (using version 3.2)
Analysis: I have made several modifications of this base model, changing the position (locationInParent) and orientation (orientationInParent, or OrientationInChild) of the box [loc&or aligned with parent, pure rotation(orientationInParent), pure translation(locationInParent), translation and rotation; pure rotation in child (orientationInChild) . Both IK and the AnalyzeTool were used on these models. The analysis consisted of BodyKinematics in the global frame, BodyKinematics in the body_local frame, and pointKinematics on the CoM of the box. I am using the matlab scripting interface to interact with OpenSim, and Matlab to plot my results.
Results: The linear velocity shows the effect of translating the box (changing locationInParent) in the global,body_local and in PointKinematics. PointKinematics and global provide identical results. The body_local linear velocity is the only parameter showing both the effect of the changes in orientation and location (! if the rotation took place as a change in orientationInParent).
The angular velocity shows no effect of any of the changes made, neither in the global or body_local frame (the box and segment plots are identical).
Problem/question: How can I obtain the linear and angular velocity (and position) data to reflect the changes made to the object location and orientation?
Since the changes are not reflected in the pointKinematics data I am assuming that this will not help me further.
I do not know if it is possible to transform the body_local linear velocity to global linear velocity, but then I would still be left without angular velocity data.
This is probably a no-brainer but I am nonetheless stuck and appreciate any help or feedback.
[I can upload plots if needed/desired]
My objective is the following:
I am adding objects to a model and want to know the IK (linear velocity and angular velocity and position) of this object.
Base model: gait2392 with a box added to the foot. Mass of the box is set to (0.8), with inertia tensor [0 0 0 0 0 0]. The parent segment of the box is the calcn, and they are connected by a weldjoint.Input motion is taken from the demo files in OpenSim (using version 3.2)
Analysis: I have made several modifications of this base model, changing the position (locationInParent) and orientation (orientationInParent, or OrientationInChild) of the box [loc&or aligned with parent, pure rotation(orientationInParent), pure translation(locationInParent), translation and rotation; pure rotation in child (orientationInChild) . Both IK and the AnalyzeTool were used on these models. The analysis consisted of BodyKinematics in the global frame, BodyKinematics in the body_local frame, and pointKinematics on the CoM of the box. I am using the matlab scripting interface to interact with OpenSim, and Matlab to plot my results.
Results: The linear velocity shows the effect of translating the box (changing locationInParent) in the global,body_local and in PointKinematics. PointKinematics and global provide identical results. The body_local linear velocity is the only parameter showing both the effect of the changes in orientation and location (! if the rotation took place as a change in orientationInParent).
The angular velocity shows no effect of any of the changes made, neither in the global or body_local frame (the box and segment plots are identical).
Problem/question: How can I obtain the linear and angular velocity (and position) data to reflect the changes made to the object location and orientation?
Since the changes are not reflected in the pointKinematics data I am assuming that this will not help me further.
I do not know if it is possible to transform the body_local linear velocity to global linear velocity, but then I would still be left without angular velocity data.
This is probably a no-brainer but I am nonetheless stuck and appreciate any help or feedback.
[I can upload plots if needed/desired]
Re: simulate IK on object added to model
Why would you expect the angular velocity to be any different? The angular velocity of any point along the tibia is exactly the same, only the linear velocity of the points would be different.
- Stefan Lambrecht
- Posts: 13
- Joined: Tue May 31, 2011 6:43 am
Re: simulate IK on object added to model
Hi James
Thank you for your reply, and my sincere apologies for not getting back to you sooner.
I agree with your statement that the angular velocity at any point of the tibia is the same (given the rigid body assumption).
My question however is related to an object attached to the tibia. Assuming that it is orientated perfectly in line with the tibia, then I would expect to get identical angular velocity results, regardless of translations applied (location).[This is inline with your comment]
However, when this object has an offset orientation with regard to the tibia orientation (rotation applied to orientationInParent in the WeldJoint) then I expect to observe this rotation in the object.
That is the behaviour I get for linear velocity(XYZ columns in .sto), but for angular velocity (oXoYoZ columns in .sto) I fail to produce any changes.
For clarity I have attached a figure consisting of 3 panels (A,B,C). In Panel A the behaviour mentioned above for linear velocity (representing the changes in orientation and location) are noticeable. The "no offsets" refers to all orientation and location vectors being (0,0,0). The translation applied is moving the object toward the midpoint (visually) of the tibia. All plots in panel A are in the body_local frame.
In panel B the lack of change in angular velocity can be observed. The plots represent data from BodyKinematics in the global (global) and body_local (local) frame.
I have added panel C as a curiosity. The mass of the object was set at 0.8 kg, with COM and tensors of inertia set to 0. I is not completely clear to me why the plots highlighted in bold are not identical.
Thank you for your reply, and my sincere apologies for not getting back to you sooner.
I agree with your statement that the angular velocity at any point of the tibia is the same (given the rigid body assumption).
My question however is related to an object attached to the tibia. Assuming that it is orientated perfectly in line with the tibia, then I would expect to get identical angular velocity results, regardless of translations applied (location).[This is inline with your comment]
However, when this object has an offset orientation with regard to the tibia orientation (rotation applied to orientationInParent in the WeldJoint) then I expect to observe this rotation in the object.
That is the behaviour I get for linear velocity(XYZ columns in .sto), but for angular velocity (oXoYoZ columns in .sto) I fail to produce any changes.
For clarity I have attached a figure consisting of 3 panels (A,B,C). In Panel A the behaviour mentioned above for linear velocity (representing the changes in orientation and location) are noticeable. The "no offsets" refers to all orientation and location vectors being (0,0,0). The translation applied is moving the object toward the midpoint (visually) of the tibia. All plots in panel A are in the body_local frame.
In panel B the lack of change in angular velocity can be observed. The plots represent data from BodyKinematics in the global (global) and body_local (local) frame.
I have added panel C as a curiosity. The mass of the object was set at 0.8 kg, with COM and tensors of inertia set to 0. I is not completely clear to me why the plots highlighted in bold are not identical.
- Michael Sherman
- Posts: 807
- Joined: Fri Apr 01, 2005 6:05 pm
Re: simulate IK on object added to model
Hi, Stefan. The angular velocities of all frames fixed on a rigid body are the same; the frame orientation doesn't matter. Are you saying you expected the angular velocity vector to be re-expressed in the frame of the attached part? OpenSim is giving you the angular velocity expressed in Ground. Did you want the angular velocity of the part expressed in its own frame? That would be the same physical quantity (angular velocity relative to Ground), but the numerical representation would change.
Regards,
Sherm
Regards,
Sherm
- Stefan Lambrecht
- Posts: 13
- Joined: Tue May 31, 2011 6:43 am
Re: simulate IK on object added to model
Hi Sherm.
I am indeed trying to get the local angular velocity, as if it were measured by a 3D gyroscope. In case this sensor is not perfectly aligned with the body segment (the tibia in the example data), then I would expect to see this offset in orientation to be reflected in the angular velocity (I believe that this is what you refer to by "the numerical representation would change").
My assumption was that the body_local angular velocity would give me this. It appears that this is an incorrect assumption.
I greatly appreciate any help/feedback you can provide me.
Stefan
I am indeed trying to get the local angular velocity, as if it were measured by a 3D gyroscope. In case this sensor is not perfectly aligned with the body segment (the tibia in the example data), then I would expect to see this offset in orientation to be reflected in the angular velocity (I believe that this is what you refer to by "the numerical representation would change").
My assumption was that the body_local angular velocity would give me this. It appears that this is an incorrect assumption.
I greatly appreciate any help/feedback you can provide me.
Stefan
- Michael Sherman
- Posts: 807
- Joined: Fri Apr 01, 2005 6:05 pm
Re: simulate IK on object added to model
I don't know whether the OpenSim GUI has an option to automatically re-express the body angular velocity in its own frame. James or Ayman, is that feature available? Or is there a script available?
If not, you can do it yourself with a little post-processing. Say you have an angular velocity vector w of a body B, relative to Ground, and expressed in the Ground frame. Call that w_G. You want the same physical quantity w, but expressed in B's body frame. Call that w_B. You need a 3x3 rotation matrix that gives the B frame orientation in Ground; call that R_GB. Then you can calculate w_B = R_GB * w_G.
You can construct R_GB from the orientation angles OpenSim provides to represent the orientation of body B in Ground.
Sherm
If not, you can do it yourself with a little post-processing. Say you have an angular velocity vector w of a body B, relative to Ground, and expressed in the Ground frame. Call that w_G. You want the same physical quantity w, but expressed in B's body frame. Call that w_B. You need a 3x3 rotation matrix that gives the B frame orientation in Ground; call that R_GB. Then you can calculate w_B = R_GB * w_G.
You can construct R_GB from the orientation angles OpenSim provides to represent the orientation of body B in Ground.
Sherm
- Stefan Lambrecht
- Posts: 13
- Joined: Tue May 31, 2011 6:43 am
Re: simulate IK on object added to model
Thanks for the advice,
My goal was to try and see if I could simulate soft-tissue artefact (replacing the weld joint by a spring-damper connection) to replicate a more realistic scenario of an object (inertial sensor, orthesis,shoe,...) connected to the human body. In this more realistic case there is no fixed relation between the object and the parent segment (i.e. R_GB is not a constant).
[I did not state this in my first post because I thought a simplified scenario would be easier to explain/understand.]
Thank you both for your help so far!
My goal was to try and see if I could simulate soft-tissue artefact (replacing the weld joint by a spring-damper connection) to replicate a more realistic scenario of an object (inertial sensor, orthesis,shoe,...) connected to the human body. In this more realistic case there is no fixed relation between the object and the parent segment (i.e. R_GB is not a constant).
[I did not state this in my first post because I thought a simplified scenario would be easier to explain/understand.]
Thank you both for your help so far!
- Michael Sherman
- Posts: 807
- Joined: Fri Apr 01, 2005 6:05 pm
Re: simulate IK on object added to model
Thanks for the clarification, Stefan. In that case you can still use the same approach -- get the angular velocity of the flexibly-attached sensor body relative to ground (which will now be different than the tibia's). Calculate the rotation matrix from the sensor body's orientation relative to Ground. Then use the rotation matrix to re-express the angular velocity in the sensor body's local frame.
Sherm
Sherm
- Stefan Lambrecht
- Posts: 13
- Joined: Tue May 31, 2011 6:43 am
Re: simulate IK on object added to model
Thanks Sherm
I will try the approach you suggested and will try to remember to post a link to the working code files once I have it up and running (I am in the middle of a few other things so I might take a while).
Once again, thank you to both of you for dedicating time to my question!
I will try the approach you suggested and will try to remember to post a link to the working code files once I have it up and running (I am in the middle of a few other things so I might take a while).
Once again, thank you to both of you for dedicating time to my question!