View Single Post
  #5   Spotlight this post!  
Unread 01-27-2010, 10:50 PM
oddjob oddjob is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Earth
Posts: 118
oddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to beholdoddjob is a splendid one to behold
Re: MECANUM WHEELS PROGRAMING

Quote:
Originally Posted by slavik262 View Post
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...
I could be wrong, but I don't think your code is optimum for a mecanum drive. Looking at the WPI code, nor is that.

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)
{
...
	magnitude = Limit(magnitude);
...
}

float RobotDrive::Limit(float num)
{
	if (num > 1.0)
	{
		return 1.0;
	}
	if (num < -1.0)
	{
		return -1.0;
	}
	return num;
}
If the joystick is moved far right and forwards, the HolonomicDrive method gives only 71% power (100%/sqrt(2)) to each wheel because it limits the magnitude to 1.0. That's not what I expect or want. Each wheel should be getting 100% power. It's not a big deal because I don't expect to be running the robot at full speed during this game and the difference between 71% and 100% power when moving diagonally is not something to go crazy over.
Reply With Quote