|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
PID Positional Control (Java)
Hello all.
Recently I've been attempting to write some code to control a motor to travel to setpoint (like spin half a revolution) and then stop. I've been using a quadrature encoder to obtain my distance traveled data. I've had little to no success with either CAN Positional control or using an adapted methods of PID-DEMO and ArmDemo. So my question is are there any teams using Java that would be willing to share their code from past robot arms that had positional control. That would help me a lot I believe. |
|
#2
|
|||
|
|||
|
Re: PID Positional Control (Java)
Hi, PID is a great tool, I understand you are using jaguars, you may want to hook the encoders directly into the DSC, When in java use the encoder as a PID source and then start tuning your variables. We have had issues in the past with jaguars we no longer use them.
Above robot init Code:
Victor motor; Encoder encoder; PIDController pid; Code:
motor = new Victor(1); # or jaguar encoder = new Encoder(1,2); # A channel B channel enncoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kDistance); PID = new PIDController(0.01,0,0.01,encoder,motor); Code:
PID.enable(); PID.setSetpoint(10.0); -Matt |
|
#3
|
||||
|
||||
|
Re: PID Positional Control (Java)
Does the setpoint have to be a distance, or can we set the setpoint to a certain number of counts?
|
|
#4
|
||||
|
||||
|
Re: PID Positional Control (Java)
Quote:
Basically, distance per count allows you to put units into your PID instead of relying just on counts. You could translate counts into inches, feet, etc. Edit: Please note this is using WPILib Java. If you're not using WPILib, the lines of code mentioned above won't work out of the box. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|