|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Smooth Path Generator for RoboRio 2015
I am no expert in data science, or computational mathematics, it was an amateur question. Since his program is iterative, there does exist a point when taking the inverse of a matrix is faster than n interations, I believe.
|
|
#2
|
||||
|
||||
|
Re: Smooth Path Generator for RoboRio 2015
Correct me if I'm wrong:
The code generates an array of velocities which the robot has to reach at specific times of the auto (each side independently) and with encoders on each side and a PID loop I need to make the wheels actually get to that velocity. Did I get it right? If so, what is the best way to use PID for velocity control? Last edited by GuyM142 : 14-10-2014 at 14:15. |
|
#3
|
|||
|
|||
|
Re: Smooth Path Generator for RoboRio 2015
Kevin, can you talk a little more about the convergence of Alpha and Beta combinations? How did you determine whether or not certain parameters converge? And would convergence be related with the original path (Like would a path with an right or acute angle between segments have different convergence properties than a closer to straight path)?
Last edited by artK : 14-10-2014 at 16:47. Reason: Better answer to question I answered |
|
#4
|
|||||
|
|||||
|
Re: Smooth Path Generator for RoboRio 2015
Quote:
Code:
// For each side of the drive...
while (following) {
// desired_position, desired_velocity, and desired_acceleration are all generated by your profile.
position_error = desired_position[i] - actual_position;
command[i] = Kv * desired_velocity[i] + Ka * desired_acceleration[i] + Kp * position_error;
}
1) Generate an impulse response. From a stop, slam the sticks forward until you max out at your full robot speed. You may require a long distance to get up to speed, so plan accordingly. Stop the robot once it hits full speed (...or the back wall of your shop). 2) You can now analyze your charts to obtain a couple useful quantities: max_speed: The maximum speed (maximum slope) of the position vs. time plot. accel_time: How long from when you started until you hit the maximum speed (it is a bit of a judgement call since the curve is smooth, but try to get it in the right ballpark). max_accel ~= max_speed / accel_time 4) Set Kp = Ka = 0, and Kv = 1/max_speed. 5) Generate a motion profile with a maximum velocity of about 80% of your max speed and a maximum acceleration of about 80% of your max acceleration. The 80% is to be conservative and robust to batteries, etc. 6) Attempt to follow the profile with the gains from step 4. Watch your plots vs. the profile (yep...also plot the commanded positions/velocities). It is likely that you lag the profile initially, and lead it (or overshoot) at the end due to the robot's inertia. 7) Next, we will tune Ka to have the robot compensate for this lag/lead. The idea is that when you are accelerating heavily, you can add or subtract from your command to compensate for the robot's inertia. Tune Ka by adjusting and repeating the experiment in 6 until you are following the profile as close as possible. The right value of Ka will be between 0 and 1/max_accel. 1/(2*max_accel) is a reasonable first guess. 8) At this point, you should be following profiles reasonably well, but it is not perfectly repeatable, probably doesn't drive straight, etc. Let's add some feedback. The units of Kp are in (% of power per unit of error). If you have tuned Kv and Ka pretty well, you can get away with a Kp on the order of 1 or 2 if your units are meters (1/3 to 2/3 if using feet, etc). 9) You should follow the trajectories really, really well now. They should be somewhat straighter and quite repeatable. At this point, things are probably working decently well. Here are a few more options if you want to keep tweaking: 1) Add an integral term based on the sum of position error to get even more precision in final distance. We found this totally unnecessary last year, but YMMV. 2) Add a gyro to help stay straight. Each side of the drive is totally independent, so you can add a simple gyro controller that adds or subtracts from the velocity command being fed to each in order to compensate for accumulated errors. 3) Add trajectory replanning so that if you get bumped to the side, you instantly regenerate a new trajectory to smoothly get you back on track. If necessary for our strategy, 254 might do this in 2015 ![]() 4) Better characterize your drive train. The calculated left and right velocities are actually assuming a two wheeled vehicle with no slip...4, 6, and 8 wheel drives always have some scrub that results in the vehicle turning less than commanded. You can attempt to measure this and adjust your trajectories accordingly. Last edited by Jared Russell : 14-10-2014 at 16:39. |
|
#5
|
||||
|
||||
|
Re: Smooth Path Generator for RoboRio 2015
This software is quite similar to what I have been planning to implement. I think I will try to decompose this code and rewrite it so I can learn how it works. I have been working on a way to generate a path on the field. The problem with my approach is that no algorithm is perfect. Even though I am using greedy's algorithm because it seems like it will work perfectly for an FRC setup, it every once in a while will generate some sudden turn, often for no purpose. This type of algorithm would help smoothen it out so It can be transformed into motor powers to control the robot.
Kevin, Thank you for sharing this with me as now I have an almost identical piece of software that works, so I can have an example to learn off of. |
|
#6
|
||||||
|
||||||
|
Re: Smooth Path Generator for RoboRio 2015
Quote:
Quote:
Quote:
Quote:
Let me think more about your second question. My hunch right now is that valid path data regardless of its actual shape should have no affect on the convergence rate of a set of parameters. But let me think about it some more, and possibly do some calcs on it and get back to you. I would assume we are talking about valid, realistic paths only, and nothing which is intentionally malformed. Quote:
Quote:
Regards, Kevin Last edited by NotInControl : 16-10-2014 at 17:11. |
|
#7
|
||||
|
||||
|
Re: Smooth Path Generator for RoboRio 2015
Sorry to revive an rather old thread, but since this is a continuation of @notincontrol's work, I felt it needed to be tied with it.
Here is my attempt at converting his code to work with swerve: https://github.com/faust1706/Smooth-Swerve I based the calculations off Ether's materials, but that doesn't mean I miss typed or something. How to use: define set of waypoints, x and y, and then a set of angles you want the robot to be facing at each way point. A known thing that is broken is the output velocity per motor. Last edited by faust1706 : 30-04-2015 at 13:31. |
|
#8
|
||||
|
||||
|
Re: Smooth Path Generator for RoboRio 2015
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|