I am trying to control the Rover 5 robot using an Android app with a touch-based joystick control in the app UI. I want to calculate the speed of the left and right motors in the rover when joystick is moved.
From the joystick, I get two values, pan and tilt. I convert them into the polar coordinate system with r
and theta
. Where r ranges from 0 to 100 and theta from 0 to 360. I want to derive an equation which can convert the (r, theta)
to (left_speed, right_speed)
for rover. The speed values also are in the [0;100] range.
Now, here is what I have figured out till now. For any value of r
,
If theta = 0
then left_speed = r, right_speed = -r
(turning right on spot)
If theta = 90
then left_speed = r, right_speed = r
(moving forward at speed r)
If theta = 180
then left_speed = -r, right_speed = r
(turning left on spot)
If theta = 270
then left_speed = -r, right_speed = -r
(moving backwards at speed r)
For other values, I want it moving and turning simultaneously. For example,
If theta = 45
then left_speed = alpha*r, right_speed = beta*r
(moving forward while turning right)
So, basically for any (r, theta)
, I can set speeds as,
(left_speed, right_speed) = (alpha*r, beta*r)
I need to formulate an equation where I can generalize all these cases by finding alpha
and beta
based on theta
.
How can I do this? Is there is any existing work I can refer to?