Velocity imu test -> master#262
Open
DanielShapir wants to merge 14 commits into
Open
Conversation
# Conflicts: # src/main/java/frc/robot/Robot.java
DanielShapir
commented
Jun 7, 2026
DanielShapir
commented
Jun 7, 2026
hillelv
requested changes
Jun 7, 2026
DanielShapir
commented
Jun 20, 2026
Comment on lines
+38
to
+39
| private final TimedValue<Pose2d> lastEstimatedPose; | ||
| private final TimedValue<ChassisSpeeds> lastEstimatedVelocity; |
hillelv
reviewed
Jun 20, 2026
Comment on lines
+149
to
+150
| if (ToleranceMath.isNear(new ChassisSpeeds(), rawVelocity, WPILibPoseEstimatorConstants.ESTIMATED_VELOCITY_TOLERANCE)) { | ||
| lastEstimatedVelocity.setValue(new ChassisSpeeds()); |
There was a problem hiding this comment.
0.5 m/s is a very high deadband for this
Comment on lines
+151
to
+161
| } else if ( | ||
| ToleranceMath.isNear(lastEstimatedVelocity.getValue(), rawVelocity, WPILibPoseEstimatorConstants.ESTIMATED_VELOCITY_TOLERANCE) | ||
| ) { | ||
| lastEstimatedVelocity.setValue( | ||
| new ChassisSpeeds( | ||
| (rawVelocity.vxMetersPerSecond + lastEstimatedVelocity.getValue().vxMetersPerSecond) / 2.0, | ||
| (rawVelocity.vyMetersPerSecond + lastEstimatedVelocity.getValue().vyMetersPerSecond) / 2.0, | ||
| (rawVelocity.omegaRadiansPerSecond + lastEstimatedVelocity.getValue().omegaRadiansPerSecond) / 2.0 | ||
| ) | ||
| ); | ||
| } |
There was a problem hiding this comment.
why avarege the velocities if they're close?
Comment on lines
+162
to
+163
| // If neither condition is met, it is a massive vision spike. We do NOT update the value, preserving the safe velocity. | ||
| lastEstimatedVelocity.setTimestamp(timestamp); |
There was a problem hiding this comment.
if you're filtering spikes you should do it by acceleration and not by velocity
Comment on lines
+305
to
+314
| public ChassisSpeeds getFieldRelativeEstimatedVelocity(ChassisSpeeds swerveVelocity) { | ||
| if (useEstimatedVelocity(swerveVelocity, lastEstimatedVelocity.getValue())) { | ||
| return lastEstimatedVelocity.getValue(); | ||
| } | ||
| return swerveVelocity; | ||
| } | ||
|
|
||
| private boolean useEstimatedVelocity(ChassisSpeeds swerveVelocity, ChassisSpeeds estimatedVelocity) { | ||
| return !ToleranceMath.isNear(swerveVelocity, estimatedVelocity, WPILibPoseEstimatorConstants.ESTIMATED_VELOCITY_TOLERANCE); | ||
| } |
Comment on lines
+305
to
+310
| public ChassisSpeeds getFieldRelativeEstimatedVelocity(ChassisSpeeds swerveVelocity) { | ||
| if (useEstimatedVelocity(swerveVelocity, lastEstimatedVelocity.getValue())) { | ||
| return lastEstimatedVelocity.getValue(); | ||
| } | ||
| return swerveVelocity; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.