|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Using Encoders to Correct Drive
I need help with using encoders to keep a robot going straight, basically adjusting the speeds of Victors based on encoder rates to make sure one motor doesn't slack behind another.
I know that this is possible with PID loops but I have not found a single Java implementation of PID for this task (and I really don't understand conceptually how PID works either) We're using the RobotDrive class with tankDrive for driving with 4 motors and 2 encoders (one per 2 motors on each side). |
|
#2
|
||||
|
||||
|
Re: Using Encoders to Correct Drive
There is a PIDController class/object.
import edu.wpi.first.wpilibj.PIDController; |
|
#3
|
||||
|
||||
|
Re: Using Encoders to Correct Drive
We know, but how would we implement it with tank drive?
|
|
#4
|
||||
|
||||
|
Re: Using Encoders to Correct Drive
Have you considered using a gyro instead?
|
|
#5
|
||||
|
||||
|
Re: Using Encoders to Correct Drive
The general method that I'm thinking of would be to use the difference in the encoder distances as the error for a PID loop. I would use the arcade drive function, since the PID would "output" how fast you should turn.
Also, when you say "tank drive" it sounds a little like you're saying you want to use it during teleop. Is that correct? I think it may get annoying for drivers if they want to turn just a little while going forward, and you'll have other logistical issues to think about. |
|
#6
|
|||
|
|||
|
Re: Using Encoders to Correct Drive
Quote:
In any case, how would we achieve this in autonomous? Give examples in Java preferably. |
|
#7
|
|||
|
|||
|
Re: Using Encoders to Correct Drive
As stated earlier, you'd be better off using a gyro to accomplish the task of straight driving. When the robot is initialized, the gyro will zero itself. If there is any change in heading, you can use that to create a loop that will steer the robot to correct itself. You may encounter a slight drifting effect, but it shouldn't be noticeable in a single match.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|