Go to Post If your goal is to win matches... Pick the most capable candidate. If your goal is to change lives... Sometimes you pick those that need the most change. - IKE [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-23-2016, 09:40 PM
Dpurry23's Avatar
Dpurry23 Dpurry23 is offline
Programmer/Control System/Scout
AKA: Darian Purry
FRC #0207 (Metalcrafters)
Team Role: Programmer
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Hawthorne
Posts: 13
Dpurry23 is an unknown quantity at this point
Exclamation Using PID in autonomous to keep straight

Need help figuring out how to use PID to go over an obstacle turn to a certain point. (ex. The position that the robot calibrates at)

This is the code I have so far.
Code:
myRobot.SetSafetyEnabled(false);

myRobot.Drive(-.5,0.0);
Wait(1.5);
myRobot.Drive(0.0, 0.0);
turnController->SetSetpoint(0.0f);
Wait(2.0); // Have to wait till the bot turns
Language is C++
Reply With Quote
  #2   Spotlight this post!  
Unread 04-24-2016, 01:18 AM
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: 341
Poseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to behold
Re: Using PID in autonomous to keep straight

Quote:
Originally Posted by Dpurry23 View Post
Need help figuring out how to use PID to go over an obstacle turn to a certain point. (ex. The position that the robot calibrates at)

This is the code I have so far.
Code:
myRobot.SetSafetyEnabled(false);

myRobot.Drive(-.5,0.0);
Wait(1.5);
myRobot.Drive(0.0, 0.0);
turnController->SetSetpoint(0.0f);
Wait(2.0); // Have to wait till the bot turns
Language is C++
You can't use a PID loop without a feedback source, e.g. a gyro or encoders. Do you have a gyro or encoders on your drive?
__________________
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


Reply With Quote
  #3   Spotlight this post!  
Unread 04-24-2016, 01:44 AM
Dpurry23's Avatar
Dpurry23 Dpurry23 is offline
Programmer/Control System/Scout
AKA: Darian Purry
FRC #0207 (Metalcrafters)
Team Role: Programmer
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Hawthorne
Posts: 13
Dpurry23 is an unknown quantity at this point
Re: Using PID in autonomous to keep straight

Sorry for not explaining, we are using a gyro as a source with the output being our drivetrain.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-24-2016, 01:54 AM
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: 341
Poseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to beholdPoseidon5817 is a splendid one to behold
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



Last edited by Poseidon5817 : 04-24-2016 at 01:56 AM.
Reply With Quote
  #5   Spotlight this post!  
Unread 04-24-2016, 06:53 AM
rich2202 rich2202 is offline
Registered User
FRC #2202 (BEAST Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 1,117
rich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond repute
Re: Using PID in autonomous to keep straight

Here is the problem:

PID presumes continuous measurements. If you are crossing the low bar with no jerky movements, then PID works ok for driving straight (our robot drives like a slightly drunken sailor).

Over the other Defenses, the jerkiness throws off PID. You will eventually head in the right direction (gyro), but you may be off track to the left/right.
Reply With Quote
  #6   Spotlight this post!  
Unread 04-24-2016, 04:24 PM
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 298
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Using PID in autonomous to keep straight

Quote:
Originally Posted by rich2202 View Post
Here is the problem:

PID presumes continuous measurements. If you are crossing the low bar with no jerky movements, then PID works ok for driving straight (our robot drives like a slightly drunken sailor).

Over the other Defenses, the jerkiness throws off PID. You will eventually head in the right direction (gyro), but you may be off track to the left/right.
You'd only be off by a few inches. That shouldn't be a problem.

We used proportional control to drive straight in auto, and we didn't have any problems.
Reply With Quote
  #7   Spotlight this post!  
Unread 04-24-2016, 06:06 PM
SamcFuchs's Avatar
SamcFuchs SamcFuchs is offline
Programmer
AKA: Sam Fuchs
FRC #0236 (TechnoTicks)
Team Role: Programmer
 
Join Date: Aug 2015
Rookie Year: 2014
Location: Old Lyme, Connecticut
Posts: 50
SamcFuchs will become famous soon enoughSamcFuchs will become famous soon enough
Re: Using PID in autonomous to keep straight

Quote:
Originally Posted by euhlmann View Post
You'd only be off by a few inches. That shouldn't be a problem.

We used proportional control to drive straight in auto, and we didn't have any problems.
Yeah but the issue is its unpredictability. For example, the ramparts tend to send robots in any direction, and there's no good way to predict that. Also, a couple inches can be a big deal, particularly when trying to shoot without a vision system. Earlier in the season, we calculated that the margin of error when shooting the high goal in auto (if you go straight through the low bar and spin) to be ~1.5 degrees and 2-3 inches IIRC.
__________________
Sam Fuchs
236 TechnoTicks, Old Lyme, CT

2015 - Programming, Electrical
2016 - Lead Programmer, Co-Driver
2017 - Lead Programmer, Co-Driver
Reply With Quote
  #8   Spotlight this post!  
Unread 04-24-2016, 07:02 PM
xjschwen xjschwen is offline
Registered User
FRC #3668
 
Join Date: Jan 2016
Location: Michigan
Posts: 18
xjschwen is an unknown quantity at this point
Re: Using PID in autonomous to keep straight

We did not use a PID just the Proportional part of it... and it is good enough to cross the ramparts in auto, then spin 180 and cross them again during lab work. We never had any issues staying straight on any of the defenses.

There are some items that we will be cleaning up in the off season but it did work.

As a matter of fact auto was better then telle-op.

https://github.com/WhitmoreLakeTroBo.../CMDdrive.java

https://github.com/WhitmoreLakeTroBo...tCaluator.java
Reply With Quote
  #9   Spotlight this post!  
Unread 04-24-2016, 09:26 PM
Dpurry23's Avatar
Dpurry23 Dpurry23 is offline
Programmer/Control System/Scout
AKA: Darian Purry
FRC #0207 (Metalcrafters)
Team Role: Programmer
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Hawthorne
Posts: 13
Dpurry23 is an unknown quantity at this point
Re: Using PID in autonomous to keep straight

Here is a link to our entire code https://github.com/Dpurry23/FRC-Team.../src/Robot.cpp
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 05:10 AM.

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