Skip to content

added pose prediction + added misc changes from our testing branch#114

Open
JAMthepersonj wants to merge 8 commits intomainfrom
JW-added-pose-prediction
Open

added pose prediction + added misc changes from our testing branch#114
JAMthepersonj wants to merge 8 commits intomainfrom
JW-added-pose-prediction

Conversation

@JAMthepersonj
Copy link
Contributor

@JAMthepersonj JAMthepersonj commented Mar 15, 2026

Tested on the robot

@JAMthepersonj JAMthepersonj changed the title added pose prediction added pose prediction + added misc changes from our testing branch Mar 15, 2026
@JAMthepersonj JAMthepersonj marked this pull request as ready for review March 15, 2026 14:52
Copy link
Contributor

@batchen1 batchen1 left a comment

Choose a reason for hiding this comment

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

Great job Jackson, this seems like it will improve shooting accuracy by a lot.
I looked briefly at the code and my main comments are:
1 - instead of using Joystick for prediction, it is probably more accurate to use the robot field velocity from the swerve subsystem. It will simplify the code quite a bit and will be more accurate
2 - currently the future pose prediction is only used for angler and shooter adjustment, I think the turret angle is still not accounting for that.
3 - once you fix that, I will do a more thorough review of the changes.

public static final double AVERAGE_CAM_LATENCY_STD_DEV = 0; // seconds; TODO: change Later
public static final double MAX_VISION_DISTANCE_SIMULATION = 6;

public static final double PREDICTION_TIME = 2.25;
Copy link
Contributor

Choose a reason for hiding this comment

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

How did you get this constant? was it measured? is it the same for all distances? this may be good enough but can be changed to use some formula based on distance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was tuned for while testing and it was the best value we got

return 3.281 * distance > 16 ? 6 : 3.281 * distance < 4.66 ? 1.42 : distance;
}

private Pose2d robotPosePredicitionCalculation(Pose2d robotPose) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why you chose to use joystick for the estimated future pose. The joystick show driver intent but not actual speed. I think it will be a lot more accurate to use the swerve getFieldVelocity() instead. If you use that you don't need to keep multiple poses to estimate speed.

Copy link
Contributor Author

@JAMthepersonj JAMthepersonj Mar 15, 2026

Choose a reason for hiding this comment

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

i agree but i will have to test this after finishing up the turret PID

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed just not tested

private double calculateDistanceMeters(Pose2d robotPose, Pose2d targetPose) {
return robotPose.getTranslation().getDistance(targetPose.getTranslation());
double distance = robotPosePredicitionCalculation(robotPose).getTranslation().getDistance(targetPose.getTranslation());
return 3.281 * distance > 16 ? 6 : 3.281 * distance < 4.66 ? 1.42 : distance;
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this? are you trying to clamp the distance? there's ways to code this that are more readable. Use constants and if statements instead of ternary expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants