Skip to content

Velocity imu test -> master#262

Open
DanielShapir wants to merge 14 commits into
masterfrom
velocity-imu-test
Open

Velocity imu test -> master#262
DanielShapir wants to merge 14 commits into
masterfrom
velocity-imu-test

Conversation

@DanielShapir

Copy link
Copy Markdown

No description provided.

Comment on lines +38 to +39
private final TimedValue<Pose2d> lastEstimatedPose;
private final TimedValue<ChassisSpeeds> lastEstimatedVelocity;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong place

@DanielShapir DanielShapir self-assigned this Jun 20, 2026
Comment on lines +149 to +150
if (ToleranceMath.isNear(new ChassisSpeeds(), rawVelocity, WPILibPoseEstimatorConstants.ESTIMATED_VELOCITY_TOLERANCE)) {
lastEstimatedVelocity.setValue(new ChassisSpeeds());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
)
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to separate to two functions

Comment on lines +305 to +310
public ChassisSpeeds getFieldRelativeEstimatedVelocity(ChassisSpeeds swerveVelocity) {
if (useEstimatedVelocity(swerveVelocity, lastEstimatedVelocity.getValue())) {
return lastEstimatedVelocity.getValue();
}
return swerveVelocity;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ternary

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants