If you want to make sure that your path is both velocity and acceleration limited, here is a simple and widely used method:
1. For each point along the path, compute the maximum allowable velocity. For straight segments, this is simply the maximum motor velocity. For points along curves, you can compute the radius of curvature and from that derive the maximum linear speed that would let you follow the curve (based on setting the outside wheel's speed to the maximum).
You now have a discontinuous velocity profile that might look something like this:
Code:
Initial maximum velocities
Plot of waypoint # (x) vs. maximum velocity (y)
---- ----- --------- (fast)
------
------- (slow)
2. Now iterate through the path (beginning to end) and for each point, set max_velocity[i] = min(max_velocity[i], max_velocity[i - 1] + max_accel_over_distance_between_points (see NOTE) ). You will now have a profile that looks something like:
Code:
Intermediate maximum velocities
Plot of waypoint # (x) vs. maximum velocity (y)
---- ---- ------- (fast)
------/ /
-------/ (slow)
3. Iterate through the path from end to beginning, and for each point, set max_velocity[i] = min(max_velocity[i], max_velocity[i + 1] + max_decel_over_distance_between_points). Your final profile will look like:
Code:
Final maximum velocities respecting acceleration limits
Plot of waypoint # (x) vs. maximum velocity (y)
--- -- ------- (fast)
\------/ \ /
\-------/ (slow)
NOTE: Generally you want to sample your path so that the points are relatively close together and uniformly spaced in distance (since this is probably what your controller will want as well). To figure out the maximum allowable velocity, use the equations d = v0 * t + 1/2 * a * t^2 and v = v0 + a * t.