Cubic Spline Setup

SCONE is a software tool for predictive simulations of biomechanical movement. It uses OpenSim for modeling and simulation, and performs optimization using various control strategies, including feed-forward control, proprioceptic feedback control, and bal
POST REPLY
User avatar
Eric Hu
Posts: 27
Joined: Tue Oct 03, 2023 1:56 pm

Cubic Spline Setup

Post by Eric Hu » Wed Mar 06, 2024 9:39 am

Hi Dr. Geijtenbeek,

I was looking into implementing the Interpolatary Cubic Spline within my controller and I came across this previous post: viewtopic.php?f=1180&t=16604&sid=547111 ... e9e0b511ee

I saw that you mentioned that if I wanted to set different values for each y control point, I should set these values within the "Parameters" section of the Simulation Objective or create my own par.init file in the CMAoptimizer. I was wondering what the functions/syntax would be for both. I didn't see a variable within the documentation that could set these parameters in the Simulation Objective, and I wanted to ask if the variable to use within the CMAoptimizer was the "init" variable to set the initial .par files.

Additionally, I wanted to clarify if setting these different y control point is truly necessary. To my understanding, if I give the values a certain mean and standard deviation to optimizer around, the optimizer should adjust the shape of the cubic spline to best accommodate the measures that I set. Is my understanding correct? Would there be any instance where that would not be the case?

Thank you so much,
Eric

User avatar
Thomas Geijtenbeek
Posts: 436
Joined: Wed Mar 12, 2014 8:08 am

Re: Cubic Spline Setup

Post by Thomas Geijtenbeek » Fri Mar 08, 2024 9:32 am

You indeed normally do not need to initialize each control point individually. Instead, the Optimizer should try to find the best values during the optimization.

You can however use a .par file to initialize the means and standard deviations of the individual control points, if you wish. For more information, see:

https://scone.software/doku.php?id=doc:init

User avatar
Eric Hu
Posts: 27
Joined: Tue Oct 03, 2023 1:56 pm

Re: Cubic Spline Setup

Post by Eric Hu » Tue Mar 12, 2024 9:04 am

Dr. Geijtenbeek,

Thank you so much for your response. I have a follow up question about setting up the par file. I created a par file with 3 columns (parameter name, mean, and standard deviation) and added the file to the optimizer just as the documentation mentioned. The init_par file only has initial parameters of the spline (Y and dt of the control points). I added the file the same way that the documentation highlighted, but I am not getting the values to appear in the parameters column when I save the file (the parameters column is not updating to the values I have in the init_par file). I was wondering if there is additional syntax that I need to be aware of within the controller file or if I was missing anything anywhere else. I can share pictures if this explanation is not clear.

Thank you so much,

Eric

User avatar
Thomas Geijtenbeek
Posts: 436
Joined: Wed Mar 12, 2014 8:08 am

Re: Cubic Spline Setup

Post by Thomas Geijtenbeek » Wed Mar 13, 2024 1:47 am

Parameter files have four columns (name, best, mean, stdev). The mean and stdev are used for initialization, unless you specify "use_best_as_mean=1".

User avatar
Eric Hu
Posts: 27
Joined: Tue Oct 03, 2023 1:56 pm

Re: Cubic Spline Setup

Post by Eric Hu » Fri Mar 15, 2024 1:43 pm

Dr. Geijtenbeek,

Thank you for your response. I managed to fix that issue. Now, I have another issue pertaining to the cubic spline function. I was wondering if there is any way to constrain the y values of each control point within a their own certain ranges? For example, if control point Y0 needs to be within <0,0.1> and control point Y1 needs to be within<0.6,0.8>, is there a way to constrain the points to be within their respective ranges?

I only wish to know this because the spline that I am creating is not optimizing to the ranges that I would like them to be. I'm not sure why that is the case, but I thought a good way to control that is to bound each control point to optimize within their own specific range. If there is a better solution than this, I would love to learn it.

Thank you,
Eric

User avatar
Thomas Geijtenbeek
Posts: 436
Joined: Wed Mar 12, 2014 8:08 am

Re: Cubic Spline Setup

Post by Thomas Geijtenbeek » Mon Mar 18, 2024 8:44 am

You cannot set the range individually per control point. Best thing you can do is set the initial value and keep the STDEV small. Also, be sure to use as little control points as possible.

User avatar
Eric Hu
Posts: 27
Joined: Tue Oct 03, 2023 1:56 pm

Re: Cubic Spline Setup

Post by Eric Hu » Mon Mar 18, 2024 12:58 pm

Dr. Geijtenbeek,

Thank you for the insight. When I implement those tips, my model still doesn't seem to output the curve that I would like.

The project that I am working on involves implementing a spline curve to mimic the torque at the ankle. I have removed the gastroc, soleus, and the tib ant off the right leg and added a coordinate actuator to the ankle. My project is to try and find a torque profile that can allow the model to replicate normal gait, and I have a kinematics and kinetic mimic measure to optimize my muscle with. As of right now, it seems that the model can get through the early and mid stance, but is not able to push off. When it wants to push off, the simulations ends early (I'm guessing because of the mimic measure). Is there any work around to this? I would love to use the mimic measure. But if there is a better method, I would love to try it.

Best,
Eric

User avatar
Thomas Geijtenbeek
Posts: 436
Joined: Wed Mar 12, 2014 8:08 am

Re: Cubic Spline Setup

Post by Thomas Geijtenbeek » Tue Mar 19, 2024 2:50 am

You can change the termination limit of the MimicMeasure, but if you want full control, you're best-off using a ScriptController.

POST REPLY