Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Mecanum Drive (http://www.chiefdelphi.com/forums/showthread.php?t=94109)

davidthefat 29-03-2011 21:44

Re: Mecanum Drive
 
Quote:

Originally Posted by kinganu123 (Post 1047141)
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.

Gdeaver 29-03-2011 22:23

Re: Mecanum Drive
 
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?t...el_Pivot_Drive

yclee31 30-03-2011 00:52

Re: Mecanum 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 :)

MattC9 30-03-2011 01:01

Re: Mecanum Drive
 
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

Re: Mecanum Drive
 
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

Re: Mecanum Drive
 
Quote:

Originally Posted by davidthefat (Post 1047277)
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.

yclee31 30-03-2011 02:10

Re: Mecanum Drive
 
Quote:

Originally Posted by Ether (Post 1047148)
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

Re: Mecanum Drive
 
Quote:

Originally Posted by yclee31 (Post 1047286)
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.

yclee31 30-03-2011 02:17

Re: Mecanum Drive
 
Quote:

Originally Posted by davidthefat (Post 1047287)
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.

Ether 30-03-2011 09:22

Re: Mecanum Drive
 
Quote:

Originally Posted by yclee31 (Post 1047263)
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. 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.



Ether 30-03-2011 09:39

Re: Mecanum Drive
 
Quote:

Originally Posted by yclee31 (Post 1047286)
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.

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:

Code:

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:

Code:

setpoint = angle_error;
process_variable = 0;



Bryan Herbst 30-03-2011 09:59

Re: Mecanum Drive
 
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:
Code:

    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.

Ether 30-03-2011 10:29

Re: Mecanum Drive
 
Quote:

Originally Posted by Tanis (Post 1047341)
Below is the heart of the mecanum code that 2052 has been using for 4 years now:
Code:

    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:

Code:

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

Re: Mecanum Drive
 
Quote:

Originally Posted by Ether (Post 1047349)
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.

Ether 30-03-2011 11:21

Re: Mecanum Drive
 
Quote:

Originally Posted by Alan Anderson (Post 1047354)
You changed the signs of everything except the velocity component.

Yes, I know.

Quote:

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.




All times are GMT -5. The time now is 21:07.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi