PID vs Bang-Bang for alignment LimeLight


#1

I was wondering if Bang-Bang or PID is better for alignment while driving.


#2

I’ve heard a PD controller has been enough for a lot of people with aligning using the limelight.


#3

A decently tuned PIDF controller will always outperform a bang-bang controller. Tuning time is a downside, but getting it “most of the way there” is still a massive difference.


#4

My first year trying vision control (stronghold) we used a kangaroo and GRIP (which seems similar to how limelight works, but with more setup), and then I learned that the hard part is not getting the data for the vision, but dealing with it.

Our vision code only rotated the robot to the goal, and I quickly developed my own P based control, but found out that because of the minimum voltage required to get it moving, I had to have more. I didn’t know about PID at the time, and so I made it have two P values, one when it was close, one when it was far and it kinda sorta slowly worked. I’d just advise a well tuned PD to start, and that should be enough. Later adding in I & F wouldn’t hurt, but not a huge deal.


#5

I’d suggest Bang-Bang to get it working and then PID after you have that to align it quicker


#6

We have Bang-Bang working but sometimes the hatch panels are off slightly


#7

Have you seen the Deep Space Case Study? http://docs.limelightvision.io/en/latest/cs_drive_to_goal_2019.html

Many teams find success using only P. You can pass the drive command and steer command values below directly into an arcade drive method:

 
final double STEER_K = 0.03;                    // how hard to turn toward the target
final double DRIVE_K = 0.26;                    // how hard to drive fwd toward the target
final double DESIRED_TARGET_AREA = 13.0;        // Area of the target when the robot reaches the wall
final double MAX_DRIVE = 0.7;                   // Simple speed limit so we don't drive too fast

double tv = NetworkTableInstance.getDefault().getTable("limelight").getEntry("tv").getDouble(0);
double tx = NetworkTableInstance.getDefault().getTable("limelight").getEntry("tx").getDouble(0);
double ty = NetworkTableInstance.getDefault().getTable("limelight").getEntry("ty").getDouble(0);
double ta = NetworkTableInstance.getDefault().getTable("limelight").getEntry("ta").getDouble(0);
if (tv < 1.0)
{
  m_LimelightHasValidTarget = false;
  m_LimelightDriveCommand = 0.0;
  m_LimelightSteerCommand = 0.0;
  return;
}

m_LimelightHasValidTarget = true;

// Start with proportional steering
double steer_cmd = tx * STEER_K;
m_LimelightSteerCommand = steer_cmd;

// try to drive forward until the target area reaches our desired area
double drive_cmd = (DESIRED_TARGET_AREA - ta) * DRIVE_K;

// don't let the robot drive too fast into the goal
if (drive_cmd > MAX_DRIVE)
{
  drive_cmd = MAX_DRIVE;
}
m_LimelightDriveCommand = drive_cmd;

#8

This is what we are currently using, but we still have the issue of it being more to the left or the right, thus only having half a disk attached


#9

Using Bang Bang for our targeting system this year. We have a small (like 1 degree) “safe zone” where the robot doesn’t turn at all, and turns towards the target at a small rotational speed if outside of those bounds. It works well for our drivers (it’s how we place on the far side of the rocket) as long as you are traveling forward while targeting. This can be done at a low speeds–like 20% motor power. If you are looking to target in place, a PD loop is probably what you want to use.