Go to Post You will forever be confronted with choosing between right and wrong, or choosing what you think you can get away with. Which way you go defines what kind of person you are. Choose wisely. - Gary Dillard [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-01-2012, 17:43
Becca334's Avatar
Becca334 Becca334 is offline
Registered User
AKA: Rebecca
FRC #0334 (TechKnights)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: New York
Posts: 57
Becca334 is a jewel in the roughBecca334 is a jewel in the roughBecca334 is a jewel in the roughBecca334 is a jewel in the rough
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).
Reply With Quote
  #2   Spotlight this post!  
Unread 23-01-2012, 20:25
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Using Encoders to Correct Drive

There is a PIDController class/object.

import edu.wpi.first.wpilibj.PIDController;
Reply With Quote
  #3   Spotlight this post!  
Unread 23-01-2012, 22:17
Becca334's Avatar
Becca334 Becca334 is offline
Registered User
AKA: Rebecca
FRC #0334 (TechKnights)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: New York
Posts: 57
Becca334 is a jewel in the roughBecca334 is a jewel in the roughBecca334 is a jewel in the roughBecca334 is a jewel in the rough
Re: Using Encoders to Correct Drive

We know, but how would we implement it with tank drive?
Reply With Quote
  #4   Spotlight this post!  
Unread 23-01-2012, 23:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Using Encoders to Correct Drive

Quote:
Originally Posted by Becca334 View Post
We know, but how would we implement it with tank drive?
Have you considered using a gyro instead?

Reply With Quote
  #5   Spotlight this post!  
Unread 24-01-2012, 01:47
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
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.
Reply With Quote
  #6   Spotlight this post!  
Unread 24-01-2012, 11:02
Unoquadium Unoquadium is offline
The Parlor Generals
AKA: Ilya Rubnich
FRC #0334 (Tech Knights)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Brooklyn, NY
Posts: 8
Unoquadium is an unknown quantity at this point
Re: Using Encoders to Correct Drive

Quote:
Originally Posted by WizenedEE View Post
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.
Reply With Quote
  #7   Spotlight this post!  
Unread 25-01-2012, 22:55
BurtGummer BurtGummer is offline
Electrical/Mechanical/Programming
FRC #3020
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Southern CA
Posts: 89
BurtGummer will become famous soon enoughBurtGummer will become famous soon enough
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.
__________________
I'm a mentor looking for a home in Southern California! I know Java, C++, electrical and mechanical.

Need Java or C++ help? Send me a PM!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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