Circular Interpolation
I'm developing some software for driving stepper motors. I'm a little stuck on some of the math behind circular interpolation.
I'm finished with linear interpolation and i went about that by using d=a/2t^2
i can move distance s every time i step so d = s*n where n is the number of steps i've taken. t = sqrt((s*n/a)*2) then my dt = sqrt((s*n/a)*2) - sqrt((s*(n-1)/a)*2).
initially i looked into doing something similar with circular interpolation but since arctan isn't a 1 to 1 function i lost my way
basically i want to start a v = 0 and accelerate at some tangential velocity aT, so the parametric forms for a circle are:
x = a + rcos(theta)
y = b + rsin(theta)
and d^2theta/2t^2 = aT/r
so theta = (aT*t^2)/(2*r)
and we have
x = a + rcos((aT*t^2)/(2*r))
y = b + rsin((aT*t^2)/(2*r))
now obviously if i wanted to solve for t the constraint on x is -r <= x <= r and this is where my problem lies i need to be able to incorporate the rotation.
ie i start at r and move to -r on the x axis, but if i want to go from -r to r then to 0 i don't know how to express that.
my current implementation interpolates using t then calculates the change in position if that is >= to my step distance, i use that delta t. this feels very inefficient but it does seem to work, is there a more elegant solution?
You should get the same answer for both the linear and rotational cases. When you think about it, if a point needs to travel some distance 'd' under an acceleration 'a', it doesn't matter if it's traveling in a straight line or constrained to a circular arc, it's going to travel that distance in an amount of time governed by d = (a/2)t2 (assuming it's initially at rest). So if your acceleration is 'aT' in the rotational case instead of 'a', just use that for the acceleration.
in this particular problem i need to generate a set of values that will allow me to ramp up to a specific tangential velocity then maintain that velocity.
i do agree that that would solve the problem if i wanted to look at it as a straight line but i don't
i suppose i should have stated that this is a coordinated motion problem, i have a stepper motor controlling x, and one controlling y
i can step s in a either direction along that axis
i need to generate a list of times for each axis that when i step the motors at those intervals generates a circle
i do agree that that would solve the problem if i wanted to look at it as a straight line but i don't
i suppose i should have stated that this is a coordinated motion problem, i have a stepper motor controlling x, and one controlling y
i can step s in a either direction along that axis
i need to generate a list of times for each axis that when i step the motors at those intervals generates a circle
maybe someone can tell me if this makes sense
i'd like to interpolate using distance rather than time so i'll solve for t
so theres
dtheta/dt = v/r + (aT/r)*t
then theta = (v/r)*t + (aT/2r)*t^2
so
now i'll assume i'm starting at a point on the circle
so
x = rcos((v/r)*t + (aT/2r)*t^2)
y = rsin((v/r)*t + (aT/2r)*t^2)
and
(aT/2r)*t^2 + (v/r)*t - acos(x/r) = 0
(aT/2r)*t^2 + (v/r)*t - asin(y/r) = 0
and i take the positive root
so if i start at (r, 0) on the circle and i rotate to (0, r) with v = 0
then
t = sqrt((acos(x/r)*2r)/aT)
t = sqrt((asin(y/r)*2r)/aT)
now at (0, r) the velocty in x is Vtangential y is 0
if i swap the sin and the cos out when i pass 90 degrees
(aT/2r)*t^2 + (Vtangential/r)*t - asin(x/r) = 0
(aT/2r)*t^2 + (Vtangential/r)*t - acos(y/r) = 0
then i continue to recalculate the tangential velocity and swap the sin/cos every 90 degrees, is this correct?
i'd like to interpolate using distance rather than time so i'll solve for t
so theres
dtheta/dt = v/r + (aT/r)*t
then theta = (v/r)*t + (aT/2r)*t^2
so
now i'll assume i'm starting at a point on the circle
so
x = rcos((v/r)*t + (aT/2r)*t^2)
y = rsin((v/r)*t + (aT/2r)*t^2)
and
(aT/2r)*t^2 + (v/r)*t - acos(x/r) = 0
(aT/2r)*t^2 + (v/r)*t - asin(y/r) = 0
and i take the positive root
so if i start at (r, 0) on the circle and i rotate to (0, r) with v = 0
then
t = sqrt((acos(x/r)*2r)/aT)
t = sqrt((asin(y/r)*2r)/aT)
now at (0, r) the velocty in x is Vtangential y is 0
if i swap the sin and the cos out when i pass 90 degrees
(aT/2r)*t^2 + (Vtangential/r)*t - asin(x/r) = 0
(aT/2r)*t^2 + (Vtangential/r)*t - acos(y/r) = 0
then i continue to recalculate the tangential velocity and swap the sin/cos every 90 degrees, is this correct?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement