Log in

View Full Version : PID Example HELP


Mark_K
20-02-2011, 12:23
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

Mark_K
20-02-2011, 14:03
We are unable to initialize it. We import the library and when tried to call the error says cannot find symbol. symbol: constructor PIDController()

ArchVince
20-02-2011, 14:08
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)

Mark_K
20-02-2011, 14:18
Yes, the code is PIDController(pVal , iVal , dVal, armposition, arm);
armposition is from the pot and arm is the jag

ArchVince
20-02-2011, 14:24
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.

Mark_K
20-02-2011, 14:26
double, double, double, edu.wpi.first.wpilibj.AnalogChannel, edu.wpi.first.wpilibj.Jaguar

ArchVince
20-02-2011, 14:34
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?

Mark_K
20-02-2011, 14:39
symbol: method PIDController() is the error

Patrickwhite
20-02-2011, 21:08
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.

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

Geek 2.0
21-02-2011, 00:01
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.

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

ArchVince
21-02-2011, 00:40
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?