View Full Version : Mecanum Drive
So I'm planning on using the mecanum drive system for next year.
and just to get a head start, i want to start coding now.
so what is a basic structure for omni-system drive?
if you guys give me some helpful advice and pseudo code
and also some help on correcting human errors and all
i will be thankful haha :)
davidthefat
28-03-2011, 20:21
Come talk to me during snack.
MagiChau
28-03-2011, 20:26
Come talk to me during snack.
You guys gets snack time? Time to start that on my team. :D
Why in the world are you planning on using one type of a drive system for next year?
There are teams that will laugh at Mecanum regardless of the game. Some pull it off with the right implementation, but I don't think you should say you're planning on using Mecanum for next year.
If it's for educational purposes, sure, we'll help you out...
I'm not just saying, just sayin'
davidthefat
28-03-2011, 20:32
Why in the world are you planning on using one type of a drive system for next year?
There are teams that will laugh at Mecanum regardless of the game. Some pull it off with the right implementation, but I don't think you should say you're planning on using Mecanum for next year.
If it's for educational purposes, sure, we'll help you out...
I'm not just saying, just sayin'
He just wants to do it for educational purposes from what I can see. There was no actual decision made. We were considering experimenting with several different drive systems. Swerve being one of them. I don't know why he has not come up and asked me for help... -__-;; But I will talk to him tomorrow.
By the way, he has no power what so ever to make such drastic decisions. Even I do not have such powers. I can convince, but not mandate what drive we should use.
Andrew Schreiber
28-03-2011, 20:34
You guys gets snack time? Time to start that on my team. :D
I wish we got snack time... it should be right after the nap time I wish we got.
Why in the world are you planning on using one type of a drive system for next year?
There are teams that will laugh at Mecanum regardless of the game. Some pull it off with the right implementation, but I don't think you should say you're planning on using Mecanum for next year.
If it's for educational purposes, sure, we'll help you out...
I'm not just saying, just sayin'
Ignoring the last sentence... THIS! Saying that would be like saying "I'm going to use an elevator." You COULD do it but it may not be the best option.
Now, having it in your bag of tricks is nice so for an off season project? Go For It!
What do you mean by the last sentence?
wilsonmw04
28-03-2011, 20:37
I'm not just saying, just sayin'
What are you trying to say?
Why in the world are you planning on using one type of a drive system for next year?
There are teams that will laugh at Mecanum regardless of the game. Some pull it off with the right implementation, but I don't think you should say you're planning on using Mecanum for next year.
If it's for educational purposes, sure, we'll help you out...
I'm not just saying, just sayin'
i dont have any knowledge on coding omni system drive so i was asking for help
we did not decide anything on next years drive and my team's adviser allowed me to play with some drives so i was just asking :)
i guess my word choice was bad :P
i dont have any knowledge on coding omni system drive so i was asking for help
Home brew:
http://www.chiefdelphi.com/media/papers/download/2906
Or use the provided mecanum drive in the WPI Library.
nahstobor
28-03-2011, 21:03
Have mecanum wheels ever touched Einstein?
Robby Unruh
29-03-2011, 20:26
Have mecanum wheels ever touched Einstein?
I think it was 294 last year who had mecanum wheels on Einstein.
Are team has used mecanum for the last 2 years, never again. Look in to swerve if anything but as an off season project GO for it!!! it will be a fun programming challenge plus there reallllyyyyyy fun to drive up and down the hall ways (we take our 2011 robot out and do figure-8's during lunch)
r2davis2
29-03-2011, 20:47
I think it was 294 last year who had mecanum wheels on Einstein.
Sorry to tell you, but 294 used our favorite 6 wheel drop-center shifter drive-train last year (this year as well). To my knowledge we have never done any strange kind of drive-train, though we did do a weird semi-holonomic system for Lunacy
As far as I know mecanum has never shown up on Einstein, but I could very well be wrong
kinganu123
29-03-2011, 21:24
its actually relatively simple, assuming u know trig
Essentially what need to be done is get the direction based upon a 180 degree circle, find the vectors, multiply it by the magnitude of the joystick, and then finally adding or subtracting the rotation
its actually relatively simple, assuming u know trig
It's simpler than you think. Mecanum requires no trigonometry.
davidthefat
29-03-2011, 21:44
its actually relatively simple, assuming u know trig
Essentially what need to be done is get the direction based upon a 180 degree circle, find the vectors, multiply it by the magnitude of the joystick, and then finally adding or subtracting the rotation
I would say you only need 3 if statements. One for strafing, another for the "deadzone" and the last for turning.
For an off season project, if you have some tetrix or vex metal laying around from the mini bot effort, you could get these wheels and test it out.
http://www.sparkfun.com/products/10543
Drive them with the smoked motors that can be repaired. Your team has a few don't they? When our team decided that we were serious about swerve, we built a vex swerve proto type with a c-rio controller on it. It was a really good learning experience.
http://wiki.team1640.com/index.php?title=4-Wheel_Pivot_Drive
so can you guys give me some pseudo code for mecanum and swerve drive?
mecanum, im getting some idea and i think i can do it but swerve.. i have no idea how i should even start coding that thing. all i want is basic structure of those drive system and how pwm feed should be from joystick, etc. thank you :)
Talk to your team also to get input on this very abtuious project you want to embark on! But you should use CAN to connect your jags it updates muchhhh faster and allows for a much smoother mecanum drive and swerve drive, If you have any can questions pm me.
davidthefat
30-03-2011, 01:14
Oh man... Stick with trying to get mecanum done. I already told you enough. I don't want to spoon feed you anything.
Andrew Schreiber
30-03-2011, 01:27
Oh man... Stick with trying to get mecanum done. I already told you enough. I don't want to spoon feed you anything.
OFF TOPIC POST COMING YOU HAVE BEEN WARNED!
Time we have a chat about helping teammates learn.
Some people learn best by being pointed in a direction and being told make a mess. Some people don't learn this way. Some people need lots of direction and support. It is up to you to learn which way is most effective.
It's simpler than you think. Mecanum requires no trigonometry.
loving to hear that and i think mecanum wont be that hard
but swerve... with servo feed over rotation of the wheel and also feeding the pwm is like..
ok pwm i just feed the scalar value for joystick but for servo how should i get the right angles and all those junks like ughh
davidthefat
30-03-2011, 02:14
loving to hear that and i think mecanum wont be that hard
but swerve... with servo feed over rotating the feed and pwm is like
ok pwm i just feed the scalar value for joystick but for servo how should i get the right angles and all those junks like ughh
PID Loop; let's talk in front of the white board tomorrow.
PID Loop; let's talk in front of the white board tomorrow.
i just talked to sam about it. he think using pid with absolute encoder or range finder would be best.
and i was asking for getting the angle not pid.
so can you guys give me some pseudo code for mecanum and swerve drive?
mecanum, im getting some idea and i think i can do it but swerve.. i have no idea how i should even start coding that thing. all i want is basic structure of those drive system and how pwm feed should be from joystick, etc. thank you :)
Mecanum code is in the WPI Library for all 3 FRC-supported languages. Just feed your joystick values to it and set whatever options you want (like using the gyro for field-centric control). If you want to understand the theory or write your own code, just search the CD papers for keyword mecanum.
Converting 3-degree-of-freedom joystick commands into holonomic values for wheel speed and wheel steering angle for swerve drive is straightforward (http://www.chiefdelphi.com/media/papers/download/3028). The challenge is downstream from there: how to actually control the wheels once you've calculated what their speeds and angles should be. These control algorithms may include logic to filter the commands to prevent undesired (but theoretically legal) commands to, for example, suddenly turn the wheels 90 degrees from the present high-speed direction. Many teams also implement driver interfaces which simplify the presentation to the driver in terms of more familiar and intuitive control. There are many different ways to do this; each team seems to have their own preferred approach.
but swerve... how should i get the right angles and all those junks like ughh
Let wheel_angle_command be the desired wheel angle calculated based on the driver inputs (http://www.chiefdelphi.com/media/papers/download/3028).
Let measured_wheel_angle be the value read from your wheel angle sensor.
Assuming both read degrees clockwise and are zeroed at the same angular position, the code for finding the shortest-path clockwise angle error is:
angle_error = wheel_angle_command - measured_wheel_angle;
angle_error -= 360*floor(0.5+angle_error/360);
If you are writing your own PID, use that angle_error.
If you are using a canned PID (from e.g. the WPI Library) you will need to convert that angle_error to a setpoint and a process_variable. You can do it like so:
setpoint = angle_error;
process_variable = 0;
Bryan Herbst
30-03-2011, 09:59
As adorable as your team chats are, I would recommend you keep them at meetings ;)
Below is the heart of the mecanum code that 2052 has been using for 4 years now:
wFL = velocity - rotation - strafe;
wFR = velocity + rotation + strafe;
wRL = velocity - rotation + strafe;
wRR = velocity + rotation - strafe;
Where velocity and rotation are the y-axis and x-axis (respectively) of one joystick, and strafe is the x-axis of another.
For whatever reason, we have never used WPI's or Labview's built in mecanum functions. Possibly because we have been using mecanum since the IFI controller.
While mecanum requires no trig or high level math to implement, it does require physics to understand. Understanding the force vectors that allow the wheels to strafe makes it even more fascinating, and sharing the knowledge of how it works would be a great team meeting.
Below is the heart of the mecanum code that 2052 has been using for 4 years now:
wFL = velocity - rotation - strafe;
wFR = velocity + rotation + strafe;
wRL = velocity - rotation + strafe;
wRR = velocity + rotation - strafe;
Where velocity and rotation are the y-axis and x-axis (respectively) of one joystick, and strafe is the x-axis of another.
A note to readers: with the above code, the calculated motor commands must be inverted in software OR the motors must be wired to spin in the "backwards" direction when a positive wheel speed command is sent to the motor controllers.
An alternate approach which may be more intuitive to some is to invert the joystick Y-axis value to produce a positive command for forward motion, and revise the wheel speed calculation like so:
front_left = forward + clockwise + right;
front_right = forward - clockwise - right;
rear_left = forward + clockwise - right;
rear_right = forward - clockwise + right;
This will produce positive wheel speed commands where positive means spin the wheel "forward".
Alan Anderson
30-03-2011, 10:47
You must be inverting the signs somewhere else in the code (or the motor wiring)...
You changed the signs of everything except the velocity component. Tanis is working directly with the joystick axis values, not with abstracted "forward" and "clockwise" and "right" values. Since the Y axis is negative for forward, what he posted and what you posted differ only in the sign of the result. The choice of which direction to wire the motor is essentially arbitrary, so there's no practical difference between the two.
I think the IFI joystick axes were actually "forward is higher value" and "right is lower value", so 2052's original code ends up matching your kinematics exactly.
You changed the signs of everything except the velocity component.
Yes, I know.
Since the Y axis is negative for forward, what he posted and what you posted differ only in the sign of the result. The choice of which direction to wire the motor is essentially arbitrary, so there's no practical difference between the two.
The choice is indeed arbitrary. The practical difference might be that some choices might be clearer to persons new to this (as in this thread).
In the code Tanis posted, the "velocity" command would be negative when you want the wheels to spin in the forward direction.
Alan Anderson
30-03-2011, 13:06
In the code Tanis posted, the "velocity" command would be negative when you want the wheels to spin in the forward direction.
You're apparently coming at this from an academic perspective rather than a practical one. The posted code might look "backwards" to you, but it's exactly the way it should be. That's because of how USB joysticks -- and the FRC control system -- work: forward is negative. It's an annoying standard from a wheeled vehicle point of view, but it's quickly learned.
You're apparently coming at this from an academic perspective rather than a practical one. The posted code might look "backwards" to you, but it's exactly the way it should be.
I think we agree on this: the code Tanis posted can be made to work by inverting the motor commands after they've been calculated or by wiring the motors so that a positive command to the motor controller produces a backwards wheel speed.
Whether or not it "should" be done this way is certainly arguable.
For some people, it might be considerably more intuitive to invert the Y-axis value to make it positive for forward motion, and use equations which produce a positive wheel speed command when the wheel needs to spin in the forward direction.
I have edited my earlier post to remove the word "should" from it and to better convey the point.
I think it was 294 last year who had mecanum wheels on Einstein.
Nope... we were 6 wheeled Tank driven.. Probably will be for many more years to come..
Edit: saw that my student lead already posted... nicely done Alex..
Alan Anderson
30-03-2011, 14:28
I think we agree on this: the code Tanis posted can be made to work by inverting the motor commands after they've been calculated or by wiring the motors so that a positive command to the motor controller produces a backwards wheel speed.
The thing is, a positive input to a WPI drive function does represent a backwards wheel speed.
For some people, it might be considerably more intuitive to invert the Y-axis value to make it positive for forward motion,...
I agree completely. However, the WPI library was written to comply with the HID joystick standard, and not to invert the axis to make it more intuitive. If you invert it yourself, you'll have to invert it again before passing it to the arcade/tank/mecanum drive function, which expects the noninverted Y axis input. That ship has sailed (this year, at least).
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.