Using MATLAB to Change Spring Properties

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Logan Lancaster
Posts: 1
Joined: Mon Aug 21, 2023 8:43 am

Using MATLAB to Change Spring Properties

Post by Logan Lancaster » Mon Nov 20, 2023 10:31 am

Hello,

I am a student at the University of Utah doing research in wearable robotics. I am relatively new to OpenSim and am using Moco to optimize spring parameters for a wearable device. My model has a path spring connected between the ankles and I am trying to modify the parameters of that spring (stiffness and rest length) in a MATLAB script.

I am having trouble knowing which commands to call to change the parameters of the spring. I am able to load in the spring into MATLAB as a force, but I am unsure how to change parameters from here because it loads spring into MATLAB as a 'force' and not as a .pathSpring'.

Spring = model.getForceSet().get('Spring');

The alternative method that I have been attempting is to just make a new path spring, set the parameters I desire, then add the spring to the model. However, I am also having trouble with specifying the geometry path between the ankles. To create the spring originally, I edited the .osim file in a text editor to include a path spring between two path points. How would I specify a geometry path between two path points in MATLAB?

I have also tried to specify the geometry path by using the getGeometryPath(Spring) command after the above command, but that does not work.

I could also just edit the .osim file in MATLAB but I would prefer to use OpenSim commands.

If you have any advice to give me, I would greatly apricate it.

Tags:

User avatar
Thomas Uchida
Posts: 1778
Joined: Wed May 16, 2012 11:40 am

Re: Using MATLAB to Change Spring Properties

Post by Thomas Uchida » Mon Nov 20, 2023 2:04 pm

Please see the "Common Scripting Commands" page in the documentation (https://simtk-confluence.stanford.edu:8 ... g+Commands) and search for the string "downcast". In your case, the code will be something like the following:

Code: Select all

spring = PathSpring.safeDownCast( model.getForceSet().get('Spring') );

POST REPLY