Using the very handy Limelight documentation, I was able to program our tank drive robot to move into position using a Limelight with reflective tape. The code I used is below (I converted it to Java) https://docs.limelightvision.io/en/latest/cs_aiming.html
However, our robot this year has a Mecanum wheel drivetrain. I’ve attempted implementing a system similar to the one in the tank drive example, and using the driveCartesian() method to implement it, but I’ve been stuck for a while. Can anyone give me a push in the right direction of how one might go about implementing this? I’ve looked around lots of forum posts, and it doesn’t seem like anyone else has this issue. My idea for how this might work is below.
When ran, the code does not appear to target the goal properly. It would move seemingly randomly, yet consistently in one direction when I began running the targeting code. Once I calibrated it, it stopped moving at all, even when it wasn’t aligned with the reflective tape. Could it be that my Limelight x & y variables aren’t being updated enough?
UPDATE: I had temporarily commented out the portion of code that updates the values. I will test this to see if anything changes as soon as I can, but in the meantime, does the formatting look correct here?
There’s a lot of language in your code that I don’t necessarily understand It would be helpful if we could just look at GitHub or something in order to see what min command means and how you’re getting your limelight values
That’s really what I’m trying to do here. The program calculates the distance it needs to move either forward or backward, left or right, and adds them together to get a net movement. Do you know if there is a better way of implementing this?
Cartesian drive takes 3 parameters speedX speedY, and speedrotation.
Your limelight gives you a value multiplied by a kP. You have lots of unneeded lines of code.
If absolutevalue(limelightxvalue) > minDegrees {xadjust = kP*limelightxvalue} else xadjust = 0
//Do the same for your y value
CartesianDrive(xadjust + xjoystickorauto, yadjust + yjoystickorauto, joystickorautorotation )
Couple things here…
Robot code thinks x is forward backward convention, so make sure your putting your joystick values which are opposite convention in the right place.
Instead of having your robot translate left and right, consider having your robot ROTATE left or right… Especially with a round goal, your robot may unintentionally circle the hub as a result.