Thread created automatically to discuss a document in CD-Media.
Driving a Robot — Fastest Path from A to B by: Mr. N
This mathematical proof shows that the fastest way to drive from one position and heading to any another position and heading is to turn on the spot, drive in a straight line, then turn again.
Two driving strategies for a typical FRC “tank” robot are compared: (1) a ‘turn-straight-turn’ path in which the robot moves in a straight line with discrete heading adjustments at the start and end points, and (2) a generalized ‘curvilinear’ path. The analysis shows that the ‘turn-straight-turn’ method minimizes drive time in all cases.
I have such a strong desire to print this out and walk around pits handing it to other teams for two reasons one is because it honestly is an interesting read(I am a nerd leave me be) the other is because if it convinces teams this is true then defense became a whole lot easier.
Interesting read. A couple things I would point out: 1.) There is another scenario to consider: Drive, turn, drive (Back up to a point coincident with a point on your final pose vector, turn to face the vector, then drive forward to the point), and 2.) This doesn’t take into account real accelerations. There is an underlying assumption that speed is instant, meaning it takes 0 time to get to speed/reverse directions. With a spline path, there are no reversals in direction, so it might be something worth looking at.
Well, with defense this whole calculation can be thrown out the window. Since there is a moving and smart (ie non arbitrary/random) blockade you end up in a situation where there is many “pose” A, B, C, D, …, Z which is constantly changing to path around said blockade.
This is simply analyzing a situation where there is no interference.
Oh I know, it was a joke, though you know if someone read this and just read the final result atleast someone wouldn’t take into account defense and just start driving “tetris style” as my old driver use to say
Thanks for reading the paper — and for your feedback. You raise some very good points. Here are some additional thoughts in response to these points:
Very true, the analysis assumes instantaneous accelerations to make the problem more tractable. However, the assumption is based on models developed from speed trial data using our 2013 robot. In a straight-line test, the robot reached 75% of maximum speed within the following times/distances:
In lo-speed gear (24:1): within 0.2 seconds/20 cm of travel
In hi-speed gear (9.4:1): within 0.7 seconds/140 cm of travel
FRC robots, going full throttle from a standing start, do virtually all of their accelerating in a faction of a second.
So, the assumption is reasonable when talking about paths lasting several seconds covering several meters. Conversely, it is a poor assumption for very short, very quick paths.
2) Reversing to Get from A to B
This is a great point. When I developed a game simulator for the 2014 game using the “turn-straight-turn” strategy, I realized that the “delta theta” terms (i.e., the changes in heading) had an ambiguity for angles greater than 180 degrees. For example, you get to the same heading by turning +270 or -90. Clearly the second turn is faster. But it also requires the robot to travel **backwards **during its straight-line motion.
Although not explicitly mentioned in the paper, this result is entirely consistent with the conclusion. Consider the 2013 game: it is faster to travel **in reverse **from the shooting position at the pyramid to the feeding station, rather than turning 180 degrees first.
3) Multi-Segmented Paths
Given the qualifiers outline in (1), I would argue it is more efficient to plan a trip around a mid-field obstacle (e.g., a pyramid) as a series of straight segments rather than one curved, sweeping path.
4) Impact on Strategy vs. Tactics
Clearly, the findings are more relevant when planning overall game strategy that involves moving between key locations (“way points” or “way poses”), as opposed to tactical moves on the field when contending with defenders.
Even assuming that, when accelerating as hard as possible, that acceleration is insignificant*, it should be noted that a human driver still has to control the robot for the in-place turn. And I doubt there are any drivers out there that can time it such that they switch from full acceleration to full deceleration at just the right time to turn a precise angle. The hardest part isn’t accelerating as fast as possible; it’s being as accurate as possible while moving at speed.
This still leaves the question of what the fastest path would be in autonomous, accounting for acceleration. Turn-Straight-Turn is certainly the simplest and reasonably fast if you get your control loops right.
*Keep in mind that if each acceleration takes a fraction of a second, you still have to accelerate/decelerate three times in a given maneuver, which can add up to a couple seconds over the course of a maneuver and even a second per maneuver adds up quickly when doing multiple maneuvers per cycle and multiple cycles per match.
That said, I don’t agree. I have done a ton of work this summer with this sort of curve generation, and curve cannot be simplified to simple cubic curves. A trajectory can contain a large number of parametric quintic curves, which can have specified end headings, specified end heading derivatives, as well as (because they’re parametric) dy/dt, which affects how sharp the curves are. If these are optimized, I believe it is faster to drive in a curve.
It is also not accurate to disregard robot acceleration.
I am also taking into account an actual robot’s velocity, acceleration (both acceleration and deceleration, a robot can decelerate faster than it can accelerate), and jerk limits, as well as the actual speed the robot can take a turn at.
To further back this up. Even if you are going to do a simple turn-straight-turn, it’s going to be faster to turn about one drive side rather than the center of the robot because this moves your center further along the path, and doesn’t require direction reversals for either drive side.
The curvilinear path, when considering the speeds of each side, is generalizing this by allowing each side of the drive to stay at a positive speed and minimized their accelerations while still accomplishing the heading changes and displacements needed.
I think, in fact, we’re in good agreement. Here are some points of clarification:
Yes, a trajectory can be defined by an arbitrary parametric curve. I was merely pointing out that the **lowest order **polynomial spline that satisfies the end conditions is a cubic. However, the analysis is generalized for any function that has either (1) no inflection points or (2) one inflection point (a curve with more inflection points has superfluous arc length and is always longer). So, within the context of the original assumptions, the conclusions hold true for any spline.
It is also not accurate to disregard robot acceleration.
Agreed. However, in my earlier post, I attempted to set out general boundaries for when the assumption is still valid. For longer paths — on the order of many meters — there is closer agreement to real results than for shorter paths. It also depends on what gear you’re in. The assumption is closer to reality for low-speed gears.
…a robot can decelerate faster than it can accelerate…
Very true, but a faster deceleration is in fact closer to my “instantaneous” assumption.
…and jerk limits…
This I’m **really **curious about. In my dynamic model, the velocity/acceleration limits are set by the motor characteristics. Speed and torque are coupled. However, I don’t see how third-order derivatives (jerk) enter into it.
…This path takes 1.77 seconds to drive, and travels 5 feet down and 5 feet to the left…
In your example, the total path length is a little over 7 feet or about 2.2 meters. In my previous post, I point out that, in hi-speed gear, it takes about 1.4 meters to accelerate (and likely something similar to decelerate). So, this example is what I would classify as a “short” path (where acceleration definitely matters).
Can you re-run your example for 25x25 foot run (e.g., a cross-field maneuver) with similar rates of turn (remembering that the speed constraint must be imposed on the outermost bank of wheels during a turn, not the centroid).
What if I do something like this? To stop and turn at each waypoint would be really slow.
Agreed , but is this representative of a real game strategy? I would argue that a typical game involves significantly fewer way points per scoring cycle that what you’ve shown.
All that said, it looks like your research and programming has led to a very powerful and useful modelling tool. Congrats!
Turning about a point other than the center does indeed made the center of the robot move faster. However, it **simultaneously creates a longer path **in every case. This is the central question: Does the increased speed compensate for the extra length? The answer is no (within the context of the working assumptions).
Me too. After reading this post, I agree with what you’ve said, that curves and drive-then-turn both have their uses, especially considering that curves are much more difficult to implement. For a single spline, the time difference is pretty small. Once you start joining many splines, or using weirder splines, it becomes a different problem.
Thanks very much for the detailed answer. Great work!
One thing: The acceleration limit you used (10 ft/s/s) may be little low. Based on our speed trials, we were getting something more like 22 ft/s/s (Supershifter, hi-speed gear).
I worked up a similar example using the math from my paper (I probably should have included this in the paper itself). I used a 25x25 foot path with a similarly shaped curve. I set my upper speed at 10ft/s and robot wheel base to 2 ft.
Although I don’t take acceleration into account, keep in mind that (a) the path is long enough that the effects of acceleration are minimized, and (b) both the linear and curved path benefit from the “instantaneous” acceleration assumption – they are **both ** slightly faster than real life, by about the same amount.
Here are my results:
Turn-Straight-Turn: 3.69 seconds, total arc length = 35.36 feet, total heading adjustment = 90 degrees
Curve: 4.00 seconds, total arc length = 37.79, total heading adjustment = 126 degrees
I wouldn’t say that. A large part of this is conservation of momentum, and the best swerve teams know that utilizing a robot’s momentum to its fullest will provide the smoothest and most advantageous maneuverability the swerve design can offer. The same is true with any robot drivetrain.
What you have brought up is a special case of a well known theorem from optimal control that says (essentially) that you always want to be saturating your inputs to get to the final state in a time optimal way. Intuitively, if your left and right motors are always going full speed in the right direction towards your setpoints (both position and angular, and you’ve found the right turn-straight-turn policy that ensures that this is true), you will always get there faster than if they are not going full speed all the time.
This property holds with an infinite acceleration limit and, indeed even with limits on acceleration, jerk, etc. - except in the latter case, you always want to be accelerating/jerking at the limit. The complication is that once you introduce higher order constraints, the “order of operations” policy becomes difficult to discover because of the nonlinear mapping between motor speeds and position/rotation. Once you have higher order constraints, finding a time-optimal path becomes a more difficult process, typically requiring iteration and search in a non-convex space.
If you look at 254’s acceleration profile generation code from this year, you’ll see this concept in action - using a triple integrator with an input that always switches between +1/-1, we obtain a limited-jerk, limited-acceleration, limited-velocity trajectory. We then applied this acceleration profile over a spatial spline, which of course broke the time optimality but was good enough in practice (with some safety margin to prevent saturation).
So…Yours is the right conclusion if you ignore practicalities like acceleration limits, wheel slip, battery usage, dynamics/momentum, and jerk to the robot and any load(s) it is carrying. Empirically, these are quite significant factors for FRC driving:
Robots that have high enough maximum accelerations to allow you to assume instantaneous acceleration will frequently also be capable of slipping their wheels, harming control, acceleration, and accurate distance measurement. Moreover, by the time you are talking about full-weight, 15+fps robots, the infinite acceleration assumption breaks down severely.
A robot that moves from one point to another along an arc does not need to repeatedly accelerate and decelerate the drive motors as in a turn-straight-turn case. This saves battery life, heat, and wear-and-tear over the course of a match. The battery life savings can be significant enough that it allows you to gear your robot faster overall.
Momentum is a HUGE part of FRC driving at high speeds. If I take a 254 robot at 19fps and want to turn, I can do so on a dime simply by slowing down one side of the drive and letting the momentum whip the back end of the robot around the corner. Maintaining momentum through maneuvers is generally preferential to coming to a stop.
Even if you have an infinitely accelerating robot that doesn’t slip its wheels, has a perfect battery, and doesn’t care about momentum, if you are carrying a game piece externally, you may want to reduce the accelerations and jerks experienced by them. Case in point: The balls we held on our bumpers during auto mode this year could be dislodged by a very abrupt stop or quick turn in place.
One quick question- how does the code (or does it even do it?) limit acceleration, jerk, and velocity if the path goes straight long enough for the robot to reach full speed, then suddenly turn sharply? Do you go through the turn too quickly, ignore acceleration limits and stop too quickly, or do you somehow begin decelerating before you get there?
In 2014, by having conservative limits on these quantities and not having lots of sharp turns. (Inelegant but good enough.)
For 2015 and beyond, by assigning maximum velocities to each point on the path based on curvature and working backwards to respect the other limits. This is the “correct” way to do it, and fairly straightforward for the limited acceleration/unlimited jerk case. But it can be very complicated for limited jerk control.