Main Site Documentation

Robot follow line


#1

Ok, so I have a line follower working, however the turns are quite abrupt, even though they are small. What’s a good strategy to make slight turn adjustments that are smooth when travelling at a good speed?

Thanks.


#2

See the video of my FEZ Mini line follower, here I use a duty cycle of 80% for speed
Can you publish a movie of your results?


#3

I saw your video Hinnie and was wondering how to did the turns to maintain the speed…


#4

I have a very simple line follower working, however the turns are very rough and abrupt which reduce the speed it can be used. If anyone could point me in the right direction I would be most appreciative, thanks!

 public static void Main()
      {
         FEZ_Components.ReflectiveSensor LeftSensor  = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An7, 50);
         FEZ_Components.ReflectiveSensor RightSensor = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An6, 50);
         
         // move forward
         FEZMini_Robot.MoveRamp(50, 50, 10);

         while (true)
         {
            bool left  = LeftSensor.GetState()  == FEZ_Components.ReflectiveSensor.DetectingState.ReflectionNotDetected;
            bool right = RightSensor.GetState() == FEZ_Components.ReflectiveSensor.DetectingState.ReflectionNotDetected;

            if (left)
            {
               FEZMini_Robot.Move(-50, 50);
               Thread.Sleep(20);
               continue;
            }

            if (right)
            {
               FEZMini_Robot.Move(50, -50);
               Thread.Sleep(20);
               continue;
            }

            FEZMini_Robot.Move(50, 50);
            Thread.Sleep(10);

         }
      }


#5

@ tmaxxtigger
The restless movements are the result of your major engine changes from 50 to -50.
The program of the movie is the normal engine speed is changed to 80 and -10. So I use the values ​​(80, 80) (80, -10) and (-10, 80)
The value (0, 0) is used as both sensors see the line (for when you pick up the robot then stop the engine)
The switch should I do with the C # switch statement.
The threads.sleep is smaller but me I call the switch statement only if the sensor value has changed.

Note: The ReflectiveSensor class is on the trigger rate at 50%
This is not really 50% because the sensor has an operating voltage of 5 volts, and that all measured values ​​above 3.3 volts (property of USBizi) come to 100%.

With this information you may need to move forward.


#6

Thanks for the pointers, makes perfect sense and I made some adjustments, however still no luck. The robot now does not make enough turns and crosses over the line completely moving of the track. There are so many variations of duty cycle and sleep time that I’ve tried but similar problem remain.:


      public static void Main()
      {
         FEZ_Components.ReflectiveSensor LeftSensor  = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An7, 60);
         FEZ_Components.ReflectiveSensor RightSensor = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An6, 60);
         
         // move forward
         FEZMini_Robot.MoveRamp(80, 80, 10);

         while (true)
         {
            while (LeftSensor.GetState() == FEZ_Components.ReflectiveSensor.DetectingState.ReflectionDetected && 
               RightSensor.GetState() == FEZ_Components.ReflectiveSensor.DetectingState.ReflectionDetected )
            {
               FEZMini_Robot.Move(80, 80);
               Thread.Sleep(5);
            }

            // lifted off the ground, so stop
//            if (left && right)
//            {
//               FEZMini_Robot.Move(0, 0);
//               Thread.Sleep(100);
//               continue;
//            }

            if (LeftSensor.GetState()  == FEZ_Components.ReflectiveSensor.DetectingState.ReflectionNotDetected)
            {
               FEZMini_Robot.Move(-10, 80);
               while (LeftSensor.GetState() == FEZ_Components.ReflectiveSensor.DetectingState.ReflectionNotDetected)
               {
                  Thread.Sleep(5);
               }
            }

            if (RightSensor.GetState()  == FEZ_Components.ReflectiveSensor.DetectingState.ReflectionNotDetected)
            {
               FEZMini_Robot.Move(80, -10);
               while (RightSensor.GetState() == FEZ_Components.ReflectiveSensor.DetectingState.ReflectionNotDetected)
               {
                  Thread.Sleep(5);
               }
            }

         }
      }



#7

@ tmaxxtigger
I’ve tried your code and it gives a reasonable result. So I understand your problem is not well. Can you make a movie of it?
Also important is how the sensors are mounted on the photo to see how I’ve confirmed.


#8

I moved the sensors and it did help somewhat, thanks for taking the time to reply. Here is a video…

[video=vimeo]35141589


#9

Hi

I’ve just done my line follower yesterday.
My robot is based on Pololu RRC04 chassis with 2 1:30 micro motors.
The whole is driven by a Panda II with a TB6612 breakout board from SparkFun for driving the motors.
I use a QTR-8A reflectance sensor array (only using 5 of them) connected to 5 analog inputs of the Panda II.
I have not used any existing class for handling these but written myself some code to calibrate the levels from the reflectance sensors.

Initial basic code, like yours was very jerky.
Now I have implemented a PID algorithm but need to find a method to tweak parameters to go faster.

Regards

Added the video. Wait as the robot accelerate every 15 seconds, or go straight to ~2:30 to see it at its current max speed


#10

Looks good!


#11

@ Barbudor - Very smooth! Now all you need is to draw a line from fridge to lab and build an auto beer loader and you’re in business!

Where do you get your parts? I like those wheels.


#12

Hi Ian, Guys

Happy that it looks good to you.
Here are the parts (purchased from local resellers in France)
Mechanical :
[ulist]Chassis : Pololu RRC04 http://www.pololu.com/catalog/product/1506, many colours available, mine is transparent gray[/ulist]
[ulist]Motors : Pololu Micro Metal 30:1 gearmotor http://www.pololu.com/catalog/product/993 with mounting brackets http://www.pololu.com/catalog/product/1086 [/ulist]
[ulist]Wheels : Pololu 42mmx19mm http://www.pololu.com/catalog/product/1090 [/ulist]

Electronics :
[ulist]Motor driver : TB6612 on a breakout board from Sparkfun http://www.sparkfun.com/products/9457 [/ulist]
[ulist]Line Detector : Pololu QTR-8A http://www.pololu.com/catalog/product/960. This 8 sensor line is breakle as 6+2. I did and used the 6-in-line for line detection. In fact I used only 5 of them to have a sensor on the center.[/ulist]
[ulist]Brain : Panda II (underneath the protoboard[/ulist]

Code is inspired from Pololu giude about their 3PI robot.

My current plans are :
[ulist]Re-learning about PID (school time is too far… ;)) to see if I can optimize the PID parameters[/ulist]
[ulist]I am thinking of adding a Sharp IR distance sensor for object avoidance.[/ulist]
[ulist]Maze solver ? as it seems the legacy 2nd step after line following in most tutorials…[/ulist]


#13

Hi @ barbudor
Maze solver is not very difficult
Richard Vannoy on its website gives a simple description of a non-loop solution http://www.richardvannoy.info/line-maze.php
The method I used to fit the FEZ Mini Robot
http://www.youtube.com/watch?v=thjcfzawlLg


#14

Hi Hinnie

How are you making 1/4 and 1/2 turns ?

Have you just calibrated the time you need when using motors at a certain speed ?
Are you using the line sensor ?

I feel that time is not reliable on my platform. Probably the wheels are sliding ramdomly.
Even the litlle left-right-left at the beginning to calibrate the sensor does not work well.


#15

@ barbudor
You can do this in two stages:
a. The turning away from the line, this is a small timer is used so that the sensors no longer detect line.
b. For positioning the robot on the line sensors are used which can be immediately followed with the following line.