visual3d:documentation:kinematics_and_kinetics:opensim
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
visual3d:documentation:kinematics_and_kinetics:opensim [2024/07/03 17:27] – removed sgranger | visual3d:documentation:kinematics_and_kinetics:opensim [2025/03/12 14:25] (current) – wikisysop | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== OpenSim ====== | ||
+ | |||
+ | Visual3D allows the user to export OpenSim compatible motion files designed for use with OpenSim gait models. The Visual3D-to-OpenSim integration is based on the OpenSim tutorial [[https:// | ||
+ | |||
+ | Visual3D exports an OpenSim compatible motion file, named Visual3D_SIMM_input.mot, | ||
+ | |||
+ | ===== Modeling Requirements ===== | ||
+ | |||
+ | The following model requirements must all be met. Please read the requirements carefully: | ||
+ | |||
+ | - The Visual3D model used for OpenSim output must include the right foot (RFT), right shank (RSK), right thigh (RTH), left foot (LFT), left shank (RSK), left thigh (RTH), pelvis (RPV) and a Thorax/Ab (RTA). | ||
+ | - The Thorax/Ab (RTA) segment must be built in a very specific way. First, the proximal end of the RTA should be the created at the exact same location as the proximal end of the pelvis. Thus the proximal end of the RTA forms the joint with the pelvis while the distal end of the RTA should be built at approximately at the height of the shoulder shoulders. If constructed in this manner, the RTA segment will now have the Z axis (which goes distal to proximal) pointed downward and the Y axis pointed backward. This must be changed so the RTA segment coordinate system matches the local coordinate system of the other segments. To do this you go click the " | ||
+ | - All segments must follow the default Visual3D convention, X ML, +Y anterior and +Z vertical. This is necessary to enforce the OpenSim model constraints (explained [[# | ||
+ | - One current limitation of the Visual3d to OpenSim approach is that in order to handle the motion of the pelvis relative to the LAB all subjects are assumed to be walking in the +Y direction, with the global +Z axis in vertical direction and the +X axis pointing to the right. If the user’s LAB coordinate system is not setup this way they can get around this limitation by creating " | ||
+ | |||
+ | See [[Visual3D: | ||
+ | |||
+ | ==== Pose Estimation in Visual3D ==== | ||
+ | |||
+ | Visual3D offers two methods of pose estimation: 1) [[visual3d: | ||
+ | |||
+ | - 3 degree of freedom ball joint at the right hip, left hip and waist. | ||
+ | - a hinge joint at the knee with the location of the hinge a function of the knee joint angle as specifies in the OpenSim model. | ||
+ | - The ankle joint is hinge with the direction of the axis matching that of the gatt23*.osim model. | ||
+ | - The subtalar joint is hinge with the direction of the axis matching that of the gatt23*.osim model. | ||
+ | - The mtp joint is fixed and set to zero at all frames. (This was done on a recommendation from Jill Higginnson at the University of Delaware.) | ||
+ | |||
+ | |||
+ | ==== Visual3D-to-OpenSim Inverse Kinematics ==== | ||
+ | |||
+ | Visual3D’s ability to write OpenSim compatible .mot files is based on Visual3D’s own Inverse Kinetics algorithm. The theory behind the Visual3D to OpenSim Inverse Kinematics is a three stage process: | ||
+ | |||
+ | - Visual3D computes the scale factors which will scale the OpenSim gait model to the Visual3d static calibration model. These scale factors get written to a special OpenSim scale set file named Visual3d_Scale_ScaleSet.xml. (See the Visual3d Scaling section of this document for more details.) | ||
+ | - Visual3D uses Inverse Kinematics to fit the scaled OpenSim gait model to the Visual3D Static Calibration Model. (This is similar to the OpenSim Marker Placer Process). | ||
+ | - Visual3D then uses Inverse Kinematics to fit the gait data to the newly calibrated model. | ||
+ | |||
+ | To recap, any export from Visual3D to OpenSim will not use a 6DOF model regardless of how the model is defined in Visual3D. Instead exports use a IK model incorporating the Opensim model constraints. This process is hard-coded inside Visual3D and occurs automatically. | ||
+ | |||
+ | Visual3d does manual scaling on all segments and does its own IK, thus many of the OpenSim files related to the Marker Set, Scaling and IK are no longer required. | ||
+ | |||
+ | ==== Model Scaling ==== | ||
+ | |||
+ | Visual3D automatically scales the OpenSim model by: | ||
+ | - Changing the OpenSim scaling method to manual scaling for all segments. The simplified version of the OpenSim scaling setup file, called Visual3d_Setup_Scale.xml, | ||
+ | - Updating the file Visual3d_Scale_ScaleSet.xml to include the Visual3D computed scale factors for the pelvis, left and right thigh and left and right tibia segments. | ||
+ | |||
+ | **NOTE**: In OpenSim 3.1, the xml formats were modified and Visual3D could not write the correct manual scale factors to be used by OpenSim. For OpenSim 3.1, the user will need to manually enter the scale factors in OpenSim. [[http:// | ||
+ | |||
+ | **NOTE**: The manual scale factors written to the Visual3d_Scale_ScaleSet.xml file must be used to scale the pelvis, thigh and tibia segments in OpenSim. If these scale factors are not used then center of pressure, which is also written by Visual3d to the Visual3d_SIMM_input.mot, | ||
+ | |||
+ | The manual scale factors computed by Visaul3d are based on the subject calibration data and the OpenSim segment geometry (as specified in the gait2392_simbody.osim). Specifically, | ||
+ | |||
+ | | Pelvis | Visual3D computes the distance (in meters) between the hip centers in the subject calibration and divides this value by 0.167. The value 0.167 is the distance between the medial and lateral hip location in the file gait2392_simbody.osim. (One important note is that by default OpenSim scales the pelvis based on the distance between the left and right ASIS; however since Visual3d does not require targets be placed on the left and right ASIS the pelvis is scaled based on the distance between the hip joint centers which will always be present.) | | ||
+ | | Thigh | Visual3D computes the distance between the hip and knee joint center in the subject calibration and divides this value by 0.396. The value 0.396 is the distance between the hip and knee location in the file gait2392_simbody.osim. (Note: the knee location will vary with knee joint angle in OpenSim and the value 0.396 represents the knee location at zero degree of knee flexion.) | | ||
+ | | Shank | Visual3D computes the distance between the knee and ankle joint center in the subject calibration and divides this value by 0.43. The value 0.43 is the distance between the knee and ankle location in the file gait2392_simbody.osim. | | ||
+ | | Torso, Calcaneus and Toes | Most users build their feet without markers at the very end of the foot and at the top of the head. Visual3D therefore uses the average thigh length to scale these segments. (Physical anthropometry studies have shown thigh length is a somewhat strongly correlated with height). | | ||
+ | |||
+ | ===== Visual3D-to-OpenSim Exports ===== | ||
+ | |||
+ | The Visual3D-to-OpenSim process is designed according to the OpenSim tutorial "Intro to Musculoskeletal Modeling" | ||
+ | - [[Visual3D: | ||
+ | - [[Visual3D: | ||
+ | - [[Visual3D: | ||
+ | - [[Visual3D: | ||
+ | |||
+ | ==== Correcting the Lumbar Tilt in the Exported Motion File ==== | ||
+ | |||
+ | Visual3D' | ||
+ | |||
+ | ==== Exported Joint Angles ==== | ||
+ | |||
+ | The angles that are exported to OpenSim are slightly different than the angles calculated in Visual3D because the Inverse Kinematics model used in the Visual3D-to-OpenSim export is a special version of Visual3D' | ||
+ | |||
+ | The four main differences in this special Visual3d implementation of the IK are: | ||
+ | - The ankle plantar flexion angle in the OpenSim export corresponds to zero degree when the foot is flat on the floor and the tibia is vertical (most Visual3d models are built with the foot z axis running from the toes to the ankle center) | ||
+ | - that the knee joint will translate in the thigh X-Y plane as a function of the knee joint angle in the same manner as the OpenSim model | ||
+ | - the Hip joint center is the located at the values set in the gait2354 or gait2392 osim models | ||
+ | - the axes of rotation at the ankle and subtalar joints are skewed. (The direction cosines of right plantar flexion axis = 0.9793, -0.1045, -0.1736. The direction cosines of right subtalar axis = -0.1209, 0.7872, 0.6047). | ||
+ | |||
+ | If you look at the osim file you will see that the knee motion, the hip center location and the ankle/ | ||
+ | |||
+ | ==== Exported Force and Free Moment ==== | ||
+ | |||
+ | Visual3D exports the FORCE and FREEMOMENT signals that are found in the data tree. | ||
+ | |||
+ | ==== Exported Center of Pressure ==== | ||
+ | |||
+ | After the Inverse Kinematics (IK) fit, the entire model could move relative to the center of pressure thus leaving the IK fit with a significant effect on the moments at the ankle, knee and hip. To counteract this Visual3D first computes and stores the local coordinates of the center of pressure in the foot coordinate system (pre-IK) whenever a foot is in contact with the plate. Then after the IK fit is complete Visual3D retrieves the pre-IK coordinates of the COP and transforms them from the post-IK foot coordinate system into lab space. Thus if the vertical component of the COP in the output .mot file you will not lie flat along the floor (or treadmill); however if look at the distance from the center of pressure to the ankle in OpenSim it should look OK. (Remember the model itself can move up and down in OpenSim, so the location of the COP under the foot is what matters not the COP coordinates in lab space.) | ||
+ | |||
+ | ==== Exporting Other Models ==== | ||
+ | |||
+ | Visual3D' | ||
+ | |||
+ | ==== Comparing Visual3D and SIMM exporting to OpenSim ==== | ||
+ | |||
+ | Visual3D and SIMM each accomplish a different task. You can think of the process of generating muscle driving simulations in OpenSim as occurring in three steps: | ||
+ | |||
+ | - Build a Musculoskeletal Model | ||
+ | - Import the Model along with Motion Capture and Force Plate Data to OpenSim | ||
+ | - Analyze/ | ||
+ | |||
+ | SIMM works at Step 1. If you are using a standard OpenSim model to analyze walking or running then you really do not need SIMM since OpenSim comes with two default full body models. (One includes 54 lower extremity muscles and the other includes 92.) In theory you could also bypass SIMM by creating models directly with an xml file, but practically speaking if you are looking at non-standard or non-gait models then SIMM can very helpful. If you are looking at walking and running then SIMM may not be needed. | ||
+ | |||
+ | Visual3D comes in at step 2. Visual3D is not required for step 2 especially if you are using the default Open marker set; however if you deviate from the expected marker set then importing the motion capture and force plate data into OpenSim can be a very cumbersome process. Visual3D will also allow you to do many, many more standard kinematic and kinetic analyses from your motion capture data then are available in OpenSim. In short Visual3D will quickly export walking and running data into OpenSim while simultaneously providing you with a large number of kinematic, kinetic and data analysis tools. | ||
+ | |||
+ | ==== OpenSim Joint Moments and Joint Load ==== | ||
+ | |||
+ | You can get the Inverse Dynamics directly out of OpenSim using the " | ||
+ | |||
+ | **NOTE**: Before running OpenSim' | ||
+ | |||
+ | ===== Compatibility ===== | ||
+ | |||
+ | - Visual3D v4.0 - The basic Visual3D-to-OpenSim integration is available. | ||
+ | - Visual3D v4.9.3 - Compatible with OpenSim version 2.4.0. | ||
+ | - OpenSim version 2.4.0 looks for the ground reaction force data in a separate .xml or .mot file. Visual3D v4.9.3 and later will generate this new ground reaction force file, named Visual3_SIMM_grf.mot, | ||
+ | - Visual3D now automatically scales the torso and feet to be equal to the average of the left and right femoral lengths with the new torso and feet manual scale factors written to Visual3d_Scale_ScaleSet.xml. This modification was made because most users build their feet and head without markers at the very end of the foot and at the top of the head. Using the average thigh length seems a reasonable scaling approximation for these segments as physical anthropometry studies have shown thigh length is a somewhat strongly correlated with height. | ||
+ | - In the OpenSim Dialog the user is now prompted for the OpenSim version number. | ||
+ | - Note: After running RRA in OpenSim version 2.4.0 sometimes the bones will disappear. (This is apparently happens because RRA will occasionally leave the “Working Directory”.) To fix the problem go to the OpenSim Edit-> | ||
+ | |||
+ | - OpenSim 4.0 - IOpening (File -> Load Motion) the Visual3d_SIMM_input.mot file in previous versions of OpenSim loaded the states and ground reaction data were applied. As of OpenSim 4.0, you need to load the Visual3d_SIMM_input.mot file, then [[https:// | ||
+ | |||
+ | ==== Example ==== | ||
+ | |||
+ | An example of this export process can be found [[Visual3D: | ||
+ | |||
visual3d/documentation/kinematics_and_kinetics/opensim.1720027640.txt.gz · Last modified: 2024/07/03 17:27 by sgranger