OpenSense via Matlab API: Setting orientation weights

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Christian Schauer
Posts: 2
Joined: Thu Sep 08, 2022 8:36 am

OpenSense via Matlab API: Setting orientation weights

Post by Christian Schauer » Wed Feb 22, 2023 12:07 pm

Hello OpenSim/OpenSense community!

I am looking for help on how to set the orientations_weights for specific body segments for the weighted least squares algorithm in IMUInverseKinematicsTool() via MATLAB scripting, so that I can assign different weights to the segments?

This is my example code section:
----------------------------------------------------------------------------------------------
imuIK = IMUInverseKinematicsTool();

% Set the model path to be used for tracking
imuIK.set_model_file(strrep(modelFileName, '.osim', '_calibrated.osim'));
imuIK.set_orientations_file(orientationsFileName);
% Set time range in seconds
imuIK.set_time_range(0, startTime);
imuIK.set_time_range(1, endTime);
imuIK.set_sensor_to_opensim_rotations(sensor_to_opensim_rotation);
% Set a directory for the results to be written to
imuIK.set_results_directory(resultsDirectory);
% Set a output motion file name
imuIK.set_output_motion_file(outputMotionFile);
imuIK.set_report_errors(writeOrientationErrors);

% Run IK
imuIK.run(visualizeTracking);
---------------------------------------------------------------------------------------------

I found in the API documentation the function set_orientation_weights(), however I do not know how to use this exactly.
It would be perfect, if someone could send me an example-code for the input to this function or another way to handle this issue.
I know the possibility to set them in the GUI and as XML-tags, but I would prefer to alter them via MATLAB.

Thank you in advance,
best regards
Christian

Tags:

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: OpenSense via Matlab API: Setting orientation weights

Post by Ayman Habib » Thu Feb 23, 2023 12:12 pm

Hi Christian,

The documentation of the tool on doxygen here
https://simtk.org/api_docs/opensim/api_ ... sTool.html
Suggests that there's a method to retrieve a reference to the set of Orientation weights

Code: Select all

upd_orientation_weights ()
Once you have the reference to the set you can modify the contents using adoptAndAppend or cloneAndAppend methods.
Alternatively, the tool has a method to set the weights from independently constructed weightset using the method

Code: Select all

set_orientation_weights()
Please let us know if you run into issues using any of these methods.

Best regards,
-Ayman

User avatar
Christian Schauer
Posts: 2
Joined: Thu Sep 08, 2022 8:36 am

Re: OpenSense via Matlab API: Setting orientation weights

Post by Christian Schauer » Wed Mar 01, 2023 6:02 am

Hi Ayman!

Thank you for your reply.
Unfortunately, I am not familar with C++ coding. As a result I cannot identify the exact input to these mentioned methods.
Would it be possible for you to send me a code-example, which I can insert into my MATLAB script.
I am using four IMUs on pelvis, femur_r, tibia_r and calcn_r and I would have the possibility to change the orientation weights differently for these segments.

Thank you in advance!
Best wishes,
Christian

POST REPLY