Page 1 of 1

Cubic Spline Setup

Posted: Wed Mar 06, 2024 9:39 am
by eric_hu32733
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

Re: Cubic Spline Setup

Posted: Fri Mar 08, 2024 9:32 am
by tgeijten
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

Re: Cubic Spline Setup

Posted: Tue Mar 12, 2024 9:04 am
by eric_hu32733
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

Re: Cubic Spline Setup

Posted: Wed Mar 13, 2024 1:47 am
by tgeijten
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".

Re: Cubic Spline Setup

Posted: Fri Mar 15, 2024 1:43 pm
by eric_hu32733
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

Re: Cubic Spline Setup

Posted: Mon Mar 18, 2024 8:44 am
by tgeijten
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.

Re: Cubic Spline Setup

Posted: Mon Mar 18, 2024 12:58 pm
by eric_hu32733
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

Re: Cubic Spline Setup

Posted: Tue Mar 19, 2024 2:50 am
by tgeijten
You can change the termination limit of the MimicMeasure, but if you want full control, you're best-off using a ScriptController.