Go to Post I don't actually have any hex shaft stock in my house (I live in an unusual household). - ollien [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Spotlight this post!  
Unread 28-03-2011, 17:50
alexhenning alexhenning is offline
WPILib Developer
FRC #0348
 
Join Date: Apr 2010
Rookie Year: 2003
Location: MA
Posts: 49
alexhenning will become famous soon enough
Re: Last minute autonomous help

Quote:
Originally Posted by PriyankP View Post
Sorry to bring up this relatively old topic but I was wondering how are you using encoders to go to a certain distance? Do you just have PID and Setpoint encoders to some number? Or are you using something else too?

Any other teams out there willing to share how they use their encoders in autonomous?
I have two encoders hooked up to jaguars running CAN one for the left side and the other for the right side. The autonomous does P (No need for ID) so that it slows down as it gets closer until it hits the wall going pretty slowly. This runs reliably as long as it's lined up and the left and right sides act the same. i.e. You jam both joysticks forward and it actually drives straight-ish.

Here's the relevant code.
Code:
	    leftDist = bot.dt.getLeftDist() - leftStart;
	    rightDist = bot.dt.getRightDist() - rightStart;
	    
	    double left = gain * ((distance - leftDist) / distance);
	    double right = gain * ((distance - rightDist) / distance);
	    
	    bot.dt.drive(left, right, bot.gyro);
distance is the distance you wish to travel in feet.
gain is the initial value that gets toned down as you drive (Currently using 0.7)

Hopefully the rest of the code is clear enough that it makes sense. If you have anymore questions feel free to ask. Also, you can PM me if you want to see our full autonomous code.
Reply With Quote
 


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 13:02.

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