![]() |
MECANUM WHEELS PROGRAMING
hi
i have a problime understanding the concept of mecanums wheels' programing .. i mean there the magnitute .. direction ... which i don't get .... so please help me ... dona |
Re: MECANUM WHEELS PROGRAMING
Think of a vector. It has a magnitude and a direction. The magnitude is between 0 and 1 how fast to move, and the direction is in degrees. These two parameters are for translational movement. For rotation, you can spin in place or spin and translate at the same time... the range is -1 to 1 for counter-clockwise and clockwise rotation.
|
Re: MECANUM WHEELS PROGRAMING
These are the important parts to get started. We don't have a chassis yet, but we wired up 4 Jaguars and 4 motors and the motors move as they should:
Code:
RobotDrive *mecanumDrive; |
Re: MECANUM WHEELS PROGRAMING
I'd assume that GetTwist() gets the z-axis value, which for the KOP joysticks is the throttle at the bottom of it.
Also, this thread is from a year ago, but I created a custom joystick class for use in omni-directional drive trains: http://www.chiefdelphi.com/forums/sh...ad.php?t=70468 Correct me if I'm wrong, but I believe GetMagnitude() just takes the square root of the squares of the x and y factors of the joystick to get its value (the Pythagorean Theorem approach). This is flawed in that due to special right triangles, sticking the joystick in the corner of its field of motion will generate a magnitude sqrt(2) larger than sticking the joystick all the way to a side. I created my own algorithm which "normalizes" the magnitude of the joystick vector so that it has a max value of 1 all the way around its bounds. Details are in the linked thread. I wrote the OmniJoystick class before I knew about function overloading and inheritence, so to make life simpler you can change GetAngle() and GetR() in the my code to GetMagnitude() and GetDirectionDegrees() if you'd rather use the "official" function names. |
Re: MECANUM WHEELS PROGRAMING
Quote:
If I push the joystick all the way to the right and forwards, the magnitude is 1.414 and the angle is 45 degrees. (maybe it's -45 degrees with the joystick defaults, but the idea is the same). If those magnitude and direction values are entered into the HolonomicDrive method, the inference is that I want to move forwards and to the right at 100% speed for both, so all wheels get 100% power with appropriate direction for each to make the chassis move diagonally as fast as it can. Looking at the WPI HolonomicDrive code, that's not what I get: Code:
void RobotDrive::HolonomicDrive(float magnitude, float direction, float rotation) |
Re: MECANUM WHEELS PROGRAMING
We do not use the code from WPI. I and my students have written our own. We did this so they understand how it works. When carbbing the opposite corners move in the same way. When turning the sides move together.
You the function below once for each wheel to get the wheels power. It works very well and is easly understood. It assumes that forward is 1.0, back is -1.0, crab left is 1.0, right is -1.0, turn to left is 1.0 and right is -1.0. The joystick values are assigned when we read in the DS values. They may need to be reversed via negation. We also may need to negate again when we assign the values to motors. (left vs right side) Right now the rotation seems backwards and may be the result of us switching front to back but for now it works great. We do it this way so we can use the same code in autonomous. We just pass in the values we want in the auto code and it all works great. Code:
float LC2010::GetMecanumPower( int i_wheel, float f_direction, float f_power, float f_turn ) |
Re: MECANUM WHEELS PROGRAMING
Quote:
http://www.chiefdelphi.com/forums/sh...ad.php?t=81025 ~ |
Re: MECANUM WHEELS PROGRAMING
I took a closer look at the WPI HolonomicDrive code. If the joystick is pushed full forwards (magnitude 1.0, direction 90 degrees) the drive wheels get only 71% power due to the sin and cos of (direction+/-45degrees) functions. The WPI code trades off maximum power for directional control, which is certainly a valid solution but I have a different strategy :)
Quote:
|
Re: MECANUM WHEELS PROGRAMING
Quote:
http://www.chiefdelphi.com/forums/sh...ad.php?t=81025 ~ |
Re: MECANUM WHEELS PROGRAMING
This has been updated in WPILib and will be in the next update.
|
Re: MECANUM WHEELS PROGRAMING
Quote:
Which post are you replying to? There's no context, so it's not clear. Thanks. ~ |
Re: MECANUM WHEELS PROGRAMING
Quote:
+ Add a Cartesian implementation of the mecanum drive method. * Clean up the expressions in the polar mecanum drive method. * Replace the saturation approach with a normalization to prevent inconsistent wheel speed ratios. * Scale the magnitude by sqrt(2) to get full power along the axes. |
Re: MECANUM WHEELS PROGRAMING
Great work! Except now our robot won't have a power and pushing advantage over the other mecanum's using HolonomicDrive, LOL.
Quote:
|
Re: MECANUM WHEELS PROGRAMING
Quote:
http://www.chiefdelphi.com/forums/sh...ad.php?t=81025 suggests scaling by the largest magnitude when any magnitude exceeds 1, rather than scaling by a fixed scalar (ie sqrt(2)). the reason for doing so is explained in the post. your thoughts? ~ |
Re: MECANUM WHEELS PROGRAMING
Quote:
Can you just commit the RobotDrive changes to FIRSTForge? We would be happy to help test. :) |
| All times are GMT -5. The time now is 10:54 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi