Go to Post Good engineering often comes down to knowing the difference between "better" and "good enough." - dlavery [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
  #16   Spotlight this post!  
Unread 12-28-2016, 02:30 PM
ollien ollien is offline
Registered User
FRC #5202
 
Join Date: Feb 2015
Location: United States
Posts: 267
ollien has a spectacular aura aboutollien has a spectacular aura aboutollien has a spectacular aura about
Re: Drivetrain PID tuning

Quote:
Originally Posted by ahartnet View Post
Code:
Robot.drivetrain.arcadeDrive(DriveForwardSpeed, (Robot.drivetrain.getGyroAngle().getAngle()));
You might want/need to multiply the gyro angle by a Kp or -Kp. We actually ended up with the following:

Code:
Robot.drivetrain.arcadeDrive(-DriveForwardSpeed, (-(Robot.drivetrain.getGyroAngle().getAngle()) * Kp+.1));
How are you allowing the driver to adjust the robot's angle?
Reply With Quote
  #17   Spotlight this post!  
Unread 12-28-2016, 02:44 PM
D.Allred's Avatar
D.Allred D.Allred is offline
Registered User
FRC #4451 (Rat Rod Robotics)
Team Role: Mentor
 
Join Date: Jun 2009
Rookie Year: 2009
Location: Greenville, SC
Posts: 197
D.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond reputeD.Allred has a reputation beyond repute
Re: Drivetrain PID tuning

Quote:
Originally Posted by ollien View Post
How do you accomplish this? Do you just set your setpoint proportional to the position of the stick?
We did not use it to execute a turn or follow a path while driving. It was only used to make a stationary turn or maintain a heading for a "drive straight" mode similar to the example in your original post.

For tele-op drive straight, a button on the xBox controller sets the current heading as the desired heading value then replaces the driver's rotation joystick value with the output of the heading proportional controller. Essentially the driver is only controlling thrust at that point and the loop maintains heading.

For our use, a proportional only loop worked but you could set up PID and experiment with the tuning.

David
Reply With Quote
  #18   Spotlight this post!  
Unread 12-28-2016, 03:43 PM
sspoldi's Avatar
sspoldi sspoldi is offline
Steven Spoldi
AKA: Steve Spoldi
FRC #0230 (Gaelhawks)
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2008
Location: Shelton, CT
Posts: 15
sspoldi is a splendid one to beholdsspoldi is a splendid one to beholdsspoldi is a splendid one to beholdsspoldi is a splendid one to beholdsspoldi is a splendid one to beholdsspoldi is a splendid one to behold
Re: Drivetrain PID tuning

In 2015 we used Mecanum wheels and one thing we really noticed was that the robot would rotate and drive forward well, but generated a lot more random slipping when moving sideways. We ended up using encoders for forward and lateral positioning and the gyro for heading. We could have used the encoders (one on each wheel) to determine heading, but the slip was giving us problems.

It was worse when the wheels got worn out. we were using the 6" Vexpro wheels, very cost effective but had a very noticeable life span for the rollers. Replacement wheels altered our autonomous timing required for the 3 tote auto.

Cheers,
Steve.
Reply With Quote
  #19   Spotlight this post!  
Unread 12-28-2016, 04:27 PM
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,062
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: Drivetrain PID tuning

Quote:
Originally Posted by sspoldi View Post
In 2015 we used Mecanum wheels and one thing we really noticed was that the robot would rotate and drive forward well, but generated a lot more random slipping when moving sideways. We ended up using encoders for forward and lateral positioning and the gyro for heading. We could have used the encoders (one on each wheel) to determine heading, but the slip was giving us problems.

It was worse when the wheels got worn out. we were using the 6" Vexpro wheels, very cost effective but had a very noticeable life span for the rollers. Replacement wheels altered our autonomous timing required for the 3 tote auto.

Cheers,
Steve.
This is very common for mecanum drives. The rollers don't need to spin for forward movement or turns in place (depending on your drivebase geometry), but do need to spin for sideways translation. The less your rollers spin freely, the more your strafing performance suffers.
Reply With Quote
  #20   Spotlight this post!  
Unread 12-28-2016, 04:31 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: Drivetrain PID tuning

Quote:
Originally Posted by Jared Russell View Post
You can definitely do motion profiling with a gyro.
Of course I'm going to defer to you on this, but how reliable is displacement with a gyro? I'm skeptical.
__________________
Sam Fuchs
236 TechnoTicks, Old Lyme, CT

2015 - Programming, Electrical
2016 - Lead Programmer, Co-Driver
2017 - Lead Programmer, Co-Driver
Reply With Quote
  #21   Spotlight this post!  
Unread 12-28-2016, 04:46 PM
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,062
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: Drivetrain PID tuning

Quote:
Originally Posted by SamcFuchs View Post
Of course I'm going to defer to you on this, but how reliable is displacement with a gyro? I'm skeptical.
Do you mean angular displacement? (Gyros measure angular rate, which then must be integrated to obtain angular displacement). With commonly available FRC gyros based on an Invensense MPU-9250 (NavX, CTRE Pigeon) or Analog Devices ADXRS-450/451 (FIRST Choice gyro, WCP Spartan board) you can measure angular displacement *very* accurately...you will only drift a handful of degrees over an entire match under most conditions (e.g. level field). You can generate a turn-in-place motion profile just as you would using encoders.

A gyro can't help you measure translational motion, of course. If you use a multi-DOF IMU with gyros AND accelerometers, you can measure linear acceleration...but trying to obtain precise translational displacement from these is not going to work well (maybe this is what you were referring to). But you can combine a gyro with encoders to give you the "best of both worlds" and follow a profiled path while correcting for yaw errors. As long as the profile contains yaw information, you can use a PID controller (often a P controller is enough) to add a bit of velocity to one side and subtract it from the other to keep you on track.

For more details, see: https://github.com/Team254/FRC-2016-...rive.java#L385 (our "drive straight" mode engaged by the driver by holding down a button)
and:
https://github.com/Team254/FRC-2016-...rive.java#L396 (our path following mode used for autonomous mode)
Reply With Quote
  #22   Spotlight this post!  
Unread 12-28-2016, 05:53 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: Drivetrain PID tuning

Quote:
Originally Posted by Jared Russell View Post
Do you mean angular displacement? (Gyros measure angular rate, which then must be integrated to obtain angular displacement). With commonly available FRC gyros based on an Invensense MPU-9250 (NavX, CTRE Pigeon) or Analog Devices ADXRS-450/451 (FIRST Choice gyro, WCP Spartan board) you can measure angular displacement *very* accurately...you will only drift a handful of degrees over an entire match under most conditions (e.g. level field). You can generate a turn-in-place motion profile just as you would using encoders.

A gyro can't help you measure translational motion, of course. If you use a multi-DOF IMU with gyros AND accelerometers, you can measure linear acceleration...but trying to obtain precise translational displacement from these is not going to work well (maybe this is what you were referring to). But you can combine a gyro with encoders to give you the "best of both worlds" and follow a profiled path while correcting for yaw errors. As long as the profile contains yaw information, you can use a PID controller (often a P controller is enough) to add a bit of velocity to one side and subtract it from the other to keep you on track.

For more details, see: https://github.com/Team254/FRC-2016-...rive.java#L385 (our "drive straight" mode engaged by the driver by holding down a button)
and:
https://github.com/Team254/FRC-2016-...rive.java#L396 (our path following mode used for autonomous mode)
No, I mean linear displacement, which you would need for motion profiling with a gyro, no?
__________________
Sam Fuchs
236 TechnoTicks, Old Lyme, CT

2015 - Programming, Electrical
2016 - Lead Programmer, Co-Driver
2017 - Lead Programmer, Co-Driver
Reply With Quote
  #23   Spotlight this post!  
Unread 12-28-2016, 06:36 PM
ollien ollien is offline
Registered User
FRC #5202
 
Join Date: Feb 2015
Location: United States
Posts: 267
ollien has a spectacular aura aboutollien has a spectacular aura aboutollien has a spectacular aura about
Re: Drivetrain PID tuning

Quote:
Originally Posted by SamcFuchs View Post
No, I mean linear displacement, which you would need for motion profiling with a gyro, no?
Gyros don't track linear displacement. As Jared said, they track the rate at which the angular displacement is changing.
Reply With Quote
  #24   Spotlight this post!  
Unread 12-29-2016, 01:32 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: Drivetrain PID tuning

Quote:
Originally Posted by Jared Russell View Post
Do you mean angular displacement? (Gyros measure angular rate, which then must be integrated to obtain angular displacement). With commonly available FRC gyros based on an Invensense MPU-9250 (NavX, CTRE Pigeon) or Analog Devices ADXRS-450/451 (FIRST Choice gyro, WCP Spartan board) you can measure angular displacement *very* accurately...you will only drift a handful of degrees over an entire match under most conditions (e.g. level field). You can generate a turn-in-place motion profile just as you would using encoders.

A gyro can't help you measure translational motion, of course. If you use a multi-DOF IMU with gyros AND accelerometers, you can measure linear acceleration...but trying to obtain precise translational displacement from these is not going to work well (maybe this is what you were referring to). But you can combine a gyro with encoders to give you the "best of both worlds" and follow a profiled path while correcting for yaw errors. As long as the profile contains yaw information, you can use a PID controller (often a P controller is enough) to add a bit of velocity to one side and subtract it from the other to keep you on track.
I think there was a misunderstanding here. I was talking about using a gyro/accelerometer (the navX in particular) to measure translational displacement, which we both agree is too inaccurate for motion profiling. However, I do have one concern with the alternative you suggest, using the PID loop together with your profile follower. Isn't there a concern that the PID loop could correct in such a way that you end up over/undershooting your goal for the profile?

Our system is to run an independent profile on each side of the robot, where each wheel follows the profile and corrects itself based on the error from the end point. This way, at the end of the loop, the setpoint for each side is the endpoint of the profile, so it ends up correcting itself to the right place.

I guess what I'm saying is that when you use the gyro to go straight (based on yaw) you're adding a new variable (yaw) instead of interpreting yaw as a difference of distances. How do you ensure that that doesn't become a problem?

Hope this makes some sense.
__________________
Sam Fuchs
236 TechnoTicks, Old Lyme, CT

2015 - Programming, Electrical
2016 - Lead Programmer, Co-Driver
2017 - Lead Programmer, Co-Driver
Reply With Quote
  #25   Spotlight this post!  
Unread 12-29-2016, 07:12 PM
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,062
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: Drivetrain PID tuning

Quote:
Originally Posted by SamcFuchs View Post
However, I do have one concern with the alternative you suggest, using the PID loop together with your profile follower. Isn't there a concern that the PID loop could correct in such a way that you end up over/undershooting your goal for the profile?

Our system is to run an independent profile on each side of the robot, where each wheel follows the profile and corrects itself based on the error from the end point. This way, at the end of the loop, the setpoint for each side is the endpoint of the profile, so it ends up correcting itself to the right place.

I guess what I'm saying is that when you use the gyro to go straight (based on yaw) you're adding a new variable (yaw) instead of interpreting yaw as a difference of distances. How do you ensure that that doesn't become a problem?

Hope this makes some sense.
Yep this makes sense and is a problem if you have large errors that the gyro needs to correct (which would also be a problem if you didn't have a gyro present). Usually, though, your yaw errors will be fairly small and stem from the fact that your left and right profiles are executed independently and can encounter independent disturbances.

For example: Say we want to go in a straight line for 10 feet. You would generate left and right profiles that in this case would be identical. You begin following each profile. At some point, maybe there's a bunch in the carpet on the left side, so your left controller begins lagging a bit because of the disturbance...but the right controller keeps tracking accurately. If this happens, your robot is now veering off to the left.

The gyro's role in all of this being to coordinate the execution of your independent left and right profiles. If you are using a gyro to track your actual yaw angle compared to your profile, you'll see that you are now veering left, so your left side should try *extra* hard to get back on track, and the right side should ease up just a bit. With enough gain on the gyro term, the left side should recover very quickly and get synchronized with the right side before you've drifted too far from your intended path.
Reply With Quote
  #26   Spotlight this post!  
Unread 12-29-2016, 08:59 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: Drivetrain PID tuning

Quote:
Originally Posted by Jared Russell View Post
Yep this makes sense and is a problem if you have large errors that the gyro needs to correct (which would also be a problem if you didn't have a gyro present). Usually, though, your yaw errors will be fairly small and stem from the fact that your left and right profiles are executed independently and can encounter independent disturbances.

For example: Say we want to go in a straight line for 10 feet. You would generate left and right profiles that in this case would be identical. You begin following each profile. At some point, maybe there's a bunch in the carpet on the left side, so your left controller begins lagging a bit because of the disturbance...but the right controller keeps tracking accurately. If this happens, your robot is now veering off to the left.

The gyro's role in all of this being to coordinate the execution of your independent left and right profiles. If you are using a gyro to track your actual yaw angle compared to your profile, you'll see that you are now veering left, so your left side should try *extra* hard to get back on track, and the right side should ease up just a bit. With enough gain on the gyro term, the left side should recover very quickly and get synchronized with the right side before you've drifted too far from your intended path.
Ok, I can see how that would be effective...how does it compare to using encoders for correction?
__________________
Sam Fuchs
236 TechnoTicks, Old Lyme, CT

2015 - Programming, Electrical
2016 - Lead Programmer, Co-Driver
2017 - Lead Programmer, Co-Driver
Reply With Quote
  #27   Spotlight this post!  
Unread 12-30-2016, 12:39 PM
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 799
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Drivetrain PID tuning

Quote:
Originally Posted by SamcFuchs View Post
Ok, I can see how that would be effective...how does it compare to using encoders for correction?
Jared probably has a slightly different way of looking at this, but I think there's a more fundamental change needed first to make sure you go straight. The encoder vs gyro problem becomes much easier to try. Instead of left, right profiles, I rewrite it as a distance, angle profile, and then use a distance PID loop and an angle PID loop.

angle = (right_distance - left_distance) / width
distance = (left_distance + right_distance) / 2

You can do a similar transform for your powers (pardon any sign errors) to get back to actual outputs you physically have.

left_voltage = distance_voltage - turn_voltage
right_voltage = distance_voltage + turn_voltage

This then lets you control what you care about.

In the presence of tire slip and tire wear, you won't always go straight with just encoders. A gyro has a different set of issues (noise), but isn't affected by those problems. So, we use the gyro for the angle of the robot instead of computing the angle as above.

Just re-phrasing your loops to be an angle, distance pair of loops has huge benefit. Unless your robot has all it's mass perfectly centered over the two drive wheels, your left, right PID loop won't be able to do good distance control and turn control without compromises. I tend to find that good distance control results in a small amount of turn chatter and oscillation. (You can work out the physics to show that the two sides are coupled in left, right, but not in angle, distance) A angle, distance loop doesn't make that assumption.

If you really want to do left, right with a gyro, you can reverse the equations above.
Reply With Quote
  #28   Spotlight this post!  
Unread 12-30-2016, 01:09 PM
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 245
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Drivetrain PID tuning

Quote:
Originally Posted by SamcFuchs View Post
Ok, I can see how that would be effective...how does it compare to using encoders for correction?
I think this question mostly stems from a misunderstanding.

The Motion Profiling you're describing, like most motion profiling, is based upon distance, velocity and acceleration. Something to note is that these all function in a single dimension. For devices like actuation arms or conveyors, this makes sense, as there is only one direction of motion. (there can still be issues here in tracking, but that is not related to a difference in distances)

If you want to start using this in a 2D sense (i.e. a drive base), these distances can be misread. For example, if a wheel (or track) on one side of your drive base slips (assuming 'tank' drive), it will mistakenly read a distance, even though it hadn't moved that far. To the code, your drive base is tracking properly, but in the real world it isn't. This is a common problem with drive bases. The most common way to fix this is to add an extra proportional gain based on the error between what you want your heading to be, and what your heading is reported to be by the gyroscope (per Austin's example). Let's say you have the following code:
Code:
float left_power = calc_power_left(time, profile_l, encoder_l);
float right_power = calc_power_right(time, profile_r, encoder_r);
The profile will have already generated the desired distance for each side of the drive base (the arc length along the curve of motion for each side), so in a perfect world, this would track just fine. However, we don't live in a perfect world, so we add something like the following:
Code:
float gyro_heading = ... your gyro code ...
float desired_heading = get_heading(time, profile);
float delta_angle = desired_heading - gyro_heading; // This is our error in alignment
float turn_power = 0.8 * (-1/80) * delta_angle;   // Change these coefficients as required

setLeftMotors(left_power + turn_power);
setRightMotors(right_power - turn_power);
In the above example, get_heading returns the heading of the path at the given time (i.e. the 'tangent' if you were to plot the curve). This accounts for errors in the heading by 'nudging' the robot in the right direction.

The main point I'm trying to clear up here is that it isn't entirely possible to use encoders for correction, as they rely on continuous, perfect connection to the field floor. Adding in a gyroscope will account for any errors in heading that the encoders, wheels or field introduce.

I hope this clears up any misconceptions you have.
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com

Last edited by Jaci : 12-30-2016 at 01:14 PM.
Reply With Quote
  #29   Spotlight this post!  
Unread 12-30-2016, 07:08 PM
thatprogrammer's Avatar
thatprogrammer thatprogrammer is online now
Registered User
AKA: Ahad Bawany
no team (None)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Florida
Posts: 603
thatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond reputethatprogrammer has a reputation beyond repute
Re: Drivetrain PID tuning

Quote:
Originally Posted by AustinSchuh View Post
Jared probably has a slightly different way of looking at this, but I think there's a more fundamental change needed first to make sure you go straight. The encoder vs gyro problem becomes much easier to try. Instead of left, right profiles, I rewrite it as a distance, angle profile, and then use a distance PID loop and an angle PID loop.

angle = (right_distance - left_distance) / width
distance = (left_distance + right_distance) / 2

You can do a similar transform for your powers (pardon any sign errors) to get back to actual outputs you physically have.

left_voltage = distance_voltage - turn_voltage
right_voltage = distance_voltage + turn_voltage

This then lets you control what you care about.

In the presence of tire slip and tire wear, you won't always go straight with just encoders. A gyro has a different set of issues (noise), but isn't affected by those problems. So, we use the gyro for the angle of the robot instead of computing the angle as above.

Just re-phrasing your loops to be an angle, distance pair of loops has huge benefit. Unless your robot has all it's mass perfectly centered over the two drive wheels, your left, right PID loop won't be able to do good distance control and turn control without compromises. I tend to find that good distance control results in a small amount of turn chatter and oscillation. (You can work out the physics to show that the two sides are coupled in left, right, but not in angle, distance) A angle, distance loop doesn't make that assumption.

If you really want to do left, right with a gyro, you can reverse the equations above.
This post is very useful, but I had a few questions based on it.

1. Assuming that you use your gyro to calculate your angular offset rather than "angle = (right_distance - left_distance) / width." How would you calculate the turn voltage part of the bottom equation?
Quote:
"left_voltage = distance_voltage - turn_voltage"
Would you just use a full PID loop to calculate a voltage (and tune it) and then just add the result of that to your distance PID loop?

2. Do you have any tips for tuning PID loops in cases with lots of friction like turning PID loops? Jared (very kindly!) sent me some tips on tuning PID loops before, but I'm curious to see if there are other viewpoints on this in situations with lots of friction.
__________________
Takin' a break.
Reply With Quote
  #30   Spotlight this post!  
Unread 12-31-2016, 02:55 AM
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 799
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Drivetrain PID tuning

Quote:
Originally Posted by thatprogrammer View Post
This post is very useful, but I had a few questions based on it.

1. Assuming that you use your gyro to calculate your angular offset rather than "angle = (right_distance - left_distance) / width." How would you calculate the turn voltage part of the bottom equation?
Would you just use a full PID loop to calculate a voltage (and tune it) and then just add the result of that to your distance PID loop?
Pick your favorite controller. P, PD, PID, LQR, Lead/Lag, MPC, YMMV I try to start with what boils down to a PD loop before I pull out I or any other terms. The input to your controller is the angle, and the output is the voltage.

Quote:
Originally Posted by thatprogrammer View Post
2. Do you have any tips for tuning PID loops in cases with lots of friction like turning PID loops? Jared (very kindly!) sent me some tips on tuning PID loops before, but I'm curious to see if there are other viewpoints on this in situations with lots of friction.
I've got a bit of a random pile of advice, but hopefully some of it is useful when the robot isn't working right. Sometimes you just need to try different things to figure out what's going wrong.

If you've got a bunch of friction, you end up needing to slow things down a bit. Friction is a pain to deal with. You also need to ask yourself really how accurate you need to be. If you can tolerate moderate steady state error, leave it as a PD loop. As the robot goes faster, it takes less energy to get it to steer, which works in your favor. If you really need good tracking, you are going to have to work at tuning I correctly.

Consider running in low gear if you have a transmission so friction is a smaller portion of your overall torque. The most annoying steering loop I tuned was 254's 2011 robot, geared for crazy speeds. We needed to run auto in high gear too, which meant we were close to saturation all the time.

The most annoying issue I've had tuning heading PID loops was where there was lag in the gyro angle reading. That phase lag meant I couldn't push the bandwidth of the loop up to anything useful. I had to fix that before I could get it to stabilize well. I debugged that by plotting the gyro and encoder headings.

Run your loops at 100 - 200 hz. You want to run your loops at 10x the frequency of the highest frequency you want to control. So, if you want to control at 10 hz, you need a 100 hz loop. The more reliable you can get your loop timing, the better. We go to great lengths to hit a 5 ms +- 5% loop timing, and it helps a lot.

The most important part here is to plot everything. Plot your error vs time, and watch it evolve. Plot the power due to P, I, D, FF. Plot the encoder based heading and the gyro based heading. It's possible but hard to tune these things by eye. Honestly, sometimes I think it's easier to rough tune them by listening to them and listening for the overshoot, and then reaching for the plots when I'm stuck. I also like to grab it and feel the loop, though you have to be very careful since robots can cause lots of damage fast.

We use more complicated controllers, which means I have less recent relevant robot experience than I'd like here. I should probably go grab a robot and tune a PID heading loop again just to have some more guidance.
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 10:38 PM.

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