Go to Post Whether or not your team has the technical mentors, as long as your kids are still inspired by the adult technical mentors of other teams, and get the picture that we're trying to portray in this program, the best that you can do is the best you can do. Do it, and be proud of your results. - Beth Sweet [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 31-08-2016, 03:15
Bo8_87 Bo8_87 is offline
Registered User
no team
 
Join Date: Aug 2016
Rookie Year: 2014
Location: California
Posts: 17
Bo8_87 is an unknown quantity at this point
Auto-Aligning in Teleop

Hello CD,
For my team's off-season competition, our team is implementing an auto-aligning feature for our robot. We have been able to align in autonomously using PID successfully, but in teleop, the aligning isn't consistent and sometimes the robot randomly oscillates in large circles.
We think that because the teleop loop is fetching more data (i.e. joysticks) than in autonomous, the feedback from the gyro that we are using to align is not fast enough to keep up with the robot.
Does anyone know of a fix to this issue? Perhaps speed up the teleop control loop rate?
Reply With Quote
  #2   Spotlight this post!  
Unread 31-08-2016, 06:55
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Auto-Aligning in Teleop

Teleop executes every time a control packet from the driver station is received. Between network latency and other things, this tends to cause inconsistency in the timing between packets (jitter). This jitter causes issues with control loops. Instead, place your PID control loop in Periodic Tasks (if LabView) or an equivalent separate running periodic process if using Java/C++.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #3   Spotlight this post!  
Unread 31-08-2016, 07:01
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,555
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Auto-Aligning in Teleop

Have you tried increasing your D? That usually dampens oscillations.

Without more detail on your setup, it's difficult to be more specific.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #4   Spotlight this post!  
Unread 31-08-2016, 08:34
M3rcuriel's Avatar
M3rcuriel M3rcuriel is offline
Mentor
AKA: Lee Mracek
FRC #0299 (Valkyrie Robotics)
Team Role: Mentor
 
Join Date: Jun 2014
Rookie Year: 2013
Location: Cupertino
Posts: 19
M3rcuriel is on a distinguished road
Re: Auto-Aligning in Teleop

My guess is that this is a combination of your PID needing more tuning, the terrible timing from the Driver Station, and PID not being the best option to overcome the friction with the carpet without over-adjusting.
Reply With Quote
  #5   Spotlight this post!  
Unread 31-08-2016, 09:08
martin417's Avatar
martin417 martin417 is offline
Opinionated old goat
AKA: Martin Wilson
no team
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Buford, GA
Posts: 719
martin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond reputemartin417 has a reputation beyond repute
Re: Auto-Aligning in Teleop

I do not understand why FRC programmers always want a full PID for every control application. In almost every case, a simple proportional control is more than sufficient. and often even that is overkill. For speed control, a digital or "bang-bang" control works quite well, and for aiming, a proportional algorithm is almost always good enough.

What we have done for aiming is to set the motor speed proportional to error, with the gain set so that when we get very close, the motor output is still being driven, but at a value so low that the motor doesn't actually move any more. The only thing you have to tune is proportional gain. It is quite easy to tune that with trial and error.
__________________
Former Mentor Team 1771
Former mentor Team 4509
Reply With Quote
  #6   Spotlight this post!  
Unread 31-08-2016, 12:02
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,070
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Auto-Aligning in Teleop

Quote:
Originally Posted by martin417 View Post
In almost every case, a simple proportional control is more than sufficient.
"Almost every case" is really pushing it, but the sentiment that not every application requires I and D is definitely correct.

For mechanisms that are well-approximated as a linear first-order system near the expected operating point (i.e. negligible inertia for position control; near constant inertia for velocity control), sure, P might be enough. Flywheels, lightweight turrets and conveyors, and counter-balanced elevators can fall into this category if you don't care about being lightning fast and/or can tolerate some overshoot or steady-state error.

However, drivetrains, arms, and heavier servo mechanisms definitely benefit from damping and/or integral action much of the time. The best policy is to always start with P-only, then add other terms from there as necessary.

To the OP's question: if the same PID gains work well for you in autonomous mode, then you must ask yourself what is different in teleop? It could be timing, other things your robot is doing when in teleop (are other mechanisms drawing from the battery or is your code taking much longer to execute?), or different initial conditions (e.g. are you trying to auto-align when you are much further off target in teleop and/or still moving, in which case you may need to re-tune your controller to these conditions)?
Reply With Quote
  #7   Spotlight this post!  
Unread 31-08-2016, 12:14
aeastet aeastet is offline
Programming Mentor
AKA: Tim Easterling
FRC #6043 (Allegan Tigers Robotics)
Team Role: Coach
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Holland, MI
Posts: 116
aeastet is an unknown quantity at this point
Re: Auto-Aligning in Teleop

First I would say that your teleop is running slower than auto. There are many ways to fix this but we need more information:

What programming language?
Can you provide your code?
Do you do anything different in Auto than in teleop?

If you get these answers I would guess that someone can help.

My guess is not the PID tuning. If it works in Auto then it should be fine as long as you are running the same loop rate. If one loop is running faster than the other you will get a different result. Everything in PID is based on time.

