PID Example HELP

We’re new to Java this year and we were having some problem with PID.

PIDController doesn’t seem to work, and we were wondering if we could possibly have some code to use as guidelines that has PID in it.

Thanks

We are unable to initialize it. We import the library and when tried to call the error says cannot find symbol. symbol: constructor PIDController()

Are you passing the required argument? Take a look at the documentation, and there are two constructors. Both require arguments.

PIDController(double Kp, double Ki, double Kd, PIDSource source, PIDOutput output, double period)

and

PIDController(double Kp, double Ki, double Kd, PIDSource source, PIDOutput output)

Yes, the code is PIDController(pVal , iVal , dVal, armposition, arm);
armposition is from the pot and arm is the jag

What type of objects are each one? I’m unclear on what pot is, my apologies.

That sentence did not come out like I meant it to.

double, double, double, edu.wpi.first.wpilibj.AnalogChannel, edu.wpi.first.wpilibj.Jaguar

Is cannot find symbol. symbol: constructor PIDController() the exact error message? Because just as a test, I tried to initialize a Solenoid with a string as an argument and it said cannot find symbol. symbol: constructor Solenoid(java.lang.String). That would mean that it isn’t being given any arguments whatsoever. Is there another place in your code where you accidentally initialized one, perhaps?

symbol: method PIDController() is the error

[strike]I believe the problem is your source and output. You are sending edu.wpi.first.wpilibj.AnalogChannel, edu.wpi.first.wpilibj.Jaguar, while PIDController expects classes implementing the edu.wpi.first.wpilibj.PIDSource and edu.wpi.first.wpilibj.PIDOutput interfaces. The idea is that you create your own classes implementing these interfaces, and pass them to the constructor.[/strike]

My bad, I must have checked the wrong class in the javadoc somehow.

AnalogChannel implements PIDSource and Jaguar implements PIDOutput, so that’s probably not their problem.

Yeah, it should be able to work. I’m still curious about two things, though.

  1. The error says it’s a method, not a constructor.
  2. The error doesn’t list ANY arguments.

Any chance we could see the part of your code that is erroring?