Go to Post One of the big things in FIRST is going global. - JosephC [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-10-2013, 10:05
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Maintaining perfect control of mecanums using encoders?

Hey! My team and I built a robot with mecanum wheels over the course of three days a few weeks ago, and right off the bat we had issues driving, because the motor controllers were extremely biased to move faster in one direction than the other. We solved this by running all of our motor outpute through these methods
Code:
	//motor speed control method
	public static float fix (float fixme) {
		return fixme < 0.00f ? 1.00f : 0.95f;
		//manipulates motor values based on direction only
	}
	
	//overload motor speed control method
	public static float fix (int motorID, float fixme) {
		if      (motorID == 1){ return (fixme < 0f)? 1:0.95f; }  //frontLeft
		else if (motorID == 2){ return (fixme < 0f)? 1:0.85f; }  //frontRight
		else if (motorID == 3){ return (fixme < 0f)? 1:0.75f; }  //backLeft
		else if (motorID == 4){ return (fixme < 0f)? 1:0.65f; }  //backRight
		else return 0;
		//manipulates motor values based on direction and ID (slower, more precise)
	}
At the competition last year, there were two or three teams using mecanum wheels, two of which said that they were using encoders to maintain perfect movement (probably also using PID loops...). I would like to learn how to do this. I have no idea where to begin, though, because mecanum wheels tend to spin in any direction at any speed depending on the actions being performed. Any ideas on how to do this would be greatly appreciated! Thanks!
  #2   Spotlight this post!  
Unread 02-10-2013, 10:11
buildmaster5000 buildmaster5000 is offline
Trying to program the swerve drive
AKA: Alex
FRC #2421 (Rolling Thunder Robotics)
Team Role: Alumni
 
Join Date: May 2009
Rookie Year: 2009
Location: Northern Virginia
Posts: 207
buildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud of
Re: Maintaining perfect control of mecanums using encoders?

Conceptually, the first thing to realize is that, without encoders, you are just setting a 'speed' value. You don't actually KNOW what speed the wheels are turning. The teams that you talked to really just used PID to control the actual speed (in rev/min) of the wheels. The first step is to figure out what speed you actually want the wheels to be going, then implement PID to get the wheel to that speed.
__________________
-Alex



2010 Washington DC Regional: Engineering Excellence Award
  #3   Spotlight this post!  
Unread 02-10-2013, 11:01
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Mentor, LRI, MN RPC
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,821
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Maintaining perfect control of mecanums using encoders?

Start by learning about PID... there's a good paper you can google, "PID without a PhD". Once you understand how it all works, implement it using the PIDController class. Basically, you set the various values, give it the input and output, and tell it how fast you want the motor to turn. If set up properly, it does the rest and "figures out" how fast to tell the controller to go in order to get the desired final speed, per the encoder feedback.

Also a small note... the bias you saw wasn't due to the controllers. It was caused by forward bias in the motors themselves. Every motor has a direction it "prefers" to travel in (based on the design of the motor). As a result, when you set up a robot so that driving forwards involves sending some motors in a clockwise fashion and some in a counter-clockwise fashion, even if you apply the exact same power to every motor you won't go perfectly straight.

For this reason, PID can be helpful with driving for all sorts of drive trains, not just Mecanum (although I think it's most noticeable with Mecanum).
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
  #4   Spotlight this post!  
Unread 02-10-2013, 11:21
BBray_T1296's Avatar
BBray_T1296 BBray_T1296 is offline
I am Dave! Yognaut
AKA: Brian Bray
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Rockwall, TX
Posts: 947
BBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond repute
Re: Maintaining perfect control of mecanums using encoders?

I think, more precisely, you are setting a 'power' value, less directly linked to speed than you need, which is the root of the problem. a motor will operate differently if it is trying to oppose your forward movement than add to it.

If you measured an unloaded CIM running at "50%" PWM, you will find it attains a RPM far greater than 1/2 of its RPM at 100% PWM, but with a loaded shaft, you can make a motor stall at 50% while it can still run at 100%.
Consequently, a robot moving forward and suddenly sliding left, will operate funny as several motors try to reverse direction and cant keep up (because of the opposing force [mainly inertia/momentum]) with motors continuing to spin forward (with far less opposing force)
This has a large effect, in addition to the above stated "motor preference"
Unfortunately I know next to nothing about software (a certain teammate of mine will attest to that), but I hope this makes sense as far as the problem is concerned.
__________________
If molecular reactions are deterministic, are all universes identical?

RIP David Shafer: you will be missed



Last edited by BBray_T1296 : 02-10-2013 at 11:23.
  #5   Spotlight this post!  
Unread 02-10-2013, 11:41
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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: Maintaining perfect control of mecanums using encoders?

Quote:
Originally Posted by BBray_T1296 View Post
I think, more precisely, you are setting a 'power' value,
Not really. More precisely, you are setting a PWM duty cycle value, which most closely correlates with applied voltage, not power.

Quote:
less directly linked to speed than you need, which is the root of the problem
True.

Quote:
If you measured an unloaded CIM running at "50%" PWM, you will find it attains a RPM far greater than 1/2 of its RPM at 100% PWM
In the above, are you referring to the duty cycle of the motor controller's output PWM, or the duty cycle of the PWM servo command signal coming into the motor controller?

If the former, what is your source for that claim?



Last edited by Ether : 02-10-2013 at 11:43.
  #6   Spotlight this post!  
Unread 02-10-2013, 13:54
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Maintaining perfect control of mecanums using encoders?

So from what I've read... you would need to write a some sort of control loop that takes the motor controller value (motor->Get() or the PWM signal somehow) and encoder reading as inputs (pidsource)? And then run them through... something. I read through "PID without a PhD" a couple of times...
  #7   Spotlight this post!  
Unread 02-10-2013, 14:24
BBray_T1296's Avatar
BBray_T1296 BBray_T1296 is offline
I am Dave! Yognaut
AKA: Brian Bray
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Rockwall, TX
Posts: 947
BBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond reputeBBray_T1296 has a reputation beyond repute
Re: Maintaining perfect control of mecanums using encoders?

Quote:
Originally Posted by Ether View Post
Not really. More precisely, you are setting a PWM duty cycle value, which most closely correlates with applied voltage, not power.
I concur. You said what I guess I should have said, and what I meant. Power is indeed another property altogether

Quote:
In the above, are you referring to the duty cycle of the motor controller's output PWM, or the duty cycle of the PWM servo command signal coming into the motor controller?
I was referring to the PWM signal exiting the sidecar (or what the code SAID was exiting the sidecar). We did some testing last year involving a CIM in a KOP CIMple box, (yeah it isn't free speed I know, but was otherwise unloaded) Victor 884, a Talon, some incremental software (push a button to add .1 to the PWM value), and a 120fps GoPro (encoders are too mainstream ).

We didn't test it while loaded but it is a fairly obvious observation that you need more "juice" when it is harder to move.
__________________
If molecular reactions are deterministic, are all universes identical?

RIP David Shafer: you will be missed


  #8   Spotlight this post!  
Unread 02-10-2013, 14:25
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 1,940
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: Maintaining perfect control of mecanums using encoders?

We have run mecanum for the last two years including using the wheels to Auto Aim the frisbee bot. Running completely open loop we have had no control issues to make us want to pursue PID. We are using the jaguars in the absolute voltage mode. But we didn't have issues before.

My point being you likely have other issues to fix before going the feedback route. Mechanically all for wheel need to have firm contact with the ground and as equally weighted as practical. Without your bot will not go straight with all 4 wheels turning the same speed.

Although you might get a little from manufacturing tolerances, CIMs don't have a bias for one direction or the other & should turn the same spreed given the same load & voltage.
  #9   Spotlight this post!  
Unread 02-10-2013, 15:54
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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: Maintaining perfect control of mecanums using encoders?

Quote:
Originally Posted by BBray_T1296 View Post
I was referring to the PWM signal exiting the sidecar (or what the code SAID was exiting the sidecar). We did some testing last year involving a CIM in a KOP CIMple box, (yeah it isn't free speed I know, but was otherwise unloaded) Victor 884, a Talon, some incremental software (push a button to add .1 to the PWM value), and a 120fps GoPro
Quote:
Originally Posted by BBray_T1296 View Post
If you measured an unloaded CIM running at "50%" PWM, you will find it attains a RPM far greater than 1/2 of its RPM at 100% PWM
Not to beat a dead horse, but are you saying that you observed ^this^ with a Talon as well as with the 884?

Team 1718 test, unloaded output voltage vs PWM command for 884 and Talon.

If you still have the actual data, would you please post it?

BTW, how did you use the GoPro to measure speed? At 5000/4.67 RPM, 1/120 of a second is 1/7 of a rev. Did you put a circular protractor on the output shaft?



Last edited by Ether : 02-10-2013 at 16:46.
  #10   Spotlight this post!  
Unread 02-10-2013, 15:56
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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: Maintaining perfect control of mecanums using encoders?

Quote:
Originally Posted by FrankJ View Post
My point being you likely have other issues to fix before going the feedback route.
^^This^^

Check all your rollers. Make sure they spin freely, even when axially loaded.


  #11   Spotlight this post!  
Unread 02-10-2013, 16:19
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Maintaining perfect control of mecanums using encoders?

Alternatively, Calibrate your motor controllers.

I've built mecanum powered robots before and never had any driveability issues with open loop. I could see wanting to close the loop in order to acheive accuracy in autonomous mode, maybe, but you shouldn't need it to be able to drive at all.
  #12   Spotlight this post!  
Unread 02-10-2013, 16:38
jvriezen jvriezen is offline
Registered User
FRC #3184 (Burnsville Blaze)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Burnsville, MN
Posts: 642
jvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond reputejvriezen has a reputation beyond repute
Re: Maintaining perfect control of mecanums using encoders?

We've also used open loop mecanum in 2011 and 2012, and had no issues worth addressing regarding wonky control.

Four wheels touching the floor with comparable force and correctly spinning rollers are important of course. We took care in design and construction to make that a non-issue. A suspension can help here. (We designed one with suspension, but due to issues removed the suspension)--- our well engineered wooden bot frame may have provided enough 'give' to allow more even weight distribution than a more rigid metal frame would have provided.

If things are noticeably misbehaving, I have my doubts that changing from open loop to PID will resolve everything.

Get four bathroom scales on a level floor so that the scale platforms are level with each other and see how much weight is on each wheel. Of course, if the scales are different models, their heights will be different, so you might have to shim some under the scale feet. If the scales aren't calibrated the same, you should be able to compensate by weighing 4 times, rotating the bot 90 degrees between weighings, Add up the 4 weighings for each wheel. We never actually did this with our bots, but that's because we didn't have issues with driving them as built.
__________________
John Vriezen
FRC, Mentor, Inspector #3184 2016- #4859 2015, #2530 2010-2014 FTC Mentor, Inspector #7152 2013-14
  #13   Spotlight this post!  
Unread 02-10-2013, 17:27
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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: Maintaining perfect control of mecanums using encoders?


The weight distribution matters only if:

1) one or more wheels loses traction because it has far less weight than the others

or

2) one or more of the wheels has significantly more rolling friction because of the extra weight


  #14   Spotlight this post!  
Unread 02-10-2013, 17:35
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Maintaining perfect control of mecanums using encoders?

Quote:
Originally Posted by Ether View Post
BTW, how did you use the GoPro to measure speed? At 5000/4.67 RPM, 1/120 of a second is 1/7 of a rev. Did you put a circular protractor on the output shaft?
Once, when we wanted to determine RPM from a video, we counted frames per revolution and divided that into frames per second. (Doing it over several revolutions gives a much more precise number.)
  #15   Spotlight this post!  
Unread 02-10-2013, 19:11
jbsmithtx's Avatar
jbsmithtx jbsmithtx is offline
FIRST Fanatic
AKA: Josh Smith
FRC #4206 (RoboVikes)
Team Role: Engineer
 
Join Date: Aug 2012
Rookie Year: 2012
Location: Fort Worth, TX
Posts: 91
jbsmithtx is a jewel in the roughjbsmithtx is a jewel in the roughjbsmithtx is a jewel in the rough
Re: Maintaining perfect control of mecanums using encoders?

Quote:
Originally Posted by Ether View Post

The weight distribution matters only if:

1) one or more wheels loses traction because it has far less weight than the others

or

2) one or more of the wheels has significantly more rolling friction because of the extra weight


So to create a balanced mecanum bot, we don't need a suspension? Because we definitely determined at the end of the year that this was the root of our problems...

Then again, we did have a few nasty hits, and I believe right now in our classroom we can rock the robot on the front left and rear right corners a wee bit...
Closed Thread


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


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

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