Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Vision Circle Fittting #95

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Vision Circle Fittting #95

wants to merge 12 commits into from

Conversation

varun7654
Copy link
Collaborator

implement circle fitting for the vision pose estimates.
Most of this has been stolen from: https://www.chiefdelphi.com/t/frc-6328-mechanical-advantage-2022-build-thread/398645/21

Most code stolen from FRC 6328 Mechanical Advantage

Co-Authored-By: Jonah <[email protected]>
Co-Authored-By: Aum-P <[email protected]>
Co-authored-by: V-RA <[email protected]>
Co-Authored-By: Ayushk2023 <[email protected]>
@varun7654 varun7654 force-pushed the vision-circle-fitting branch from df14c7b to 5f6dbd8 Compare September 3, 2022 02:11
@varun7654 varun7654 changed the base branch from main to seperate-vision-shooter-code September 3, 2022 02:15
* @author jonahb55
* @author Mechanical Advantage 6328
*/
public final class CircleFitter {
Copy link

@ravzilla ravzilla Sep 6, 2022

Choose a reason for hiding this comment

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

If I understand this correctly the solver works by computing a residual that is equal to sum of (point-center guess)^2 then iterates on that solution by taking a step in the 4 cardinal directions and choosing an optimal point based on the residual of all 5 (center included).
right now the optimizer will take a path like this:
image

if this is working fine, i see no reason to change it, BUT the correct way to do this is by taking advantage of the fact that our residual function is differentiable. this will allow us to take a step directly towards the optimal solution like this:

image

The way we would do this would be by moving the center by stepsize * -1 * gradient of the residual each iteration
this would give us a 2D vector to move the center, just like the old code we would decrease our stepsize by some amount (https://en.wikipedia.org/wiki/Gradient_descent#Choosing_the_step_size_and_descent_direction)

If we need to improve the circle fitting we can do this, but if its working fine I see no reason to change it.

We could also do some optimizations by playing with the rate at which the step size decreases, dividing by half may be too much but that is just a guess.

tldr: if its working, we dont need to do this. If we want it to be faster or "more correct" we should do this

Copy link

Choose a reason for hiding this comment

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

also if java has a convex optimization library we should just use that, would make this a lot easier, im sure it exists, just not sure what we can put on the rio
http://haifengl.github.io/api/java/smile/math/BFGS.html
BFGS is a nice algorithm but idk what works on the robot

Base automatically changed from seperate-vision-shooter-code to main September 13, 2022 20:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants