Open peiret opened 3 years ago
Hi @peiret, thanks for sharing your prototype. Unfortunately, I don't think this approach will work. Populating the m_time_acceleration
variable like this will produce inconsistent results since both calcIntegrandImpl and calcGoalImpl get called multiple times per iterate during an optimization, meaning that you're duplicating acceleration values or clearing them too early.
The way MocoGoal is designed, you can only use the inputs provided via const GoalInput& input
. The correct way to minimize jerk would be to introduce another layer of dynamics such that j = da/dt
, j
is jerk modeled using a control variable, and a
is acceleration, now a state variable. You could then simply minimize the jerk controls.
This is unfortunately significantly more complicated then just adding a new MocoGoal, but we could mimic the way acceleration controls are handled when using implicit multibody dynamics.
Hi,
My team and I are working on a new
MocoGoal
that minimizes the jerk (that is, the time-derivative of the acceleration). Minimizing higher-order time derivatives generally helps solver convergence and reduces the noise in the solution.To do that, we collect the acceleration of each coordinate in
MocoGoal::calcIntegrandImpl()
, which is supposed to be called for each collocation point (instant of time). Then, we would like to generate a spline for each coordinate acceleration and calculate the derivative (jerk). This last step is implemented inMocoGoal::calcGoalImpl()
, but that doesn't work.We don't seem to get the acceleration in all time instants, but rather a few instants, and sometimes duplicates. We also observed that a
clone()
of the goal is created for each thread. I asume this complicates the implementation described above since we will have to gather the information collected in all threads...What would be the best way to collect and sort the acceleration data? Are we missing something?
Thank you in advance!
Here are the goal implementation files:
MocoMinimizeJerkGoal.h
MocoMinimizeJerkGoal.cpp