Tim
Reply With Quote
  #8   Spotlight this post!  
Unread 31-08-2016, 12:23
wesleyac's Avatar
wesleyac wesleyac is offline
Registered User
AKA: Wesley Aptekar-Cassels
FRC #1678
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Davis, CA
Posts: 45
wesleyac is a glorious beacon of lightwesleyac is a glorious beacon of lightwesleyac is a glorious beacon of lightwesleyac is a glorious beacon of lightwesleyac is a glorious beacon of light
Re: Auto-Aligning in Teleop

As adciv mentioned, placing things in teleop periodic is a Bad Idea. People tend to say that TeleopPeriodic and AutonomousPeriodic run at 20Hz, but they actually run whenever they get a packet from the driver station, which is *usually* approximately 20Hz. The result of this is that they have significant delays in when they're executed.

Ideally, the only things that you should do in your periodic functions is to check for new joystick values. If you're using C++ or Java, you should have a separate thread for your PID controller, so that you can easily control what frequency it runs at.

Once you have a PID controller running in a separate thread, you should see much more consistent results between auto and teleop.

If you let me know what language you're using, I can point you towards more resources for implementing a separate thread for your controller.

EDIT: This post is assuming that everything but the code that's running is the same. Jared Russell gave some good advice on figuring out if that's the case above.
__________________
Quote:
Originally Posted by The programming team
Define "works."

Last edited by wesleyac : 31-08-2016 at 12:37.
Reply With Quote
  #9   Spotlight this post!  
Unread 31-08-2016, 12:40
WSiggs WSiggs is offline
Pb Fabricator
FRC #4908 (Dragons)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2014
Location: Duxbury Massachusetts
Posts: 26
WSiggs is an unknown quantity at this point
Re: Auto-Aligning in Teleop

Quote:
Originally Posted by M3rcuriel View Post
and PID not being the best option to overcome the friction with the carpet without over-adjusting.
What would be the best option for this then?
Reply With Quote
  #10   Spotlight this post!  
Unread 31-08-2016, 18:34
Bo8_87 Bo8_87 is offline
Registered User
no team
 
Join Date: Aug 2016
Rookie Year: 2014
Location: California
Posts: 17
Bo8_87 is an unknown quantity at this point
Re: Auto-Aligning in Teleop

The code for the aligning is the exact same.
We are currently using Java
Could you elaborate more on the multi-threading for the PID Loops?
Reply With Quote
  #11   Spotlight this post!  
Unread 31-08-2016, 22:11
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Auto-Aligning in Teleop

We don't use Java so I can't give complete details, but basically start a new thread running a custom class that you've programmed. That thread controls your drive train and nothing else. You pass it the commands from where ever and it executes them. Internal to that thread, it runs the PID or executes joystick commands directly or whatever else you're doing.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #12   Spotlight this post!  
Unread 31-08-2016, 23:50
Bo8_87 Bo8_87 is offline
Registered User
no team
 
Join Date: Aug 2016
Rookie Year: 2014
Location: California
Posts: 17
Bo8_87 is an unknown quantity at this point
Re: Auto-Aligning in Teleop

Would using WPI's PIDController instead of a custom Controller work? According to online sources WPI's PIDController creates a new thread to run the control loop.
Reply With Quote
  #13   Spotlight this post!  
Unread 01-09-2016, 06:08
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Auto-Aligning in Teleop

I wish I could say yes, but reading over the documentation it doesn't allow output to the drive train. It only allows control of single motor controllers. For controlling the drive train you need to be able to control all your drive train motors at once.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #14   Spotlight this post!  
Unread 01-09-2016, 07:39
gerthworm's Avatar
gerthworm gerthworm is offline
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 56
gerthworm has a spectacular aura aboutgerthworm has a spectacular aura about
Re: Auto-Aligning in Teleop

Quote:
Originally Posted by Bo8_87 View Post
Hello CD,
the feedback from the gyro that we are using to align is not fast enough to keep up with the robot.
Here is a question I haven't seen asked yet: What is the maximum number of degrees/second the gyro you have can measure? Is it faster than the robot is actually turning?

Another quick experiment to run - in "open loop" mode, spin the robot a few times in circles really fast. Stop pointed the same direction you started. Is he heading reading within a few degrees of a multiple of 360? If not, there is something in your input (before the PID) which is not accurately measuring the pose of your robot. This can definitely cause strange behaviors when fed into a control system.
Reply With Quote
  #15   Spotlight this post!  
Unread 01-09-2016, 21:55
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,556
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Auto-Aligning in Teleop

Quote:
Originally Posted by adciv View Post
I wish I could say yes, but reading over the documentation it doesn't allow output to the drive train. It only allows control of single motor controllers. For controlling the drive train you need to be able to control all your drive train motors at once.
It will output to anything which implements the PIDOutput interface. It's correct to say that single motor controllers do. But it's not correct to say it doesn't allow output to a drive train, just that you need to make your drivetrain implement the PIDOutput interface.
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 20:24.

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