View Single Post
  #5   Spotlight this post!  
Unread 19-02-2011, 16:23
sjspry sjspry is offline
Registered User
FRC #1984
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Kansas
Posts: 125
sjspry has a spectacular aura aboutsjspry has a spectacular aura aboutsjspry has a spectacular aura about
Re: how to program mecanum wheel drive?



That picture should make it fairly obvious. If not, look below. mainJoy is the one used for forward/back and strafing, rotJoy is used for rotation (pretty much like a FPS game, we even wired our camera's tilt up to rotJoy's Y axis so it is exactly like the usual FPS controls ) For best results, use an Xbox/PS3 controller. Remember forward is -1.

Assuming you get -1..1:

front_Left = -mainJoy.getY() - rotJoy.getX() + mainJoy.getX()
front_Right = -mainJoy.getY() + rotJoy.getX() - mainJoy.getX()

back_Left = -mainJoy.getY() - rotJoy.getX() - mainJoy.getX()
back_Right = -mainJoy.getY() + rotJoy.getX() + mainJoy.getX()