Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Revert to cross-product delta-theta formulation
Browse files Browse the repository at this point in the history
  • Loading branch information
shueja committed Jun 22, 2024
1 parent 9b508df commit 66c6e82
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/optimization/SwerveTrajoptUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,19 @@ inline void ApplyKinematicsConstraints(
// If the angles are equal, the angle between the unit vectors should be
// zero.
//
// a b = ||a|| ||b|| cos(angleBetween) NOLINT
// = 1 * 1 * 1
// = 1
// a x b = ||a|| ||b|| sin(angleBetween) NOLINT
// = 1 * 1 * 0
// = 0
//
// a ⋅ b = 1
// a.x * b.x + a.y * b.y = 1
// cos(theta_diff) * cos(omega_n * dt_sgmt) + NOLINT
// sin(theta_diff) * sin(omega_n * dt_sgmt) = 1 NOLINT
problem.SubjectTo(theta_diff_cos * sleipnir::cos(omega_n * dt_sgmt) +
theta_diff_sin * sleipnir::sin(omega_n * dt_sgmt) ==
1);
// a x b = 0
// a.x * b.y - b.x * a.y = 0
// a.x * b.y = b.x * a.y
// cos(theta_diff) * sin(omega_n * dt_sgmt) =
// sin(theta_diff) * cos(omega_n * dt_sgmt)
// NOTE: angleBetween = pi rad would be another solution
problem.SubjectTo(theta_diff_cos * sleipnir::sin(omega_n * dt_sgmt) -
theta_diff_sin * sleipnir::cos(omega_n * dt_sgmt) ==
0);
problem.SubjectTo(
theta_cos_n_1 * theta_cos_n_1 + theta_sin_n_1 * theta_sin_n_1 == 1);
problem.SubjectTo(vx_n_1 + ax_n * dt_sgmt == vx_n);
Expand Down

0 comments on commit 66c6e82

Please sign in to comment.