# Equation to limit rate of change of end-effector in X and Y coordinates

Some vector math is involved here so prepare yourself.

I am developing a robotic arm that moves in two dimensions. It is a rotary-rotary design which looks roughly like the picture in this post: Building Robotic arm joint

I am now trying to limit the speed of the end-effector. I am using Simulink and believe that the best way to limit the speed is the limit the rate of change of the X and Y coordinates that I tell it to move to.

Now, I also want the end-effector to be able to move in a straight line and believe that I can accomplish this by defining functions that calculate the maximum rate for movement in the X or Y direction based on the distance the arm is trying to travel. The equasion I came up with is this :

xRate = (abs(currentX - nextX) / max(abs(currentX - nextX), abs(currentY - nextY))
yRate = (abs(currentY - nextY) / max(abs(currentX - nextX), abs(currentY - nextY))


So basically, XRate: distance in x / max between distance in X and distance in Y.

Now, for the actual problem. Because this limits the speed in both X and Y, the end-effector can travel (for instance) 1 in./sec in both directions at the same time. Meaning that it is travelling at OVER 1 in./sec overall. If, however, it is only moving in ONE direction then it will only move at that 1 in./sec speed because there is no second component. It boils down to the fact that the max speed the arm can move is 'sqrt(2)' and the minimum is '1'.

My main question is: Given that I need to calculate a max xRate and a max yRate, how can I limit the overall speed of the end-effector?

Secondarily, is there a way for me to implement a rate control that will limit the overall rate instead of limiting X and Y independantly using Simulink?

Rather than trying to limit the 'x' and 'y' velocities separately, you should be limiting the overall velocity and calculating the component velocities from that overall velocity. In other words, something like:

dx = currentX - nextX
dy = currentY - nextY
rate = min (maxRate, maxRate / sqrt( dx^2 + dy^2 )
xRate = dx * rate
yRate = dy * rate


So for moving only in X:

dx = currentX - nextX                              = 1
dy = currentY - nextY                              = 0
rate = min (maxRate, maxRate / sqrt( dx^2 + dy^2 ) = maxRate
xRate = 1 * rate                                   = maxRate
yRate = 0 * rate                                   = 0


While moving only in Y:

dx = currentX - nextX                              = 0
dy = currentY - nextY                              = 1
rate = min (maxRate, maxRate / sqrt( dx^2 + dy^2 ) = maxRate
xRate = 0 * rate                                   = 0
yRate = 1 * rate                                   = maxRate


And for the diagonal movement you suggested:

dx = currentX - nextX                              = 1
dy = currentY - nextY                              = 1
rate = min (maxRate, maxRate / sqrt( dx^2 + dy^2 ) = maxRate / sqrt(2)
xRate = dx * rate                                  = maxRate / sqrt(2)
yRate = dy * rate                                  = maxRate / sqrt(2)

• Fantastic answer. If you don't mind me asking, is there a resource somewhere you know of, or did you work this out yourself? Apr 3, 2013 at 20:21
• No problem @user912447, I just worked it out from first principals based on your premise. It's completely untested pseudocode though, so I would write some tests and try it yourself before assuming that it works. *8') Apr 4, 2013 at 9:38
• Yep, gave it a try and it worked well. Apr 4, 2013 at 12:22