Help With trying to code a PID Loop for Turret on a falcon

I am trying to use a PID loop on a turret with a falcon, however I do not think I have set it up right as I did not follow CTRE’s documentation thoroughly. Could someone please guide me through what to do and check if I have done anything wrong? The code is linked under the turret class in the github repository below.

Key distinction here… do you think you didnt do it right, or have you tested it and seen it not working right?

Generally speaking, its recommended to try things before asking for help. Then you can provide specifics about whats not working. Otherwise its basically “here’s 20000 lines of code, what’s wrong with it?” (Obviously the 20k number is exaggerated)

2 Likes

I understand that, however I just do not want to download code to the robot, test it, and the break something on it and have 2 weeks of work gone to waste because something broke. That was the whole point of this thread. I would like someone knowledgeable, someone who has coded a turret with a PID loop to overlook the code to ensure that something does not go horrifically wrong.

Realistically nothing will break if you tune your p value starting with very small values if you want to have some added saftey you can add some mechanical safe gaurds such as tether and pool noodle to anything in the path if you haven’t tested the turret with manual control then you should do that first if that works than you just need to be careful while tuning your gain values(kp,ki,kd) if you want to get accurate gains without guessing and checking you can run the sysId tool that comes with wpilib and create an analysis of general mechanism this will give you somewhat accurate with values without having to guess and check.

On top of the recommendations that were made by the other commenters, a trick we found was to create an Estop command that you can schedule when the current in your motors spikes too high, basically indicating a motor crash. This Estop command can require the subsystem and you can make it non interruptible and never ending, so while testing it can be a way to hard stop the subsystem until you restart robot code.

1 Like

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