Help with vision alignment

My team has been trying to align with the vision targets using our limelight 2. We have it working really well with a PID controller on tx when the robot is not moving. However, when the robot is moving linearly it will not align (it oscillates a lot). We’ve tried tuning it differently, or even locking the speed when the drivers are aligning, but nothing has worked so far.

Sounds like an issue with your PID controller. What are your constants? Sounds like an issue of too high of P or not enough D.

I would say the issue is using PID directly on the tX input. I’ve never seen this work well!

I know of two general patterns that teams have successfully used:

  1. Use tX to set a target angle, then use PID on a gyro to align to that angle (see Team 254’s excellent presentation on this subject), or
  2. Use tX multiplied by a scaling factor for your turning output (as described in the Limelight examples)

I’m sure there are other possibilities…but I can vouch for the two above.

Our team also ran into this issue a few times. First make sure you are processing in the lower res mode(there are two modes that you can run, lower should be default however) because when we used the high res mode we got a lot of oscillation. Also like others have said before make sure your PID is tuned( we didn’t use a PID we used the same scaling example linked above, it’s basically a PID with only P, I and D don’t really work well and aren’t needed) . Thirdly this could be an issue with multiple targets so you can change the way you look at targets and give your operator the ability to switch between them(worked pretty well 4 our team). Some other sources of errors could be a poorly tuned pipeline(this was our main problem) so your robot wouldn’t always be detecting the target when you are moving and swapping between 0 and a targeting command, if you want to try my teams settings I’d be happy to provide them(only thing you might need to change is min area/ fullness). Other than this I can’t think of any other errors of the top of my head.

As others have recommended, it sounds like an issue with your P-gain perhaps being too high. Try reducing it and maybe increasing your d-gain out to smoothen out your robots turn as it gets to it’s set-point. Also, if you haven’t already, make sure you have a slight tolerance (1 or 2 degrees) for your set-point, so that it has a couple of degrees range it can end up in, rather than one specific point.

I think you are running into a typical “pitfall”. You probably tuned your P value for turning while the robot is sitting still, then you added the ‘drive forward’ part of the code and suddenly your robot is oscillating. The problem is your robot turns a lot more easily when driving forward so in this situation your turning constant is too high. So turn down your turning constant a bit. Just keep working with it, I think you’re almost there.

2 Likes

I’ve found this blog post to be excellent on PID design:
http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/

Make sure you implement the reset windup mitigation section. The integral portion should be limited to what motor controllers allow.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.