utils.UtilsLengthOpt
Created on Wed Jul 28 12:54:25 2021
@author: hwang
Module Contents
Functions
|
Initialize the worker process. |
|
this objective function calculate the difference of moment arms between opensim model and mujoco model. |
|
Check if the moment arm differences between the osim and mjc models are beyond |
|
This is a self-defined particle swarm optimizer (PSO) for the moment arm optimization. The purpurse of define |
- utils.UtilsLengthOpt.initializeWorker(shared_model) None[source]
Initialize the worker process.
- INPUTS:
- shared_model
the mujoco model
- utils.UtilsLengthOpt.objMAMuscle(x, side_id, wrap_type, wrap_id, pos_wrap, size_wrap, rotation_wrap, osim_ma, muscle, joints, joint_ranges, evalN)[source]
this objective function calculate the difference of moment arms between opensim model and mujoco model.
Inputs:
- x: vector
optimization vectors
- side_id: int
the id list of the optimization sides
- wrap_type: string
the type defined in O2MStep2
- wrap_id: int
wrapping object id
- pos_wrap: vector
the position of the wrapping object
- size_wrap: vector
the size of the wrapping object
- rotation_wrap: vector
the rotation vector of the wrapping object
- osim_ma: vector
the moment arm vector of the osim model
- muscle: string
muscle name
- joints: list of string
the coordinates that the moment arms are caclulated
- angle_ranges: list
the motion ranges of the mentioned coordinates
- evalN: int
the number of evaluation points for the moment arm calculation
- Outputs:
rms_ma: root mean square of the moment arm difference.
rms_x: root mean square of the optimizing parameters.
- utils.UtilsLengthOpt.getMomentArmDiff(mjc_model, muscle, joints, jnt_motion_range, osim_ma_joints, evalN)[source]
Check if the moment arm differences between the osim and mjc models are beyond thresholds
Only works for one muscle at multiple joints.
- utils.UtilsLengthOpt.maOptPSO_cust(mjc_model_path, muscle, joints, joint_ranges, side_id, wrap_type, wrap_id, pos_wrap, size_wrap, rotation_wrap, osim_ma, evalN, optParam_lb, optParam_ub, cost_org, speedy=False)[source]
This is a self-defined particle swarm optimizer (PSO) for the moment arm optimization. The purpurse of define it here, instead of using other packages, is to gain custmizied feature control. This is a temporary solution, eventually, these features should be added to the exist PSO python packages and use them as the optimizor
- INPUTS:
mjcModel: mujoco model muscle: string
muscle name
- joints: list
a list of coordinate names for the optimization
- joint_ranges: list
a list of vectors that defines the motion ranges of the above coordinates
- side_id: int
the id list of the optimization sides
- wrap_type: string
the type defined in O2MStep2
- wrap_id: int
wrapping object id
- pos_wrap: vector
the position of the wrapping object
- size_wrap: vector
the size of the wrapping object
- rotation_wrap: vector
the rotation vector of the wrapping object
- osim_ma: vector
the moment arm vector of the osim model
- evalN: int
the number of evaluation points for moment arm opt
- opt_param_lb: array
the lower bound of the optimized parameters
- opt_param_ub: array
the upper bound of the optimized parameters
- cost_org: double
the cost function value before the optimization
- speedy: boolean
If true, reduce the particle size and iteration number
- OUTPUTS:
res_side: optimization side locations mjcModel: updated mujoco models