Arcade and X-Arcade Drive using full range of joystick without clipping

I responded in a couple other topics about Arcade and X-Arcade drive code. I had intended to post some tables to visualize what is happening in the code but discourse does not make that easy. So I converted a spreadsheet to HTML & JavaScript. You can pull or download the html pages from GitHub here:

BTW, I’m sure I didn’t come up with the Arcade Drive equations. I remember seeing something like them a few years(?) back but it still took me a couple hours to figure out the math. If anyone knows who first came up with this please post (I didn’t see anything in my search).

Disclaimer: X-Arcade has not been tested on an actual robot, yet.

4 Likes

Well I found out how to add tables so I figured I’d put the Arcade drive equation here with the tables showing some values for different joystick positions. The X-Arcade tables are interactive so they are still in HTML form found at the github link above.

If using joy and/or motor ranges that are not -127 to 127 then the 127 in the equations changes to the joy value and the output value must be scaled to the motor range.

Arcade Drive Equations

Extrapolated from Arcade function
These equations are for Left Drive is normal and Right Drive is reversed
mSpeed is the Forward (and -Reverse) vector component due to Speed
mYaw is the Left (and -Right) vector component due to Yaw

mSpeed = Speed - (Speed*ABS(Yaw)/127)/2
mYaw = Yaw - (Yaw*ABS(Speed)/127)/2
L = mSpeed + mYaw
R = mSpeed - mYawm

mSpeed Values

null -127 -112 -96 -80 -64 -48 -32 -16 0 16 32 48 64 80 96 112 127
127 63.5 71 79 87 95 103 111 119 127 119 111 103 95 87 79 71 63.5
112 56 62.5 69.5 76.5 84 91 98 105 112 105 98 91 84 76.5 69.5 62.5 56
96 48 53.5 59.5 66 72 78 84 90 96 90 84 78 72 66 59.5 53.5 48
80 40 44.5 50 55 60 65 70 75 80 75 70 65 60 55 50 44.5 40
64 32 36 40 44 48 52 56 60 64 60 56 52 48 44 40 36 32
48 24 27 30 33 36 39 42 45 48 45 42 39 36 33 30 27 24
32 16 18 20 22 24 26 28 30 32 30 28 26 24 22 20 18 16
16 8 9 10 11 12 13 14 15 16 15 14 13 12 11 10 9 8
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-16 -8 -9 -10 -11 -12 -13 -14 -15 -16 -15 -14 -13 -12 -11 -10 -9 -8
-32 -16 -18 -20 -22 -24 -26 -28 -30 -32 -30 -28 -26 -24 -22 -20 -18 -16
-48 -24 -27 -30 -33 -36 -39 -42 -45 -48 -45 -42 -39 -36 -33 -30 -27 -24
-64 -32 -36 -40 -44 -48 -52 -56 -60 -64 -60 -56 -52 -48 -44 -40 -36 -32
-80 -40 -44.5 -50 -55 -60 -65 -70 -75 -80 -75 -70 -65 -60 -55 -50 -44.5 -40
-96 -48 -53.5 -59.5 -66 -72 -78 -84 -90 -96 -90 -84 -78 -72 -66 -59.5 -53.5 -48
-112 -56 -62.5 -69.5 -76.5 -84 -91 -98 -105 -112 -105 -98 -91 -84 -76.5 -69.5 -62.5 -56
-127 -63.5 -71 -79 -87 -95 -103 -111 -119 -127 -119 -111 -103 -95 -87 -79 -71 -63.5

mYaw Values

null -127 -112 -96 -80 -64 -48 -32 -16 0 16 32 48 64 80 96 112 127
127 -63.5 -56 -48 -40 -32 -24 -16 -8 0 8 16 24 32 40 48 56 63.5
112 -71 -62.5 -53.5 -44.5 -36 -27 -18 -9 0 9 18 27 36 44.5 53.5 62.5 71
96 -79 -69.5 -59.5 -50 -40 -30 -20 -10 0 10 20 30 40 50 59.5 69.5 79
80 -87 -76.5 -66 -55 -44 -33 -22 -11 0 11 22 33 44 55 66 76.5 87
64 -95 -84 -72 -60 -48 -36 -24 -12 0 12 24 36 48 60 72 84 95
48 -103 -91 -78 -65 -52 -39 -26 -13 0 13 26 39 52 65 78 91 103
32 -111 -98 -84 -70 -56 -42 -28 -14 0 14 28 42 56 70 84 98 111
16 -119 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 119
0 -127 -112 -96 -80 -64 -48 -32 -16 0 16 32 48 64 80 96 112 127
-16 -119 -105 -90 -75 -60 -45 -30 -15 0 15 30 45 60 75 90 105 119
-32 -111 -98 -84 -70 -56 -42 -28 -14 0 14 28 42 56 70 84 98 111
-48 -103 -91 -78 -65 -52 -39 -26 -13 0 13 26 39 52 65 78 91 103
-64 -95 -84 -72 -60 -48 -36 -24 -12 0 12 24 36 48 60 72 84 95
-80 -87 -76.5 -66 -55 -44 -33 -22 -11 0 11 22 33 44 55 66 76.5 87
-96 -79 -69.5 -59.5 -50 -40 -30 -20 -10 0 10 20 30 40 50 59.5 69.5 79
-112 -71 -62.5 -53.5 -44.5 -36 -27 -18 -9 0 9 18 27 36 44.5 53.5 62.5 71
-127 -63.5 -56 -48 -40 -32 -24 -16 -8 0 8 16 24 32 40 48 56 63.5

