Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code calculates Minimum Jerk instead of Minimum Snap #98

Open
infrontlight opened this issue May 6, 2024 · 1 comment
Open

Code calculates Minimum Jerk instead of Minimum Snap #98

infrontlight opened this issue May 6, 2024 · 1 comment

Comments

@infrontlight
Copy link

Hello,

I've been reviewing the trajectory optimization code and noticed a potential issue in the segment labeled as "minimum snap matrix." The code snippet is as follows:

/* ---------- minimum snap matrix ---------- */
Eigen::MatrixXd Q = Eigen::MatrixXd::Zero(seg_num * 6, seg_num * 6);

for (int k = 0; k < seg_num; k++)
{
  for (int i = 3; i < 6; i++)
  {
    for (int j = 3; j < 6; j++)
    {
      Q(k * 6 + i, k * 6 + j) =
          i * (i - 1) * (i - 2) * j * (j - 1) * (j - 2) / (i + j - 5) * pow(Time(k), (i + j - 5));
    }
  }
}

From my understanding, this matrix setup seems to calculate the Q matrix for a minimum jerk problem (third derivatives of position), rather than the fourth derivatives required for a minimum snap calculation. The loop indices and the polynomial terms (i * (i - 1) * (i - 2) * j * (j - 1) * (j - 2)) specifically handle the third derivatives.

For minimum snap, we expect the matrix to involve fourth derivatives, which would typically include terms up to the fifth order (i * (i - 1) * (i - 2) * (i - 3) * j * (j - 1) * (j - 2) * (j - 3)). Could this be an oversight, or is there another part of the code that adjusts for this?

I would appreciate clarification on this, as the designation of the matrix as "minimum snap" might be misleading if it indeed calculates minimum jerk values.

Thank you for looking into this.

@bigsuperZZZX
Copy link
Member

Thank you for pointing out this mistake. The current code is the implementation of minimum jerk rather than minimum snap indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants