Go to Post The point is that while having the abiltity to find information in a variety of reference sources is a useful skill, it does not replace a good, complete, fundamental knowledge of your subject material. - dlavery [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 Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-03-2015, 12:57
microbuns's Avatar
microbuns microbuns is offline
Registered User
AKA: Sam Maier
FRC #4917
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Elmira
Posts: 81
microbuns is an unknown quantity at this point
Driving Straight With Encoders

How do you drive straight with a tank style drivetrain using encoders (no gyro)? Our bot has 2 wheels which each have identical encoders on them, but unfortunately one side has more friction than the other side.

Our best solution we have right now (which isn't amazing) is to have a speed PID controller on both sides, which ensures they are both going the correct speed relative to the floor. However, this doesn't always guarantee the wheels get up to speed in time - meaning one side may get as much as 2-3 inches ahead of the other while they are speeding up - this difference will be maintained as they stay at speed.

I was thinking about somehow trying to minimize the difference between the two sides' encoders, but I'm not exactly sure what/how to go about that. Do you just have some speed factor you add to one side and subtract to the other that scales off the difference of the two sides?
  #2   Spotlight this post!  
Unread 02-03-2015, 13:00
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,725
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Driving Straight With Encoders

Quote:
Originally Posted by microbuns View Post
How do you drive straight with a tank style drivetrain using encoders (no gyro)? Our bot has 2 wheels which each have identical encoders on them, but unfortunately one side has more friction than the other side.

Our best solution we have right now (which isn't amazing) is to have a speed PID controller on both sides, which ensures they are both going the correct speed relative to the floor. However, this doesn't always guarantee the wheels get up to speed in time - meaning one side may get as much as 2-3 inches ahead of the other while they are speeding up - this difference will be maintained as they stay at speed.

I was thinking about somehow trying to minimize the difference between the two sides' encoders, but I'm not exactly sure what/how to go about that. Do you just have some speed factor you add to one side and subtract to the other that scales off the difference of the two sides?
What language are you using?

Last year we read the values of the encoder and then used a PID controller with a setpoint of 0 and did as you said, added to one side and subtracted from the other. This can also be done using arcade style driving just just putting your PID output into the turn value.
  #3   Spotlight this post!  
Unread 02-03-2015, 13:19
microbuns's Avatar
microbuns microbuns is offline
Registered User
AKA: Sam Maier
FRC #4917
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Elmira
Posts: 81
microbuns is an unknown quantity at this point
Re: Driving Straight With Encoders

We are using C++.

How straight did you end up driving with that? We are looking for a maxiumum error of roughly 1:100 (ie 100 units forward gets you at worst 1 unit to the left or right) or ~0.5 degrees. Is that kind of precision you guys were seeing?
  #4   Spotlight this post!  
Unread 02-03-2015, 13:22
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,725
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Driving Straight With Encoders

Quote:
Originally Posted by microbuns View Post
We are using C++.

How straight did you end up driving with that? We are looking for a maxiumum error of roughly 1:100 (ie 100 units forward gets you at worst 1 unit to the left or right) or ~0.5 degrees. Is that kind of precision you guys were seeing?
I don't know the exact numbers, but we were able to grab multiple balls in every match last year.
  #5   Spotlight this post!  
Unread 02-03-2015, 13:51
JABot67 JABot67 is offline
Unregistered User
AKA: John Bottenberg
FRC #2930 (Sonic Squirrels)
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Redmond, WA
Posts: 328
JABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond reputeJABot67 has a reputation beyond repute
Re: Driving Straight With Encoders

Quote:
Originally Posted by microbuns View Post
I was thinking about somehow trying to minimize the difference between the two sides' encoders, but I'm not exactly sure what/how to go about that. Do you just have some speed factor you add to one side and subtract to the other that scales off the difference of the two sides?
This is a good approach. I've seen the following work pretty well:

Code:
// Set up drivePID as a PIDController with a custom PIDSource that
// calculates the distance between the encoders and outputs the result
// in PIDGet(). The PIDOutput doesn't matter and should be a dummy.

// In AutonomousInit
drivePID.Enable();

// In AutonomousPeriodic
drivePID.SetSetpoint(0);
double movement = someConstant;
double rotation = drivePID.Get();

drive.ArcadeDrive(movement, rotation, /*SquaredInputs=*/ false);
This is where drivePID is an instance of the PIDController class. The PIDController class is pretty obnoxious in that its source and output have to be of the types PIDSource and PIDOutput, respectively. This means that you (the FRC team) have to create a class that inherits from PIDSource which calculates the difference between two encoders and returns that in the virtual function PIDGet().

Gotta say, sometimes the flow of information in C++ is really hard to follow.
__________________
John Bottenberg - University of Michigan '14 - Microsoft
FLL Team "Dark Matter": 2003-2005
Robofest Team "Dark Matter": 2005-2008
Team 67 Programmer: 2007-2010
Team 3322 Programming Mentor: 2012-2014
Team 2930 Engineering Mentor: 2015-????

Last edited by JABot67 : 02-03-2015 at 14:03. Reason: Fix up the code
  #6   Spotlight this post!  
Unread 02-03-2015, 14:27
ToddF's Avatar
ToddF ToddF is offline
mechanical engineer
AKA: Todd Ferrante
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Apr 2011
Rookie Year: 2011
Location: Newport News, VA
Posts: 600
ToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond reputeToddF has a reputation beyond repute
Re: Driving Straight With Encoders

Keep in mind that if both sides turn the exact same amount, the robot will go straight, in theory ONLY. In the real world, tiny inconsistencies will prevent this from ever happening. Tiny perturbances lead to vastly varying results. Things like: wheels being slightly different diameters; slightly wrinkled carpeting; driving over a wire tie with one side, one side of the robot being heavier and sinking into the carpet more etc. Counting on dead reckoning for less than a 1" drift over 100" of travel seems iffy, even with perfect software. The actual physical environment just isn't that theoretically perfect.

For example, you might expect repeatability of a 4" diameter cast rubber wheel to be about +/-.020". If one side has wheels 3.98" and the other side has wheels 4.02" in diameter, if you tell the robot to drive 100" (7.958 revolutions of a 4.000" wheel) one side will travel 99.5 inches, and the other side will travel 100.5", and that's just one factor out of many that will cause drift. If you are lucky, all those factors will cancel each other out, but it's likely they won't.

I'm not trying to discourage you from implementing a purely encoder based solution. But you need to realize that even if your software is perfect, the robot may still not drive straight. You may need to add some other sensors to your control algorithm. This could be computer vision, keeping you headed exactly at your target. It could be a sideways looking distance sensor, keeping you driving parallel to a wall. It could be a highly accurate gyro telling you if you are drifting off course. Hopefully, you have a practice bot with which to experiment. If not, next summer is a great time for experimentation, so you have a thoroughly tested solution ready for next season.
__________________
Todd F.
mentor, FIRST team 2363, Triple Helix
Photo gallery
video channel
Triple Helix mobile
  #7   Spotlight this post!  
Unread 02-03-2015, 14:47
microbuns's Avatar
microbuns microbuns is offline
Registered User
AKA: Sam Maier
FRC #4917
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Elmira
Posts: 81
microbuns is an unknown quantity at this point
Re: Driving Straight With Encoders

Quote:
Originally Posted by ToddF View Post
Keep in mind that if both sides turn the exact same amount, the robot will go straight, in theory ONLY. In the real world, tiny inconsistencies will prevent this from ever happening. Tiny perturbances lead to vastly varying results. Things like: wheels being slightly different diameters; slightly wrinkled carpeting; driving over a wire tie with one side, one side of the robot being heavier and sinking into the carpet more etc. Counting on dead reckoning for less than a 1" drift over 100" of travel seems iffy, even with perfect software. The actual physical environment just isn't that theoretically perfect.

For example, you might expect repeatability of a 4" diameter cast rubber wheel to be about +/-.020". If one side has wheels 3.98" and the other side has wheels 4.02" in diameter, if you tell the robot to drive 100" (7.958 revolutions of a 4.000" wheel) one side will travel 99.5 inches, and the other side will travel 100.5", and that's just one factor out of many that will cause drift. If you are lucky, all those factors will cancel each other out, but it's likely they won't.

I'm not trying to discourage you from implementing a purely encoder based solution. But you need to realize that even if your software is perfect, the robot may still not drive straight. You may need to add some other sensors to your control algorithm. This could be computer vision, keeping you headed exactly at your target. It could be a sideways looking distance sensor, keeping you driving parallel to a wall. It could be a highly accurate gyro telling you if you are drifting off course. Hopefully, you have a practice bot with which to experiment. If not, next summer is a great time for experimentation, so you have a thoroughly tested solution ready for next season.
Thank you very much for this Todd. I do understand that it's almost impossible to drive straight with just encoders... However that's the situation the programmers on our team have been put on. Next year we're going to have to get this driving straight thing down earlier!

We do have a practice bot. I'm not sure how practical it is to try and implement something new completely to our bot, given time constraints. However I do think we will try the "keep encoder delta at 0" PID strategy.

Just out of curiosity - what is considered the "best" way to drive straight (assuming a tank drive bot and a moderate budget)? Would that be encoders + a gyro?
  #8   Spotlight this post!  
Unread 02-03-2015, 14:52
rich2202 rich2202 is offline
Registered User
FRC #2202 (BEAST Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 1,242
rich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond repute
Re: Driving Straight With Encoders

Quote:
Originally Posted by microbuns View Post
Just out of curiosity - what is considered the "best" way to drive straight (assuming a tank drive bot and a moderate budget)? Would that be encoders + a gyro?
Driving straight has always been a problem. Even with a gyro. We just received the navX board, and have high hopes. It should be able to tell you orientation of the bot, heading, and where you are so mid-course corrections can be made.

http://www.andymark.com/product-p/am-3060.htm
Andymark is supposed to be getting in more any day now.
  #9   Spotlight this post!  
Unread 02-03-2015, 15:38
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Driving Straight With Encoders

Providing your wheels don't slip, the change in heading of your robot is

heading_radians = (leftEncoderDistance - rightEncoderDistance)/TrackWidth

TrackWidth is the distance between the left and right wheels.

Wheel slip and other imperfections make the above heading calculation not perfect, but it's good enough to use in a PID loop to keep your robot driving straight.
__________________
-
An ounce of perception is worth a pound of obscure.
  #10   Spotlight this post!  
Unread 02-03-2015, 15:47
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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: Driving Straight With Encoders


Here's some info that may be of interest.

Drive straight with encoders:

http://www.chiefdelphi.com/forums/sh...89#post1446789

Use motion planning for best results:

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

http://www.chiefdelphi.com/forums/sh...d.php?t=134965

Do some simple system identification[1]. For example, take the wheel diameter problem Todd mentioned. Drive the vehicle in a straight line (by tweaking the left-right motor commands) and note the ratio of the left and right encoder values. Use that ratio to fudge your setpoints, or use it to fudge your encoder readings before using them as your process variable.

[1] http://en.wikipedia.org/wiki/System_identification

  #11   Spotlight this post!  
Unread 02-03-2015, 15:56
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,679
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Driving Straight With Encoders

Quote:
Originally Posted by microbuns View Post
Just out of curiosity - what is considered the "best" way to drive straight ?
Any of these (gyroscope, encoders on wheels) or even a magnetic compass is a good first step, and is probably good enough to get you through most 15 second autonomous tasks.

The next step is to make mid-course corrections, based on sensing the environment. This could range from the highly complex (camera-based navigation) to the ridiculously simple (two "curb feelers" or other touch sensors that as limit switches for the drive on either side) and a number of points in between (down-looking sensor looking for the landmark; optical or ultrasonic rangefinders). In this game (unlike most), you could even set down a "trail of bread crumbs" to follow, provided that those bread crumbs are on a tether to your robot.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
  #12   Spotlight this post!  
Unread 02-03-2015, 16:07
microbuns's Avatar
microbuns microbuns is offline
Registered User
AKA: Sam Maier
FRC #4917
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Elmira
Posts: 81
microbuns is an unknown quantity at this point
Re: Driving Straight With Encoders

Quote:
Originally Posted by Ether View Post

Here's some info that may be of interest.

Drive straight with encoders:

http://www.chiefdelphi.com/forums/sh...89#post1446789

Use motion planning for best results:

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

http://www.chiefdelphi.com/forums/sh...d.php?t=134965

Do some simple system identification[1]. For example, take the wheel diameter problem Todd mentioned. Drive the vehicle in a straight line (by tweaking the left-right motor commands) and note the ratio of the left and right encoder values. Use that ratio to fudge your setpoints, or use it to fudge your encoder readings before using them as your process variable.

[1] http://en.wikipedia.org/wiki/System_identification

We may have done some of this "system identification" unintentionally. We did a test where we pushed the robot straight and looked at the encoder values after a certain distance - the two wheel systems seem to be more than within our error tolerance, as we saw a <0.1% error arise (little enough error to just be caused by how we conducted the experiment). We believe the difference is in friction on the two wheels, but we are unsure of a way to quantify that.
  #13   Spotlight this post!  
Unread 02-03-2015, 16:24
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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: Driving Straight With Encoders

Quote:
Originally Posted by microbuns View Post
We believe the difference is in friction on the two wheels, but we are unsure of a way to quantify that.
If by "friction on the two wheels" you mean a difference between the left vs right drivetrain friction (due to gearbox, chains/belts, misalignment, lube, etc) then the closed-loop control can compensate for that.


  #14   Spotlight this post!  
Unread 12-03-2015, 17:43
Skyehawk's Avatar
Skyehawk Skyehawk is offline
Nuts N' Bolts
AKA: Skye Leake
FRC #0876 (Thunder Robotics)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2011
Location: Northwood, ND
Posts: 259
Skyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to all
Re: Driving Straight With Encoders

I have not have time to read this entire thread, my apologies it I am being redundant:
My team has a method for making a "perfectly" straight line while driving forward in auto.

The method:
1) Reset both the left and right encoders.
2) Running in a ~20ms while loop:
...A) some form of counter, timer, or interrupt to stop the loop
...B) some form of comparison between the two encoders
3) Start off the while loop by driving at a certain speed
4) Check if Right>Left, if so speed up Left
5) Check if Left>Right, if so speed up Right
6) Stop loop when the control condition is met.

We sped up the side that was going slower when we reached a tolerance of + or - 1/8 inch. This gave us a drift of 2 inch over a 500 inch forward run.

Last edited by Skyehawk : 12-03-2015 at 17:45.
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:19.

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