# Choosing motor speeds for an omnidirectional robot given desired linear and angular velocity

Below is an example of an "omnidirectional robot" with four wheels. Each wheel has rollers on it so it can only exert a force along the line parallel to its face, coincident to the ground, and coincident with the point on the wheel touching the ground.

I am trying to choose angular velocities for each of the four motors to result in a desired 2D linear velocity vector as well as an angular velocity for the whole robot. For simplicity, I have reduced this problem to the following diagram, where each wheel contributes a velocity vector to the system with magnitude $$a$$, $$b$$, $$c$$, and $$d$$ respectively.

Note that this is kind of like an extended force diagram, but I can only control motor velocity (speed and direction), and so it doesn't make sense to use forces for my application.

The vector $$[x, y]$$ is the desired instantaneous velocity vector (fixed to the robot), and $$\omega$$ is the desired instantaneous angular velocity.

Say the distance of each wheel from the center of the robot is constant $$r$$. Then, I believe \begin{align*} \omega=\frac{a+b+c+d}{4r}\\ \end{align*}

Also, $$x=(c-a)$$ and $$y=(b-d)$$.

Therefore, $$a=(c-x)$$, $$b=(d+y)$$, $$c=(a+x)$$, and $$d=(b-y)$$. Substituting into the equation for $$\omega$$, we have:

\begin{align*} \omega&=\frac{a+b+c+d}{4r}\\ &=\frac{(c-x)+b+c+(b-y)}{4r}\\ 4r\omega&=2(c+b)-x-y\\ \frac{4r\omega+x+y}{2}&=c+b\\ \end{align*} and \begin{align*} \omega&=\frac{a+b+c+d}{4r}\\ &=\frac{a+(d+y)+(a+x)+d}{4r}\\ 4r\omega&=2(a+d)+x+y\\ \frac{4r\omega-x-y}{2}&=a+d\\ \end{align*}

Since everything on the left side of these two equations is given, we can introduce constants $$m$$ and $$n$$, where $$m=\frac{4r\omega-x-y}{2}$$ and $$n=\frac{4r\omega+x+y}{2}$$. Then, we simply have $$a+d=m$$ and $$b+c=n$$.

I then proceeded to find the values of $$a$$ and $$b$$ such that the squared differences between each motor value and the average motor value were minimized. I did this because each motor has a max speed, and so if max$$(a,b,c,d)$$ were above that max speed I would have to multiply all of the motor speeds by $$\bigg( \frac{\text{max power}}{\text{max}(a,b,c,d)} \bigg)$$. This would keep the direction of the desired vectors, but would reduce the magnitudes to be attainable. Minimizing the sum of the squared deviances should minimize the amount that I will have to scale down all of the speeds. In other words, I minimized the following with respect to $$a$$ and $$b$$:

\begin{align*} &\hspace{0.6cm} (a-\text{avg})^2+(b-\text{avg})^2+(c-\text{avg})^2+(d-\text{avg})^2 \\\\ &=(a-\tfrac{a+b+c+d}{4})^2+(b-\tfrac{a+b+c+d}{4})^2+(c-\tfrac{a+b+c+d}{4})^2+d-\tfrac{a+b+c+d}{4})^2 \\\\ &=(a-\tfrac{a+b+(n-b)+(m-a)}{4})^2+(b-\tfrac{a+b+(n-b)+(m-a)}{4})^2+((n-b)-\tfrac{a+b+(n-b)+(m-a)}{4})^2+((m-a)-\tfrac{a+b+(n-b)+(m-a)}{4})^2 \\\\ \end{align*}

If you do out the partials (or use Wolfram Alpha) you get $$a=\frac{m}{2}$$ and $$b=\frac{n}{2}$$, and then you can solve for $$c=\frac{n}{2}$$ and $$d=\frac{m}{2}$$.

The problem is, when I test this out, I get a peculiar result. If I plug in $$x=100$$, $$y=0$$, and $$\omega=100$$, I get $$m=(200r-50)$$ and $$n=(200r+50)$$. So using my previously derived formulae, $$[a,b,c,d]=[100r-25,100r+25,100r+25,100r-25]$$ which works when plugged into the equations $$a+d=m$$ and $$b+c =n$$, but yields $$[x,y,\omega]=[50,50,100]\neq [100,0,100]$$. Are the steps to get (a+d) and (b+c) in terms of $$x$$, $$y$$, and $$\omega$$ not reversible? How can I attain my goal?

• You're going to have to have a time dependence in your wheels. If the robot rotates, $a$ is no longer aligned with the x-axis, for example... – HiddenBabel May 16 at 0:47
• I should have specified, but I just want x and y fixed to the robot... so the x, y, and $\omega$ are instantaneous and the x-y axes change moment to moment – Murey Tasroc May 16 at 1:02
• This article discusses how to do this relative to a fixed set of axes: researchgate.net/publication/… – Murey Tasroc May 16 at 1:03
• I was hoping to keep the axes relative because I ultimately want the robot to be able to turn around a point so I need $\omega$=x/R where R is the radius from the point to the center of the robot... assuming the y axis is pointed at the object – Murey Tasroc May 16 at 1:05
• I think this is better for the engineering site , there are various in stackechange. this is the general engineering.stackexchange.com – anna v May 16 at 4:22