Shop OBEX P1 Docs P2 Docs Learn Events
Line Following Racing Robot — Parallax Forums

Line Following Racing Robot

John AbshierJohn Abshier Posts: 1,116
edited 2010-11-13 16:03 in Robotics
This robot handily won first place in the Dallas Personal Robotics Group Roborama 2010A last May. I did my first run with the base speed set to 75 percent. Since that run was successful, I did my second run at 100 percent speed. The course was mostly curves, six inch radius. My speed didn't increase much because most of the time the robot was turning. A test run a home resulted in a 14 percent speed increase (measured) even though the commanded speed increased 33 percent.

My initial design criteria was for light weight and low moment of inertia. The body is six millimeter thick expanded PVC. The controller is a stock Parallax Propeller Proto Board USB. The line sensor is the Pololu QTR-8RC reflectance sensor array. It is similar to Parallax's QTI sensor. The motor driver is also from Pololu, TB6612FNG. The battery is a 7.4 volt lithium. I don't remember where I got it or its capacity. Main wheels, 3mm hubs, and the tail wheel assembly came from Lynxmotion. Motors and mounts were some that I had from a previous robot. The dip switch has the following functions: Switch 1--select race or calibrate sensors. Switch 2--white or dark line. Switches 3 and 4 select various base speeds. The push button switch is a go/start button and the LED is for general information. An absolutely critical part is the XBee module. It is mounted in a carrier board from Selmaware (unfortunately no longer available).

The software reads all eight sensors and returns a number between -3500 and 3500 depending where the robot is in relationship to the line. A proportional, derivative (PD) controller tries to drive this error to zero. The hardest task I had was to determine the PD coefficients. Initially the robot would follow the line for a few inches and then go to never land. The XBee was used to send back the error value, motor commands, sensor status and some other information. I am using the XBee in simple serial mode and using Parallax's PST on my laptop. Looking at the data and sometimes copying the data into Excel to graph allowed me to develop PD coefficients that would complete my test course. Then I ran into another problem. I would change the coefficients and then ask, "Is this run with new coefficients better than the previous run?" It was hard to tell from just visually observing the run. Fortunately, the light bulb lit up. I summed the absolute value of the error term and counted the number of times the control loop executed. The number of times the control loop executed is a measure of speed, fewer is better. The average of the absolute value of the error term is a measure of smoothness in the run, smaller is better. Now I could tell if the coefficient change made things better or worse. The motor driver code is a mixture of SPIN and PASM. The rest of the code is in SPIN.

Future plans are to replace the wheels with 1/2 inch greater diameter ones for greater speed. A harder, and therefore less likely, change would be to move the Propeller Proto Board forward an inch and cut an inch off the rear of the frame. This should allow it to turn somewhat faster.

John Abshier
1600 x 1200 - 161K
1600 x 1200 - 166K
1600 x 1200 - 214K

Comments

  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2010-11-02 15:28
    Very nice job, very straightforward approach (no pun intended). Not sure if it has been done before, but I would think two more line followers (one before and one after the main one) would enable you to control the adjustments of the robot's direction to manage the steering corrections more accurately to increase your speed.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-11-03 10:53
    I was going to suggest something along the same lines (so to speak) -- especially the one further forward, which would allow the bot to anticipate its turns sooner. A TSL1401-DB might also give you an advantage, if a finer resolution on the line's position would help. See here:

    -Phil
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-11-03 11:28
    Andrew and Phil I don't think a sensor behind the current one would help. Looking further out may help. I am considering the TSL1401-DB for several reasons. One, philosophically I dislike having a sensor close to the ground. It is a beat the game sensor that has big problems in the real world. Second, looking further out would let you slow down prior to entering a curve. Perhaps most importantly, I think it may give smoother outputs. The current sensor has a tendency to be on-off. The derivative of the error is often highly not continuous. Since the next contest is November 13, a new sensor will have to wait until next year. I have added the larger wheels and retuned the PD coefficients. The TSL1401-DB presents some interesting design challenges. How far out to look? What is a good threshold value? I think that head lamps are necessary, I wouldn't want to rely on ambient lighting. The Dallas Science Museum has a glass wall that has been the bane of many robots.

    John Abshier
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-11-03 14:06
    The TSL1401-DB presents some interesting design challenges. How far out to look? What is a good threshold value? I think that head lamps are necessary, I wouldn't want to rely on ambient lighting.
    If used in conjunction with an ADC, you can set the threshold dynamically, based on an average reading. Without an ADC, you can read the width of the line and adjust the exposure time to keep it at a constant value (assuming the line is always in view).

    Definitely, yes, you need to use lighting that you have control over.

    -Phil
  • wyzard28wyzard28 Posts: 24
    edited 2010-11-13 14:56
    I noticed in your photos you're using a 5.00 MHz crystal. Any thoughts to moving to a 6.25 MHz and running the Propeller at 100 MHz? I'm fond of the 20% processing speed gain -- especially if you plan on "look ahead" curve analysis.

    _richard
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-11-13 16:00
    _richard, 80 MHz has been fast enough. I guess if I went to a higher update rate for the main loop then perhaps I would need the faster Prop. One thing to keep in mind is that no matter how fast the Propeller chip runs, you cannot go faster than your sensors. I am out of town today and don't remember how fast the sensor is.

    John Abshier
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-11-13 16:03
    Roboroma 2010b, 13 Nov 2010. My time 5.9 seconds, second place 16+ seconds. Robarma 2010b was a nice contest with great prizes. First time I have ever won a prize that was worth more than it cost me to build the robot. But Kansas Turnpike, tolls, gas and Motel 6 still put me in the hole. But I do this to keep my mind active.

    John Abshier

    PS. I keep trying to preach the gossple of Propeller.
Sign In or Register to comment.