Go to Post I (personally) am not involved in FIRST because I want to win (of course, that would still be nice ;) ). - pogenwurst [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

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-12-2012, 20:59
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,064
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: Motion Profiling

A perfect motion profiler (and appropriate controller) will get you to your goal at least as fast as any other method. If the acceleration limit in your profiler is right on the cusp of the stick-slip point for the wheels, you have essentially implemented a form of traction control for your robot.

Of course, the stick-slip point depends on a lot of things (tread wear, carpet irregularities, the amount of weight being carried by each wheel instantaneously, etc.), so in practice you usually want to back off on the acceleration limit by a safety margin. The extra repeatability is worth the handful of milliseconds longer it takes for your robot to get to its goal.

In general, if all your feedback controller is doing is removing noise/error from your planned trajectory, you're going to have a good time. This is why feedforward gains are so powerful - in the absence of any disturbances, you theoretically will get exactly where you want to go without needing ANY feedback!

Last edited by Jared Russell : 21-12-2012 at 21:01.
  #2   Spotlight this post!  
Unread 21-12-2012, 21:07
Paul Copioli's Avatar Unsung FIRST Hero Woodie Flowers Award
Paul Copioli Paul Copioli is offline
President, VEX Robotics, Inc.
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Rockwall, TX
Posts: 1,381
Paul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond repute
Re: Motion Profiling

Tom,

I am sitting in the HK airport so I have some time to kill. I will try to go through a simple double linear filter motion profile scheme. This is the fastest way, computationally, to do real time motion profiling. However, for FRC autonomous mode applications, the real time filtering really isn't required.

Some definitiions:

itp = iteration time (loop time)
T1 = Time, in ms for the first filter
T2 = Time, in ms for the second filter
FL1 = Filter 1's length, unitless. Must be an integer. FL1=RoundUp(T1/itp)
FL2 = Filter 1's length, unitless. Must be an integer. FL2=RoundUp(T2/itp)

Vprog = Desired Max Speed, ft/sec (can be any units you desire, just be consistent)

Dist = Desired travel distance, ft (can be any units ...)

T4 = Time, in ms, to get to destination if always at Vprog. T4 = Dist / Vprog
N = Total number of inputs to the filter, Integer. N = RoundUp (T4/itp)

That is really all you need to do the filtering so here is an example with numbers:

Vprog = 10 ft/sec
Dist = 4 ft
itp = 50ms (doing this to make the math short and easy)
T1 = 200 ms
T2 = 100 ms (this makes it an even trapezoid, as this number increases, it becomes a more traingular accel profile)

T4 = 4/10 *1000 = 400
FL1 = 200/50 = 4
FL2 = 100/50 = 2
N = 400/50 = 8

Ok, now time to fill the filters. How this works is simple. FIlter 1 has FL1 number of boxes, Filter 2 has FL2 # of boxes, and your inputs are N # of 1s until all filters are cleared.

Step # Time Input FL1 FL2 Output (Vel)
1 0 0 0 0 0 0 0 0 0 * Vprog
2 .05 1 1 0 0 0 0 0 1/6 * Vprog
3 .10 1 1 1 0 0 0 0 1/3 * Vprog
4 .15 1 1 1 1 0 0 0 1/2 * Vprog
5 .20 1 1 1 1 1 0 0 2/3 * Vprog
6 .25 1 1 1 1 1 1 0 5/6 * Vprog
7 .30 1 1 1 1 1 1 1 1 * Vprog
8 .35 1 1 1 1 1 1 1 1 * Vprog
9 .40 1 1 1 1 1 1 1 1 * Vprog
10 .45 0 0 1 1 1 1 1 5/6 * Vprog
11 .50 0 0 0 1 1 1 1 2/3 * Vprog
12 .55 0 0 0 0 1 1 1 1/2 * Vprog
13 .60 0 0 0 0 0 1 1 1/3 * Vprog
14 .65 0 0 0 0 0 0 1 1/6 * Vprog
15 .70 0 0 0 0 0 0 0 0 * Vprog

This is now your velocity command. Some interesting statistics:

Total time to end point = (N + FL1 + FL2)*itp
Total time to Max Speed = (FL1 + FL2)*itp
Theoretical time to end point = N*itp. This now corresponds to the time when decel starts.

In theory, if your itp time is short enough, then you can simply do a velocity PI routine on each of these commands in the Jag and get great position control. In addition, you can manipulate the ratio between T1 and T2 to get different Velocity trajectories based on your robot's capabilities. At FANUC, the T1 = 2 * T2 was pretty much a golden rule, but I violated it once or twice on specific painting robot models.


Let me know if you have any questions.

Paul
Attached Files
File Type: xlsx Filter Motion Profile.xlsx (11.7 KB, 151 views)
__________________
In full disclosure I am the President of VEX Robotics, a division of Innovation First International.

Last edited by Paul Copioli : 21-12-2012 at 21:22. Reason: Added Excel File to show data better
  #3   Spotlight this post!  
Unread 21-12-2012, 21:45
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,064
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: Motion Profiling

Paul,

Thanks for sharing that. That's a very elegant way to do it.

You say about T2, "this makes it an even trapezoid, as this number increases, it becomes a more traingular accel profile". I don't follow. In your spreadsheet I can't see the difference between the two filters (to me it looks like one filter of length FL1+FL2).
  #4   Spotlight this post!  
Unread 21-12-2012, 21:50
Paul Copioli's Avatar Unsung FIRST Hero Woodie Flowers Award
Paul Copioli Paul Copioli is offline
President, VEX Robotics, Inc.
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Rockwall, TX
Posts: 1,381
Paul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond repute
Re: Motion Profiling

Jared,

Graph acceleration vs. time and you will see what I mean. Now I did just do that from memory while sitting in an airport so there is a chance I missed a step. When I get back to my notes I will make sure what I put in this post is correct.

Edit:
Yep, I missed a step. After filter 1 you are supposed to sum filter 1 and divide by the number of steps in filter 1 (in our case, 4) and use that as the input to filter 2. Everything else stays the same. I attached a new Excel file. The resolution of this example stinks so that is why you get the chop in the accel curve.


Paul
Attached Files
File Type: xlsx Filter Motion Profile.xlsx (15.2 KB, 204 views)
__________________
In full disclosure I am the President of VEX Robotics, a division of Innovation First International.

Last edited by Paul Copioli : 21-12-2012 at 22:04.
  #5   Spotlight this post!  
Unread 22-12-2012, 01:33
AdamHeard's Avatar
AdamHeard AdamHeard is offline
Lead Mentor
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Atascadero
Posts: 5,494
AdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond repute
Send a message via AIM to AdamHeard
Re: Motion Profiling

Quote:
Originally Posted by Paul Copioli View Post
In theory, if your itp time is short enough, then you can simply do a velocity PI routine on each of these commands in the Jag and get great position control.
l
How well would passing the position commands to a PD or PID positon controller work compared to the above suggestion?

Also, would you leave the Vprog, T1, T2 parameters constant for all movements (for traveling 1 ft, and also 100 ft?), or would you vary per distance?
  #6   Spotlight this post!  
Unread 22-12-2012, 14:35
Paul Copioli's Avatar Unsung FIRST Hero Woodie Flowers Award
Paul Copioli Paul Copioli is offline
President, VEX Robotics, Inc.
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Rockwall, TX
Posts: 1,381
Paul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond repute
Re: Motion Profiling

Adam,

I think passing position commands work too. One interesting thing to note is that you could do a cascading PID with pos PID in the crio and velocity in the jag.

The motion profile usually needs 2 types of parameters: regular and short motion. The short motion routine is for motions where T4 is less than T1 +T2. Other than that, the profile constants adjust the profile pretty well.
__________________
In full disclosure I am the President of VEX Robotics, a division of Innovation First International.
  #7   Spotlight this post!  
Unread 21-12-2012, 03:28
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,500
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Motion Profiling

Quote:
Originally Posted by Jared341 View Post
To echo what Austin said: This is a great example of something you can develop and test without a running robot. Write the code to generate a trapezoidal motion profile using J2SE or on a desktop using C++, debug using Excel, Matlab, or Gnu plots, and you will be able to port it to your robot code with ease.

Of course, once you are generating your trapezoidal motion profiles, you will need a controller that makes sure the bot actually follows it! Here are a few ideas on how you could do this:

1. Use a PID loop on your drive motors (in distance mode). Use the speed output of your motion profile to limit the maximum command that PID is allowed to send to your motors.

2. Use a PID loop on your drive motors (in speed mode). As long as your speed loop has an integral term (the I gain is nonzero), this should get you where you are going.

3. Use both (1) and (2) to control both speed and distance; there is also a specialized "PIV" controller used in industrial servos that mixes both speed and distance to command the motors.

4. Just use the speed command you generated to drive the motors directly (open loop), but switch to a PID controller when you get close to the goal to go the last few inches.

5. Make a full-state controller using control theory and simulation; if you go this route you are either insane or 254
I'm a bit lost as to why a trapezoidal profile would be better than a well tuned PID. It seems to me that you want to accelerate as quickly as possible for as long as possible, then decelerate as quickly as possible and stop at your location.

How does a 'profile' do that any better than PID?

Last edited by Tom Line : 21-12-2012 at 17:17.
  #8   Spotlight this post!  
Unread 21-12-2012, 03:42
Paul Copioli's Avatar Unsung FIRST Hero Woodie Flowers Award
Paul Copioli Paul Copioli is offline
President, VEX Robotics, Inc.
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Rockwall, TX
Posts: 1,381
Paul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond reputePaul Copioli has a reputation beyond repute
Re: Motion Profiling

That profile actually gives you a predictable and repeatable motion path almost regardless of battery voltage (I say almost because a dead battery is a dead battery). The PID should only be used for disturbance correction. All high end industrial robots that need ridiculously good repeatability use the motion planning method. FANUC uses trapezoidal Acceleration profile and triangular acceleration profile (for really short motions) to control motion. The biggest issue fighting repeatability is Jerk (the derivative of Acceleration) and the trapezoidal acceleration profile helps fight this.

Most wafer robots used in the silicon industry use triangular aceeleration, but the loads are a bit higher with a tradeoff of shorter time to target.

In general, it is good practice to do some sort of motion planning to increase reliability. Most of us FRC people are just too lazy to actually do it and use PID to control everything.
__________________
In full disclosure I am the President of VEX Robotics, a division of Innovation First International.
Closed Thread


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 09:13.

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