Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centripetal Swerve Pose Estimator #36

Open
barel13 opened this issue Jan 21, 2022 · 4 comments
Open

Centripetal Swerve Pose Estimator #36

barel13 opened this issue Jan 21, 2022 · 4 comments
Assignees
Labels

Comments

@barel13
Copy link
Member

barel13 commented Jan 21, 2022

We can't really know where the robot is using vision, because we can see the target from every position of the field, and we would classify it the same, so we drop the position, we just know how far are we, and the angle from the target

@Se-gol
Copy link

Se-gol commented Jan 22, 2022

  public Translation2d getRobotTranslation2d() {
       if (!photonCamera.hasTargets()) return null;
       double distance = getTargetDistance();
       Rotation2d gyroAngle = RobotContainer.navx.getRotation2d();
       Rotation2d relativeAngle = photonCamera.getLatestResult().getBestTarget().getCameraToTarget().getRotation();
       Rotation2d perpendicularAngle = gyroAngle.minus(relativeAngle);
       Translation2d translation2d = new Translation2d(distance * Math.cos(perpendicularAngle.getRadians()), distance * Math.sin(perpendicularAngle.getRadians()));
       return HUB_POSITION.minus(translation2d);
   }

You can use the navx to know where you're looking at the target from.

@barel13
Copy link
Member Author

barel13 commented Jan 22, 2022

You can't know from the vision where are you in the field due the fact that the target has a circle shape and you can look at the target from every position (there is no notion of "I'm right to the target"), you only can know how far are you from the target, and how much you need to rotate in order to align to the target. And when you don't see the camera you can't use the data from photonvision...

@katzuv
Copy link
Member

katzuv commented Jan 22, 2022

@Se-gol, FTFY.
@barel13, what @Se-gol says that if you roughly know your heading, you can infer what part of the vision target you see.
This doesn't mean that "radial" localization isn't helpful, it's good for aiming towards the Hub.

@barel13
Copy link
Member Author

barel13 commented Jan 28, 2022

Could be helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants