Log in

View Full Version : Best way to control the mechanum wheels


tomy
12-01-2011, 21:08
So I've heard that it's easier to control the robot with four mechunum wheels with an x-box controller. Is this true? If it is true how do you program that, because I'm our teams programmer?

davidthefat
12-01-2011, 21:16
First, before touching any code, write down everything on paper. Now I personally have no experience with mechanum drive, but I do have lots of experiences when the robot goes haywire because I used the wrong operation or something silly like that. Always double check before hitting "run".

I would say if the X axis (or what ever you are trying to control the strafing with) is past a certain point then switch to "strafing" mode. Then make the wheels rotate based on the x axis. Its quiet simple IMHO. I assume you would have the same code for the regular 4, 6, 8 wheel drive then tag on the strafing.

tomy
12-01-2011, 21:22
slow down there i forgot to say this our first year with mecanum wheels should we just stick to the basics with the joysticks?

Stephen of REX
12-01-2011, 21:25
You should use a joystick with a twist axis. Forward and back make the robot go forward and back, side to side makes it strafe, and twisting the joystick turns the robot. I have no idea about the programming though, I do mechanical/CAD.

davidthefat
12-01-2011, 21:26
slow down there i forgot to say this our first year with mecanum wheels should we just stick to the basics with the joysticks?

No, I say go for it bro. If you do not have the resources to build a prototype, I can make a software simulator for you. It won't be a robot driving on screen, but I can do motors on screen displaying its PWMs. First get the regular 4 wheel drive working with 1 joystick (the xbox controller in this case) then I will assist you with the mechanum drive. From the looks of it, its just the 4 wheel arcade with some extra

XaulZan11
12-01-2011, 21:27
Now I personally have no experience with mechanum drive

There are enough people here that do have experience with mechanum drive and have learned from those experiences. As it is with rules questions, only post when you are positive you are correct opposed to what you think is right. (I try to practice this and if you notice, I rarely, if ever, post in technical threads :o )

PS: for all I know, what you said was 100% correct and if so, I apologize.

EricH
12-01-2011, 21:28
slow down there i forgot to say this our first year with mecanum wheels should we just stick to the basics with the joysticks?
And you're starting during build?

Stick to the joysticks. There's prewritten code around somewhere; you would of course have to find it in your favorite language and tweak it for your robot.

I don't recommend doing mecanum in the six weeks if you haven't done it before; if you do it that way, KISS is a MUST. Start with stuff that's already out there.

David, you're close to right about the method, except that you forgot one thing: 4 independent motors vs 2 pairs of 2 motors. 2 pairs of 2 motors, you can Y-cable. 4 independent, it's a lot harder to Y-cable for some reason. Also use caution: Should you go to fallback (mecanum goes to 4WD rather easily), make sure you comment out the strafing--Alan Anderson of FRC45 found that out the hard way.

You could also do a complete directional program. That might be a bit harder.

tomy
12-01-2011, 21:39
My team really wants to do mecanum wheels... Anyone got any sample code for two joysticks+mecanum wheels?

3p1c w1n
12-01-2011, 23:00
This is my 2nd year programming and last year we had a basic 4 wheel drive. For this year the team has chosen to go with mecanum. I'm using labview. It would be awesome if someone could teach me the programming behind mecanum drive.

tomy
12-01-2011, 23:04
Im using c++ anyone got any good libraries?

KHall
12-01-2011, 23:05
Which develpment environment are you planning to use?

If its LabView, the VIs are all supplied. You'll have to do some problem solving to convert the joystick's output (or any other kind of steering device) to the inputs that the mechanum VI requires.

I can vouch for the LabView VI. We used it last year, it works great. And we've done mechanum wheels 3 of the last 5 years. Like anything else, there are tradeoffs to consider.

Keith Hall
Mentor FRC 2171, FLL 1528

davidthefat
12-01-2011, 23:07
Im using c++ anyone got any good libraries?

The only library allowed is the WPILib.

pfreivald
12-01-2011, 23:07
Last year we used mecanum to great success, using two joysticks. One joystick controlled movement direction, and the other controlled rotation -- exactly like a 1st person shooter played on Xbox.

While it wasn't an Xbox controller, our driver could think of it as one, and he had an intuitive knack for it very quickly.

tomy
12-01-2011, 23:10
So it's not hard to do it in c++?

davidthefat
12-01-2011, 23:12
So it's not hard to do it in c++?

No not at all, the mechanum drive would only take 5 lines MAX. (excluding the header file and PWM regulation)

tomy
12-01-2011, 23:15
Wow thanks I can wait to try it out

davidthefat
12-01-2011, 23:17
Wow thanks I can wait to try it out

Actually I lied, more like 8-10 but you get the point. Good luck, if you need any help ask.

JewishDan18
12-01-2011, 23:40
The algorithms for the speeds to drive each wheel are in white papers here, i'm sure. For omnidirectional drives, I like to use the setup with one joystick doing direction, plus one more axis doing turning. My team has found that twisting a stick makes it harder to drive. This setup is ideal for a game controller, which is quite trivial to program if you know how to do a normal joystick (see getRawAxis). If you are up to it, making the drive field-centric using a gyroscope makes it much more intuitive to drive.

EricH
13-01-2011, 02:00
The only library allowed is the WPILib.
Show me the rule, because I can't find that one in the Game Manual Section 4.

In 2008, I know I found a link to some "canned" mecanum code lying around CD. However, the programming language that year was C, so it wouldn't work this year without modification. I might be able to find it again... but it would take a while.

Mr. Lim
13-01-2011, 04:35
http://runnymede-robotics.googlecode.com/svn/trunk/2010_Team_1310_V2/

http://www.youtube.com/user/1310Robotics#p/u/0/7mBxVPvyYwQ

The Lucas
13-01-2011, 08:17
tomy,
For C++ (LV, & Java also) WPILib provides a couple Mecanum drive methods in the RobotDrive Class. I recommend you start out with MecanumDrive_Cartesian() function. Documentation of this function (generated using Doxygen on comments in WPILib) is provided online by Dustin Spicuzza of Team 2423 is here (http://www.virtualroadside.com/WPILib/class_robot_drive.html#a2e7fa1a9713332281012e8aae5 d9570e). It hasn't been updated since last Feb 5th but I dont expect any changes since then.

I don't know enough about how the left and right thumbsticks for the Xbox controller are mapped to axises in WPILib to give you a specific call. However, my suggestion is if you have a driver with experience on an Arcade Drive (single joystick for 4wd or 6wd) then use one thumbstick for y and rotation parameters in MecanumDrive_Cartesian() and the x-axis of another thumbstick for x. With this configuration, the driver can use one thumbstick to drive like the arcade drive (that they are experienced with) and add strafing with the other thumbstick. If you do not have experienced driver then decide which thumbstick mapping you think is best.

I encourage you to develop advanced features like the ones in Team 1310's code above once you are comfortable with Mecanum. The MecanumDrive_Cartesian() should be all you need to protoype the Mecanum and start training drivers. If you need any help initializing the RobotDrive with your 4 motors or anything else, just ask and I am sure someone on this forum will help ASAP

Good Luck

efoote868
13-01-2011, 10:11
Grab a sheet of paper and a writing utensil, hook up your controller to the robot's controller, and use labview to output all inputs to the screen. Write down what inputs are where.

For mecanum drive, we have always found its best to separate twist from your cardinal directions, make it the x-axis of a separate joystick. Some 3-axis joysticks have a tendency to twist while moving any other direction.

Another thing you should seriously consider doing with mecanum drive is field-centric positioning with a gyro. It takes a little extra trigonometry, a little extra debugging, but it makes driving the robot SO much easier. In my experience, anyone could drive this type of robot without any training at all, and do it very well. I'd like to think 868's success last year was in part due to this.

Let us know if you need help getting set up with that, I may have my old tutorials lying around.

Alan Anderson
13-01-2011, 13:40
The only library allowed is the WPILib.

I'm not aware of that restriction. Where did you find it?

Alan Anderson
13-01-2011, 13:44
Grab a sheet of paper and a writing utensil, hook up your controller to the robot's controller, and use labview to output all inputs to the screen. Write down what inputs are where.

If you're not adept with LabVIEW, you can easily use the Game Controllers control panel in Windows to see what physical bits and bobs correspond to which axis and button numbers.

Nemo
13-01-2011, 16:04
You get a holonomic drive VI with the Labview libraries. All you have to do is plug your three joystick axes into that VI, and it gives you the output levels for each of the four drive motors.

davidthefat
13-01-2011, 19:26
Show me the rule, because I can't find that one in the Game Manual Section 4.

In 2008, I know I found a link to some "canned" mecanum code lying around CD. However, the programming language that year was C, so it wouldn't work this year without modification. I might be able to find it again... but it would take a while.

I'm not aware of that restriction. Where did you find it?

I thought wrong then. So ,in the off season, technically I can spend my time writing my own library that would directly communicate with the FPGA or even modifying the FPGA to run my own library?

Greg McKaskle
13-01-2011, 19:36
During the season, or in the offseason, you can modify, rewrite, or replace any of the libraries above the FPGA access libraries. Since writing that from scratch would literally take you years, may I suggest learning to read the code that is there.

FYI, one of my biggest turn-offs when interviewing job candidates is the NIH syndrome. NIH == Not Invented Here. It seems to be a phase all programmers and engineers go through, but almost nobody is productive enough to be able to compete well until they get over it. Learn to read, debug, analyze, criticize, praise, understand, extend, and communicate the designs of others. It will serve you well.

You cannot modify the FPGA. That would remove the ability for FIRST to control the outputs and provide a safe experience for team members, volunteers, etc.

Greg McKaskle

Jogo
13-01-2011, 22:33
Seems like a lot of teams (ours included) are giving mecanum a shot this year. Here are a few things I've picked up...

-Basic mecanum is pretty easy to achieve using the built in "holonomic drive" function, which either taken in 3 axis values (x=strafe,y=fwd/rev,z=rotation) or a polar coordinate (magnitude and direction). The derived equations are based on the solution to the Inverse Kinematics Problem (see: http://www.simbotics.org/files/first-robotics-canada/workshop-presentations/omnidirectional.pdf).

-There are various ways to taken in inputs. One method is a twisting joystick. Another method is using two joysticks--one for x and y translation, and one for rotation. A final method is a joystick and two buttons--the joystick handles translation, and the two buttons handle left and right rotation at constant speed.

-To make mecanum better, use closed-loop control on the robot's header angle and/or wheel speeds. This can be accomplished with a gyro and encoders.

-To make mecanum better better, you can consider driver-centric control. This means that, no matter what the robot's header angle is, pushing the joystick away from you means that the robot moves away from you. This can be best accomplished by using the Polar coordinates implementation of mecanum, and using the gyro angle to modify the angle.

-To make mecanum better better better, consider using steering curves (see: http://www.chiefdelphi.com/media/papers/2421).

kinganu123
13-01-2011, 23:36
mecanum wheels were so much fun using last year
if you'd like to see how we used it in our labview code, just download our code
See attachment from this thread
http://www.chiefdelphi.com/forums/showthread.php?t=87949