Skip to content

Commit

Permalink
Fix vector calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
viggy96 committed Sep 18, 2024
1 parent 66d8012 commit ae1b558
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/lasarobotics/drive/MAXSwerveModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ private Measure<Velocity<Distance>> getParallelVelocity(SwerveModuleState state,
);

// Calculate portion of inertial velocity that is in direction of desired
var parallelModuleVelocity = moduleDesiredVelocityVector.scalarMultiply(moduleInertialVelocityVector.dotProduct(moduleDesiredVelocityVector));
var parallelModuleVelocity = moduleDesiredVelocityVector.scalarMultiply(
moduleInertialVelocityVector.dotProduct(moduleDesiredVelocityVector.normalize())
);

// Return velocity
return Units.MetersPerSecond.of(parallelModuleVelocity.getNorm());
Expand Down

0 comments on commit ae1b558

Please sign in to comment.