File tree Expand file tree Collapse file tree 2 files changed +3
-2
lines changed
java/edu/wpi/first/math/kinematics
native/include/frc/kinematics Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ public SwerveModuleState[] toSwerveModuleStates(
167167 double y = moduleStatesMatrix .get (i * 2 + 1 , 0 );
168168
169169 double speed = Math .hypot (x , y );
170- Rotation2d angle = new Rotation2d (x , y );
170+ Rotation2d angle = speed > 1e-6 ? new Rotation2d (x , y ) : m_moduleHeadings [ i ] ;
171171
172172 moduleStates [i ] = new SwerveModuleState (speed , angle );
173173 m_moduleHeadings [i ] = angle ;
Original file line number Diff line number Diff line change @@ -66,7 +66,8 @@ SwerveDriveKinematics<NumModules>::ToSwerveModuleStates(
6666 units ::meters_per_second_t y{moduleStateMatrix (i * 2 + 1 , 0 )};
6767
6868 auto speed = units ::math ::hypot (x, y);
69- Rotation2d rotation{x.value (), y.value ()};
69+ auto rotation = speed > 1 e- 6 _mps ? Rotation2d{x.value (), y.value ()}
70+ : m_moduleHeadings[i];
7071
7172 moduleStates[i] = {speed, rotation};
7273 m_moduleHeadings[i] = rotation;
You can’t perform that action at this time.
0 commit comments