Go to Post ...if the penalties were not significant and match-deciding then there would not be much incentive to pay attention to them, would there? - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 23-01-2010, 16:52
dona klarson dona klarson is offline
Registered User
no team
 
Join Date: Jan 2010
Location: ISRAEL
Posts: 5
dona klarson is an unknown quantity at this point
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
Reply With Quote
  #2   Spotlight this post!  
Unread 23-01-2010, 19:32
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
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.
Reply With Quote
  #3   Spotlight this post!  
Unread 25-01-2010, 09:27
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

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;
Joystick *Attack3Joystick;
...

mecanumDrive = new RobotDrive(1, 2, 3, 4);	// frontLeft, rearLeft, frontRight, rearRight
Attack3Joystick = new Joystick(1);
...

mecanumDrive->HolonomicDrive(Attack3Joystick->GetMagnitude(), Attack3Joystick->GetDirectionDegrees(), Attack3Joystick->GetTwist());
The kit of parts joysticks don't have a twist handle so I didn't test the twist (rotation).
Reply With Quote
  #4   Spotlight this post!  
Unread 26-01-2010, 11:18
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
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.
__________________
Reply With Quote
  #5   Spotlight this post!  
Unread 27-01-2010, 22:50
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
  #6   Spotlight this post!  
Unread 28-01-2010, 05:01
pafwl pafwl is offline
Franciose
AKA: Frank Larkin
FRC #0272 (Cyber Crusaders)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 1998
Location: Lansdale, Pennsylvania
Posts: 108
pafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud of
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 ) 
{
	float retValue = 0.0;

	switch( i_wheel )						// Apply Forward and side motion
	{
		case LC2010::kMecanumLeftFront:
		case LC2010::kMecanumRightRear:
			retValue =  f_power - f_direction;
			break;

		case LC2010::kMecanumLeftRear:
		case LC2010::kMecanumRightFront:
			retValue =  f_power + f_direction;
			break;
		
		default:
			printf("GetGetMacannumMotorValue: Bad Wheel passed....\r");
			break;
	}

	switch( i_wheel )						// Apply the rotation
	{
		case LC2010::kMecanumLeftFront:
		case LC2010::kMecanumLeftRear:
			retValue += f_turn;				// retValue - f_turn;
			break;

		case LC2010::kMecanumRightFront:
		case LC2010::kMecanumRightRear:
			retValue -= f_turn;				//retValue + f_turn;
			break;
	
		default:
			printf("GetMacannumPower: Bad Wheel passed....\r");
			break;
	}


	if( retValue < -1.0) 								// condition before recasting to unsigned char
		retValue = -1.0;

	if( retValue > 1.0 ) 
		retValue = 1.0; 

	return retValue; 
};
Reply With Quote
  #7   Spotlight this post!  
Unread 28-01-2010, 11:52
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: MECANUM WHEELS PROGRAMING

Quote:
Originally Posted by pafwl View Post
We do not use the code from WPI....
See post number 9 in the following thread:

http://www.chiefdelphi.com/forums/sh...ad.php?t=81025


~
Reply With Quote
  #8   Spotlight this post!  
Unread 28-01-2010, 16:13
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

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:
Originally Posted by Ether View Post
See post number 9 in the following thread:
http://www.chiefdelphi.com/forums/sh...ad.php?t=81025
Reply With Quote
  #9   Spotlight this post!  
Unread 28-01-2010, 16:42
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: MECANUM WHEELS PROGRAMING

Quote:
Originally Posted by oddjob View Post
The WPI code trades off maximum power for directional control, which is certainly a valid solution but I have a different strategy
I think you can have your cake (max power) and eat it too (correct direction), by using the scaling technique suggested in post number 9 in the following thread:

http://www.chiefdelphi.com/forums/sh...ad.php?t=81025


~
Reply With Quote
  #10   Spotlight this post!  
Unread 28-01-2010, 18:21
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: MECANUM WHEELS PROGRAMING

This has been updated in WPILib and will be in the next update.
Reply With Quote
  #11   Spotlight this post!  
Unread 28-01-2010, 20:29
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: MECANUM WHEELS PROGRAMING

Quote:
Originally Posted by jhersh View Post
This has been updated in WPILib and will be in the next update.
What does the pronoun "this" refer to?

Which post are you replying to?

There's no context, so it's not clear.

Thanks.

~
Reply With Quote
  #12   Spotlight this post!  
Unread 29-01-2010, 01:03
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: MECANUM WHEELS PROGRAMING

Quote:
Originally Posted by Ether View Post
What does the pronoun "this" refer to?

Which post are you replying to?

There's no context, so it's not clear.
Here is the change list description:

+ 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.
Reply With Quote
  #13   Spotlight this post!  
Unread 29-01-2010, 01:10
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

Great work! Except now our robot won't have a power and pushing advantage over the other mecanum's using HolonomicDrive, LOL.

Quote:
Originally Posted by jhersh View Post
Here is the change list description:

+ 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.
Reply With Quote
  #14   Spotlight this post!  
Unread 29-01-2010, 01:16
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: MECANUM WHEELS PROGRAMING

Quote:
Originally Posted by jhersh View Post
* Scale the magnitude by sqrt(2) to get full power along the axes.
The approach suggested in post number 9 in the following thread:

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?

~
Reply With Quote
  #15   Spotlight this post!  
Unread 29-01-2010, 01:18
Abrakadabra Abrakadabra is offline
Here We Go !!!
AKA: Scott Kukshtel, Mr. K
FRC #3467 (The Windham Windup!)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2002
Location: Windham, New Hampshire
Posts: 159
Abrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant futureAbrakadabra has a brilliant future
Re: MECANUM WHEELS PROGRAMING

Quote:
Originally Posted by jhersh View Post
This has been updated in WPILib and will be in the next update.
<baited_breath> So when do we get this next update you speak of? </baited_breath>

Can you just commit the RobotDrive changes to FIRSTForge? We would be happy to help test.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mecanum Wheels? Maxpower57 Kit & Additional Hardware 17 17-03-2008 16:50
Mecanum Wheels Calvin_1631 Motors 7 09-02-2007 13:29
4 encoders + mecanum wheels programing Smoking_Gun Programming 4 18-01-2007 23:43
Friction coefficients for Omni wheels and Mecanum wheels from AndyMark Andy Baker Technical Discussion 11 16-12-2006 19:40
Mecanum Wheels TheFerret Technical Discussion 8 16-01-2006 09:23


All times are GMT -5. The time now is 14:09.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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