Controlling a turret Motor in position mode

So I have a motor connected to a talon which is also connected to a quad encoder.

My goal is to take error angles from my vision system and be able to constantly have turret home to that location.

Where I struggle with this is it creates some sort of open loop… where I am getting constant rotation commands (which will hopefully make sense as I get closer to that point… 30 degrees, 25…20…10…etc) but it’s possible they don’t was well.

Can I just constantly keep resetting the position value? Does that make sense?

Does anyone have an example of something like this?

Thanks!

You can just update the error value. Also, you don’t even need the encoder. You can write a simple P or PID controller that just takes the error from the limelight. I want one on our turret, though so that we can always point to the target even when we are driving around.

Feel like the encoder would help accurately the

If anyone has any good examples of this that would be cool too

It could. Maybe it will read faster than the limelight and be smoother.

Our code is here https://github.com/phlogiston1/frc-3461-2020/blob/master/src/main/java/frc/robot/commands/AutoAim.java but it doesn’t use encoders.

Yet

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