(L,R) Drive Values

null -127 -112 -96 -80 -64 -48 -32 -16 0 16 32 48 64 80 96 112 127
127 (0, 127) (15, 127) (31, 127) (47, 127) (63, 127) (79, 127) (95, 127) (111, 127) (127, 127) (127, 111) (127, 95) (127, 79) (127, 63) (127, 47) (127, 31) (127, 15) (127, 0)
112 (-15, 127) (0, 125) (16, 123) (32, 121) (48, 120) (64, 118) (80, 116) (96, 114) (112, 112) (114, 96) (116, 80) (118, 64) (120, 48) (121, 32) (123, 16) (125, 0) (127, -15)
96 (-31, 127) (-16, 123) (0, 119) (16, 116) (32, 112) (48, 108) (64, 104) (80, 100) (96, 96) (100, 80) (104, 64) (108, 48) (112, 32) (116, 16) (119, 0) (123, -16) (127, -31)
80 (-47, 127) (-32, 121) (-16, 116) (0, 110) (16, 104) (32, 98) (48, 92) (64, 86) (80, 80) (86, 64) (92, 48) (98, 32) (104, 16) (110, 0) (116, -16) (121, -32) (127, -47)
64 (-63, 127) (-48, 120) (-32, 112) (-16, 104) (0, 96) (16, 88) (32, 80) (48, 72) (64, 64) (72, 48) (80, 32) (88, 16) (96, 0) (104, -16) (112, -32) (120, -48) (127, -63)
48 (-79, 127) (-64, 118) (-48, 108) (-32, 98) (-16, 88) (0, 78) (16, 68) (32, 58) (48, 48) (58, 32) (68, 16) (78, 0) (88, -16) (98, -32) (108, -48) (118, -64) (127, -79)
32 (-95, 127) (-80, 116) (-64, 104) (-48, 92) (-32, 80) (-16, 68) (0, 56) (16, 44) (32, 32) (44, 16) (56, 0) (68, -16) (80, -32) (92, -48) (104, -64) (116, -80) (127, -95)
16 (-111, 127) (-96, 114) (-80, 100) (-64, 86) (-48, 72) (-32, 58) (-16, 44) (0, 30) (16, 16) (30, 0) (44, -16) (58, -32) (72, -48) (86, -64) (100, -80) (114, -96) (127, -111)
0 (-127, 127) (-112, 112) (-96, 96) (-80, 80) (-64, 64) (-48, 48) (-32, 32) (-16, 16) (0, 0) (16, -16) (32, -32) (48, -48) (64, -64) (80, -80) (96, -96) (112, -112) (127, -127)
-16 (-127, 111) (-114, 96) (-100, 80) (-86, 64) (-72, 48) (-58, 32) (-44, 16) (-30, 0) (-16, -16) (0, -30) (16, -44) (32, -58) (48, -72) (64, -86) (80, -100) (96, -114) (111, -127)
-32 (-127, 95) (-116, 80) (-104, 64) (-92, 48) (-80, 32) (-68, 16) (-56, 0) (-44, -16) (-32, -32) (-16, -44) (0, -56) (16, -68) (32, -80) (48, -92) (64, -104) (80, -116) (95, -127)
-48 (-127, 79) (-118, 64) (-108, 48) (-98, 32) (-88, 16) (-78, 0) (-68, -16) (-58, -32) (-48, -48) (-32, -58) (-16, -68) (0, -78) (16, -88) (32, -98) (48, -108) (64, -118) (79, -127)
-64 (-127, 63) (-120, 48) (-112, 32) (-104, 16) (-96, 0) (-88, -16) (-80, -32) (-72, -48) (-64, -64) (-48, -72) (-32, -80) (-16, -88) (0, -96) (16, -104) (32, -112) (48, -120) (63, -127)
-80 (-127, 47) (-121, 32) (-116, 16) (-110, 0) (-104, -16) (-98, -32) (-92, -48) (-86, -64) (-80, -80) (-64, -86) (-48, -92) (-32, -98) (-16, -104) (0, -110) (16, -116) (32, -121) (47, -127)
-96 (-127, 31) (-123, 16) (-119, 0) (-116, -16) (-112, -32) (-108, -48) (-104, -64) (-100, -80) (-96, -96) (-80, -100) (-64, -104) (-48, -108) (-32, -112) (-16, -116) (0, -119) (16, -123) (31, -127)
-112 (-127, 15) (-125, 0) (-123, -16) (-121, -32) (-120, -48) (-118, -64) (-116, -80) (-114, -96) (-112, -112) (-96, -114) (-80, -116) (-64, -118) (-48, -120) (-32, -121) (-16, -123) (0, -125) (15, -127)
-127 (-127, 0) (-127, -15) (-127, -31) (-127, -47) (-127, -63) (-127, -79) (-127, -95) (-127, -111) (-127, -127) (-111, -127) (-95, -127) (-79, -127) (-63, -127) (-47, -127) (-31, -127) (-15, -127) (0, -127)
2 Likes