Go to Post This is ChiefDelphi. There are threads on everything! - LauraN [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 29-10-2016, 14:47
Wasabi Fan Wasabi Fan is offline
Registered User
FRC #0488
 
Join Date: Dec 2015
Location: Washington
Posts: 15
Wasabi Fan is an unknown quantity at this point
How is velocity control supposed to work on the Talon SRX?

I'm trying to use the closed-loop control on the Talon SRXs to run the motor at a specified velocity. I have successfully configured the encoders and they read in the units I want them to. However, I'm having trouble with the concept of velocity control as it currently stands.

In many cases, a PID(F) controller is used for position control, where the property of the system that the control variable is acting on is roughly the derivative of the error property (velocity -- which is roughly proportional to motor power -- is the derivative of position). In this case, however, the output of the controller will be roughly proportional to the input. That means that, when the error is zero (the motor is spinning at the desired velocity), output will fall to zero and by extension the motor will no longer be spinning at its target speed.

Intuitively, I expect this would result in the motor falling into a state of equilibrium where the error value corresponds to an output speed that sustains that error value. This behavior doesn't actually run the motor at the desired velocity, it runs it at an unpredictable velocity. The F parameter could be used to get closer to the target, but the P and D parameters still wouldn't be doing anything.

What is the proper way to handle this with the Talon's built-in velocity control? I would normally implement velocity PID by adding the output of the PID to a velocity accumulator, but in this case I can't do that because the closed-loop control logic is being run on the motor controller itself.
Reply With Quote
  #2   Spotlight this post!  
Unread 29-10-2016, 15:19
Bryce2471's Avatar
Bryce2471 Bryce2471 is offline
Alumnus
AKA: Bryce Croucher
FRC #2471 (Team Mean Machine)
Team Role: Mechanical
 
Join Date: Feb 2013
Rookie Year: 2007
Location: Camas, WA
Posts: 423
Bryce2471 has much to be proud ofBryce2471 has much to be proud ofBryce2471 has much to be proud ofBryce2471 has much to be proud ofBryce2471 has much to be proud ofBryce2471 has much to be proud ofBryce2471 has much to be proud ofBryce2471 has much to be proud ofBryce2471 has much to be proud of
Re: How is velocity control supposed to work on the Talon SRX?

Quote:
Originally Posted by Wasabi Fan View Post
I'm trying to use the closed-loop control on the Talon SRXs to run the motor at a specified velocity. I have successfully configured the encoders and they read in the units I want them to. However, I'm having trouble with the concept of velocity control as it currently stands.

In many cases, a PID(F) controller is used for position control, where the property of the system that the control variable is acting on is roughly the derivative of the error property (velocity -- which is roughly proportional to motor power -- is the derivative of position). In this case, however, the output of the controller will be roughly proportional to the input. That means that, when the error is zero (the motor is spinning at the desired velocity), output will fall to zero and by extension the motor will no longer be spinning at its target speed.

Intuitively, I expect this would result in the motor falling into a state of equilibrium where the error value corresponds to an output speed that sustains that error value. This behavior doesn't actually run the motor at the desired velocity, it runs it at an unpredictable velocity. The F parameter could be used to get closer to the target, but the P and D parameters still wouldn't be doing anything.

What is the proper way to handle this with the Talon's built-in velocity control? I would normally implement velocity PID by adding the output of the PID to a velocity accumulator, but in this case I can't do that because the closed-loop control logic is being run on the motor controller itself.
Very astute observations. I believe there is much debate about this topic. I agree with you that the output of the PID should be accumulated before being set as motor power. However, I think many in the chief Delphi community think that the P, I, D, and F values should just be tuned to get as close to the set speed as possible.
In the case of the talon, I do not have a lot of experience but I don't think there is a lot you can do. Like you say, the code you would like to edit is firmware on the talon itself.
__________________
FLL Team Future imagineers
2010 Oregon State Championships: Winners
2011 International Invite: First place Robot design, Second Place Robot Performance
FRC Team Mean Machine
2012 Seattle: Winning alliance
2013 Portland: Winning alliance
2013 Spokane: Winning alliance
2014 Wilsonville: Winning alliance
2014 Worlds: Deans List Winner

Last edited by Bryce2471 : 29-10-2016 at 15:22.
Reply With Quote
  #3   Spotlight this post!  
Unread 29-10-2016, 15:52
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 521
ozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant future
Re: How is velocity control supposed to work on the Talon SRX?

The general goal is calculate or tune a FeedForward gain so that the sensor velocity is near the target velocity. P (and potentially D/I) are then tuned to respond when the velocity error is nonzero. This allows for an aggressive closed-loop response with less overshoot caused by large changes in target velocity (let F do the heavy lifting).

To make this clearer we provide an velocity closed-loop walkthough in our documentation and examples on our site/GitHub.

Section 12.4 (Talon SRX Software reference manual)
http://www.ctr-electronics.com/talon...ical_resources
Reply With Quote
  #4   Spotlight this post!  
Unread 29-10-2016, 16:37
Wasabi Fan Wasabi Fan is offline
Registered User
FRC #0488
 
Join Date: Dec 2015
Location: Washington
Posts: 15
Wasabi Fan is an unknown quantity at this point
Re: How is velocity control supposed to work on the Talon SRX?

Quote:
The general goal is calculate or tune a FeedForward gain so that the sensor velocity is near the target velocity. P (and potentially D/I) are then tuned to respond when the velocity error is nonzero. This allows for an aggressive closed-loop response with less overshoot caused by large changes in target velocity (let F do the heavy lifting).
Using the F parameter to get close is a good policy, but it doesn't fix the problem. Using F as a crutch is no better than just setting a power target directly; the value produced by F doesn't change as the state of the system does. The issue here is that, as velocity PID is implemented in the Talons currently, P is useless. One must rely on the I term, because it is the only term which will actually help you get to your velocity goal based on changes in the system.
Reply With Quote
  #5   Spotlight this post!  
Unread 29-10-2016, 16:49
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,574
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: How is velocity control supposed to work on the Talon SRX?

Quote:
Originally Posted by Wasabi Fan View Post
One must rely on the I term, because it is the only term which will actually help you get to your velocity goal based on changes in the system.
This.

While I can usually be skipped when driving to a position, it is essential to tuning a velocity control PID for a realistic (can't control every variable) situation.
__________________

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
  #6   Spotlight this post!  
Unread 29-10-2016, 16:59
R.C.'s Avatar
R.C. R.C. is online now
2017... Oooh Kill em, Swerve!
AKA: Owner, WestCoast Products
FRC #1323 (MadTown Robotics)
Team Role: Engineer
 
Join Date: Feb 2008
Rookie Year: 2006
Location: Madera, CA
Posts: 2,175
R.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond repute
Re: How is velocity control supposed to work on the Talon SRX?

Quote:
Originally Posted by Wasabi Fan View Post
Using the F parameter to get close is a good policy, but it doesn't fix the problem. Using F as a crutch is no better than just setting a power target directly; the value produced by F doesn't change as the state of the system does. The issue here is that, as velocity PID is implemented in the Talons currently, P is useless. One must rely on the I term, because it is the only term which will actually help you get to your velocity goal based on changes in the system.
We followed Omar's advice this season and used pdf control. We got our shooter speed to +-.50 rpm of our goal. This has been the cleanest we've ever gotten.
__________________
R.C.
Owner, WestCoast Products || Twitter
MadTown Robotics Team 1323
Reply With Quote
  #7   Spotlight this post!  
Unread 29-10-2016, 18:04
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,077
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: How is velocity control supposed to work on the Talon SRX?

Quote:
Originally Posted by Wasabi Fan View Post
The issue here is that, as velocity PID is implemented in the Talons currently, P is useless..
This is totally false in practice. Proof by counter-example:

254 used Talon-based velocity control on both our drive motors and our flywheel last season. In both cases, we used a PD+F controller and were able to track our setpoints to within +/- single digit RPM despite no integral action, even with varying battery voltage, system load, and (for the drive) while traversing defenses.

The reason why this works well is (a) feedforward, and (b) a really fast 1KHz control loop. Both of these factors let you crank up your feedback gains without sacrificing stability.

Feedforward helps because it deals with the nominal dynamics of the system so that feedback only needs to worry about dealing with modeling errors and disturbances. Usually this means that feedforward is doing most of the heavy lifting, so the feedback gains can be really aggressive because the disturbance is pretty small in magnitude. Likewise, a faster loop means that your P term can correct for the current error very quickly, so even if you overshoot by a little bit, a millisecond later you are compensating.

Our tuning methodology was to start with a nominal battery and load (e.g. flat floor and no other systems running) and tune F first, as recommended in the Talon SRX Software Reference Manual. Once this was working, we tuned our P gain until we oscillated (very quickly! 1KHz loop ) around the setpoint. Then we crank up D until the oscillation is no longer noticeable to your eye or in a plot of system response. For both of our systems last year, this meant a D gain on the order of 4-5x Kp.

I understand the sentiment around saying that integral gain is the only way to ensure that in the steady state (error=0), your system continues to operate at your desired setpoint. This is theoretically correct. But, with a sufficiently high Kp and Kd, you can react quickly to very, very small errors that are about the same magnitude as your velocity measurement error. In other words, more than good enough for FRC.
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:01.

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