Go to Post don't be grumpy. No one is allowed to be grumpy during build. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming
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
  #4   Spotlight this post!  
Unread 24-04-2016, 01:54
Poseidon5817's Avatar
Poseidon5817 Poseidon5817 is offline
"Cool" Squad
AKA: Mitchel Stokes
FRC #5817 (Uni-Rex)
Team Role: Mentor
 
Join Date: Aug 2013
Rookie Year: 2014
Location: Clovis, CA
Posts: 348
Poseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud of
Re: Using PID in autonomous to keep straight

Quote:
Originally Posted by Dpurry23 View Post
Sorry for not explaining, we are using a gyro as a source with the output being our drivetrain.
Ok thanks. At its simplest, you could do something like this:

Code:
double angle = robot.getAngle();
double angleError = AngleYouWantToBe - angle;
double output = constant * angleError;
myRobot.drive(output, 0);
Wait(2.0);
myRobot.drive(0, 0);
This is a simple P loop. It takes the angle error, multiplies it by a constant you specify, and applies that as the output for your drive. As you get closer, your output gets smaller because the error gets smaller, and it coasts to a stop. Note that due to the fact that a drive train needs a certain percentage to actually drive (e.g. 10%), it will never actually make it the whole way to where you want it to go with just a P loop, although you could make it where it gets pretty close, depending on how you tune your constant.

If you want to get more complex than that, you could use a PI loop, but that's another story.
__________________
My FRC History:

2014 - Team 1671: Central Valley Regional Finalist and Chairman's Award Winner, Sacramento Regional Finalist, Archimedes Quarterfinalist
2015 - Team 1671: Central Valley Regional Semifinalist, Sacramento Regional Semifinalist and Chairman's Award Winner, Newton Winner, Einstein Winner
2016 - Team 5817: Central Valley Regional Finalist and Rookie All-Star, Orange County Regional Quarterfinalist and Rookie All-Star, Newton Division
2017 - Team 5817: Return of the bench grinder



Last edited by Poseidon5817 : 24-04-2016 at 01:56.
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 06:43.

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