Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Using Encoders to Correct Drive (http://www.chiefdelphi.com/forums/showthread.php?t=100978)

Becca334 23-01-2012 17:43

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).

eddie12390 23-01-2012 20:25

Re: Using Encoders to Correct Drive
 
There is a PIDController class/object.

import edu.wpi.first.wpilibj.PIDController;

Becca334 23-01-2012 22:17

Re: Using Encoders to Correct Drive
 
We know, but how would we implement it with tank drive?

Ether 23-01-2012 23:04

Re: Using Encoders to Correct Drive
 
Quote:

Originally Posted by Becca334 (Post 1112318)
We know, but how would we implement it with tank drive?

Have you considered using a gyro instead?


WizenedEE 24-01-2012 01:47

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.

Unoquadium 24-01-2012 11:02

Re: Using Encoders to Correct Drive
 
Quote:

Originally Posted by WizenedEE (Post 1112477)
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.

We would have been fine with doing this for only autonomous but the robot really doesn't go straight for more than a few feet, which would annoy the driver. We tried adjusting the ratios of motor speeds and went pretty straight for 10 feet, but slower.

In any case, how would we achieve this in autonomous? Give examples in Java preferably.

BurtGummer 25-01-2012 22:55

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.


All times are GMT -5. The time now is 22:21.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi