Go to Post I didn't get inspired watching my peers and I, I was inspired watching professionals. - AdamHeard [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 09-11-2006, 02:44
CircularLogic CircularLogic is offline
Registered User
FRC #1546 (Chaos Inc)
Team Role: Leadership
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baldwin
Posts: 38
CircularLogic will become famous soon enoughCircularLogic will become famous soon enough
Line Following with PID

Has anyone ever tried writing line following code using a PID style control system.

Right now I am using Lego Mindstorms, programming it with NQC (basically C for mindstorms with a few built in functions), and I am only allowed to use two light sensors.

Right now I am sucessfully able to drive my motors by having one function that rapidly turns them on and off for a certain period of time, which is passed to the function (in 10's of milliseconds). I take the threshold value of the black material and from it I subtract the current sensor value. I multiply that value by a gain and voila. That works well.

But then I tried to implement a Derivative control and everything went beserk.

Anyone ever do this or have any type of experience with it?
__________________
Team 1546 Chaos Incorporated
2005- SBPLI Rookie All Stars
2006- SBPLI Sportsmanship award.

Gotta hand it to the straight line autonomous mode, the most effective defense out there.

Proud beyond belief of the accomplishments of the second year, 20th ranked, 6 wins and 6 losses Chaos Incorporated.
  #2   Spotlight this post!  
Unread 09-11-2006, 07:03
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: Line Following with PID

I remember doing this with the old drag and drop code blocks of Mindstorm and it was easy. However that wasnt a derivative control system. Can you post the code for us to look at?
  #3   Spotlight this post!  
Unread 09-11-2006, 08:08
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,363
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Line Following with PID

Sometimes in a competition where there are lines on the field, following the line may not be the best technique. What our team has done in the past is to use the lines as way points. It can be faster to drive straight by dead reckoning or encoders until the IR sensors detects the line. Then turn until another sensor detects the line for alignment, then go on. This only works if the lines are placed right.Detecting way points on a field can many times be done faster than following the line. It's an important concept to to keep in mind for autonomous navigation.
  #4   Spotlight this post!  
Unread 09-11-2006, 15:43
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Line Following with PID

Unless you have a fairly high number of sensors, using PID control can be difficult.

One way to increase the speed is to put the sensors just on the edge of the tape, so that if you're a little off, then 1 will be "on" and 1 will be "off". You then slow down a motor to correct.
  #5   Spotlight this post!  
Unread 09-11-2006, 17:03
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Line Following with PID

Quote:
Originally Posted by Astronouth7303
Unless you have a fairly high number of sensors, using PID control can be difficult.

One way to increase the speed is to put the sensors just on the edge of the tape, so that if you're a little off, then 1 will be "on" and 1 will be "off". You then slow down a motor to correct.
He is right. One way to have high resolution is to use a camera. I have written PID line followers using both the CMU Cam and the RC and a DVT camera linked over ethernet to a laptop controlling a wheelchair.

If you dont have either alot of sensors or a camera, there are simpler algorithms.

What are you using for sensors?
__________________
1139 Alumni
  #6   Spotlight this post!  
Unread 09-11-2006, 17:21
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Line Following with PID

FYI, If you're looking for an example of a robot using the CMUCam to follow a line, this one does it pretty well. His video link doesn't have content, but I found video of it in action at the end of this demo video
  #7   Spotlight this post!  
Unread 13-11-2006, 15:44
CircularLogic CircularLogic is offline
Registered User
FRC #1546 (Chaos Inc)
Team Role: Leadership
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baldwin
Posts: 38
CircularLogic will become famous soon enoughCircularLogic will become famous soon enough
Re: Line Following with PID

I guess it would have beneficial to say a few things in my original post.

1. This is not for an FRC compeititon. I am using the lego mindstorms platform for a competition here at my college.

2. I am limited to using two light sensor and two touch sensors. So any suggestions of CMU cam to detect the line arent really applicable.

3. The competition is line following, so by default, it is the most efficient way of doing it.


On top of all of this, the width of the line varies from 1 1/2 inches to 1/8 inch meaning that way point detection can be very difficult.

I will post my code as soon as I am on my own computer.
__________________
Team 1546 Chaos Incorporated
2005- SBPLI Rookie All Stars
2006- SBPLI Sportsmanship award.

Gotta hand it to the straight line autonomous mode, the most effective defense out there.

Proud beyond belief of the accomplishments of the second year, 20th ranked, 6 wins and 6 losses Chaos Incorporated.
  #8   Spotlight this post!  
Unread 13-11-2006, 17:53
AdamHeard's Avatar
AdamHeard AdamHeard is offline
Lead Mentor
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Atascadero
Posts: 5,506
AdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond repute
Send a message via AIM to AdamHeard
Re: Line Following with PID

Quote:
Originally Posted by CircularLogic


On top of all of this, the width of the line varies from 1 1/2 inches to 1/8 inch meaning that way point detection can be very difficult.
If you just keep track of the change from white to black or vice versa, the width of the line will not matter if it is used as a waypoint.
  #9   Spotlight this post!  
Unread 13-11-2006, 18:03
Rob2713g's Avatar
Rob2713g Rob2713g is offline
Registered User
FRC #0540 (Screaming Eagles)
 
Join Date: Apr 2006
Rookie Year: 2004
Location: VA
Posts: 143
Rob2713g has a spectacular aura aboutRob2713g has a spectacular aura aboutRob2713g has a spectacular aura about
Re: Line Following with PID

Something that has worked well for me: Scale the sensor input to motor speed.
So if left sensor has input 50 and right sensor has input 40 (assuming white is high and following a black line), then 100% power to left motor and 80% power to the right motor
  #10   Spotlight this post!  
Unread 13-11-2006, 18:20
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,673
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Line Following with PID

Totally useless for this particular problem, but I've wondered about how to improve basic line following for FIRST bots. I think you could use a relatively fast line sensor and just basically wave the thing around where you think the line should be. And you keep track of where the sensor is with a potentiometer, so you end up with an analog (ish) value for the position of the line instead of a digital value from 3 or so static sensors. I think it just depends on if the sensor would acquire the line in a fast and predictable manner.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #11   Spotlight this post!  
Unread 13-11-2006, 18:26
intellec7's Avatar
intellec7 intellec7 is offline
108 programmer
AKA: Gustavo
FRC #0108 (SigmaC@ts)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2006
Location: Hollywood, Florida
Posts: 65
intellec7 is on a distinguished road
Send a message via AIM to intellec7 Send a message via MSN to intellec7
Re: Line Following with PID

I am not sure if this could work, but what if the PID input were time? If the slope of the robot in relation to the line is small, it will take longer for an error to occur. (one of the line detectors to detect the line). If the difference in slope is great, then an error will occur more quickly.
Perhaps pseudo code would be something like

:Beginning
Begin Timer
While line not detected
Go forward
Stop Timer
correction = PID(timer,sensor)
GOTO Beginning

Just a thought.

Last edited by intellec7 : 13-11-2006 at 18:29.
  #12   Spotlight this post!  
Unread 14-11-2006, 00:22
Ken Streeter's Avatar
Ken Streeter Ken Streeter is offline
Let the MAYHEM begin!
FRC #1519 (Mechanical Mayhem)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Team: Milford, NH; Me: Bedford, NH
Posts: 470
Ken Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond repute
Re: Line Following with PID

Quote:
Originally Posted by CircularLogic
I guess it would have beneficial to say a few things in my original post.

1. This is not for an FRC compeititon. I am using the lego mindstorms platform for a competition here at my college.
Are you allowed to modify the robot design, or are you stuck with a particular robot design?

The reason I ask is that about 4 years ago I built an incredible line follower where the secret wasn't in the software but was in the construction of the lego robot. Do you have freedom to choose your own robot design?

What is the design of your robot? Can you post a picture?
__________________
Ken Streeter - Team 1519 - Mechanical Mayhem (Milford Area Youth Homeschoolers Enriching Minds)
2015 NE District Winners with 195 & 2067, 125 & 1786, 230 & 4908, and 95 & 1307
2013 World Finalists & Archimedes Division Winners with 33 & 469
2013 & 2012 North Carolina Regional Winners with teams 435 & 4828 and 1311 & 2642
2011, 2010, 2006 Granite State Regional Winners with teams 175 & 176, 1073 & 1058, and 1276 & 133
Team 1519 Video Gallery - including Chairman's Video, and the infamous "Speed Racer!"
  #13   Spotlight this post!  
Unread 14-11-2006, 10:49
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: Line Following with PID

There are two ways to do line following with an RCX/NXT.
The first easier, but slower way is simply if it sees black go left, if it see white go right. This approach uses only one light sensor so if you want to use the other sensor for something else you could.

The second more complicated way is to have two light sensors mounted (in your case) about 1 1/2-2'' apart. When the left sensor sees black slow the left motor, and increase speed of the right motor, and when the right sensor sees black slow the right motor, and increase speed of the left motor. This approach is more complicated, but the robot will move faster.
__________________
Eric Haskins KC9JVH
  #14   Spotlight this post!  
Unread 14-11-2006, 11:46
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: Line Following with PID

This site has a lot of useful information. I don't own any of his books, but the line following robot is very fast. In the video it looks like it's on rails. Simple 2wd differential steering.

http://robotroom.com/Jet.html
  #15   Spotlight this post!  
Unread 14-11-2006, 13:15
Ken Streeter's Avatar
Ken Streeter Ken Streeter is offline
Let the MAYHEM begin!
FRC #1519 (Mechanical Mayhem)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Team: Milford, NH; Me: Bedford, NH
Posts: 470
Ken Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond repute
Re: Line Following with PID

Quote:
Originally Posted by Ken Streeter
The reason I ask is that about 4 years ago I built an incredible line follower where the secret wasn't in the software but was in the construction of the lego robot. Do you have freedom to choose your own robot design?
Even though I haven't heard back after my note from yesterday, I decided I'd provide a little more info. In my opinion, the real trick to getting incredible line following ability is to use a "steering robot", like a car, rather than like a typical FRC robot which typically uses "tank-style" differential drive to turn.

In a line-following steering robot, the light sensor is actually mounted to pivot with the front wheels as they turn. In this way, the light sensor ensures that the front wheels track down the line. Whenever the robot is driving with the light sensor over the edge of the line, the front wheels get centered over the edge of the line, pointing the front tires in the correct direction along the line due to the geometry between the light sensors and the front wheels.

After building a robot like this, play with things you can do to tighten the steering response (you want no slop) and adjust the distance between the light sensor and the front wheels. You'll want the robot to be as small and light as possible. The programming is actually rather simple -- use the steering to keep the sensor centered over the edge of the line, and simply power the drive motor to keep the robot moving. Use of proportional control for the steering would probably be sufficient, but PD would probably improve the steering. PID would probably not be needed in this case. In addition to modifying the steering software, you can adjust the forward speed to be greater when the robot is "tracking well" and slower when it is "tracking poorly."

The robot that I built as a line follower a few years ago was an enhancement upon an incredible line follower by Gas Jansson -- his famous "Steerbot" -- http://www.lugnet.com/~726/SteerBot His page describes a lot about how the robot is built, includes detailed photos, and talks about the programming. There are also some great videos of the robot driving at http://www.lugnet.com/org/us/smart/~48/meetings/2001/01

My improvements were never documented, but had to do with decreasing the slop between the steering motor and the front tires, as well as slop between the front tires and the light sensor. (Gus' robot has a fair bit of play there, which decreases the responsiveness of the system.) I'd love to show you a picture or photo, but the robot was cannibalized for my FLL team before I took the time to take photos.

Let us know how it turns out!
__________________
Ken Streeter - Team 1519 - Mechanical Mayhem (Milford Area Youth Homeschoolers Enriching Minds)
2015 NE District Winners with 195 & 2067, 125 & 1786, 230 & 4908, and 95 & 1307
2013 World Finalists & Archimedes Division Winners with 33 & 469
2013 & 2012 North Carolina Regional Winners with teams 435 & 4828 and 1311 & 2642
2011, 2010, 2006 Granite State Regional Winners with teams 175 & 176, 1073 & 1058, and 1276 & 133
Team 1519 Video Gallery - including Chairman's Video, and the infamous "Speed Racer!"

Last edited by Ken Streeter : 14-11-2006 at 13:24.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Emergency: PID with Wheels Off the Ground Rick TYler Programming 9 07-02-2006 11:37
Light and Line Following Sensors jeffmorris FIRST Tech Challenge 1 15-12-2005 21:57
Problems with PID- PLEASE HELP!!! thinkpad Programming 12 10-02-2005 00:18
All-Time PID Drive with Hall-effects: Coming along very nicely jdong Programming 6 05-02-2005 19:39
Line Following -- Optical Sensors WillyC Electrical 4 23-01-2004 16:59


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

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