FRC5549Robotics / 5549-2020

FRC Team 5549's 2019-2020 Robot Code
2 stars 2 forks source link

PID Loop for Shooter #14

Open dylantknguyen opened 4 years ago

dylantknguyen commented 4 years ago

Please implement a PID loop for the shooter. Use the following resources for assistance.

https://robotpy.readthedocs.io/projects/wpilib/en/latest/wpilib/PIDController.html https://frc-pdr.readthedocs.io/en/latest/control/using_WPILIB's_pid_controller.html

Parsia-8001 commented 4 years ago

Mikes Pseudocode:

        self.dashboard.putNumber('DB/Kp', 0)
        self.dashboard.putNumber('DB/Ki', 0)
        self.dashboard.putNumber('DB/Kd', 0)

        class encorderPid
            init(encoder)
                self.encdoer = encorder
            getSourceType()
             return kRate; #1
            setSourceType()
              pass
            pidGet()
              return self.encorder * mult;

        class motorOutput
           init(m1, m2)
             self.m1 = m1
             self.m2 = m2
           pidWrite(output)
            m1.set(output)
            m2.set(output)

        # shooter
          self.topMotorEncoderPid = encoderPid(self.topEncoder)
          self.topMotorOutput = motorOutput(top1, top2)
          self.topPIDController = PID(p,i,d,f,topMotorEncoderPid, topMotorOutput)

from Dylan

dylantknguyen commented 4 years ago

This was implemented bfb1bbc. However, it still needs to be tuned.

dylantknguyen commented 4 years ago

In 9ffa21a, you can input an RPM and get that RPM out but it's not a true PID. However, it works.

dylantknguyen commented 4 years ago

Implemented a real PID in fdb33b0

dylantknguyen commented 4 years ago

The PID has been tuned in 318267e with kF (feed-forward). This PID is far from perfect but is a good starting point.