Friday, May 3, 2013

Line Following Robot with obstacle avoidance (Lejos NXT)


The robot has to traverse an arena to reach a destination area. The destination lies towards the southern region of the arena. There is a path in the arena which leads to the destination. The path is black in colour over a white surface. This path ends in a red coloured region which is the destination. The trajectory of this path is variable (such as straight, zig-zag, circular etc.). There are obstacles of different shapes and sizes along the path. While traversing, the robot has to avoid any collision with those obstacles and keep following the path. If a yellow coloured strip is found on the path by the robot that would mean there is a junction point ahead wherein two or more paths diverge. The robot has to decide which way to go to reach the destination.

Algorithms

We use three different algorithm to implement our program that we are going to discus one by one but here it is the overall algorithm containing all the algorithm in one.

until destination reached

      drive to ward destination
          if robot found obstacle
              until robot found target path
                   follow obstacle contour
             end
         end if
         if robot found junction
              until robot found target position
                    follow junction contour
              end
         end if
end

Line Following algorithm


In this algorithm we use two light sensors and as a result our robot encounters four conditions

    1.   If the side sensor sees white and the center sensor sees white, the robot is 
           right outside the path, so it should turn right.
  1. If the side sensor sees white and the center sensor sees black, the robot is right over the path, so it should run forward.
  2. If the side sensor sees black and the center sensor sees white, the robot is outside to the right part of the path , so it should turn to left.
  3. If the side sensor sees black and the center sensor sees white, the robot is outside to the right part of the path , so it should turn to left.

Obstacle detection


if Obstacle found then
    check left and right path for no obstacle
    if no obstacle to the left side of the path
          turn the robot left
          until robot found target path
                move outside the path in curve and
                turn away from the obstacle
          end
   else if no obstacle to the right side of the path
          turn the robot right
          until robot found target path
                move outside the path in curve and
                turn away from the obstacle
         end
   else
         report no path
   end if

end if


Junction Algorithm


If the yellow strip found
       move forward until the robot completely crossed the yellow strip
       rotate 180 degree and move forward until finding the yellow strip and store the compass value
       rotate until the compass reading become 180.
       rotate to left side until getting a black strip other than the incoming path and store the compass -               reading
       rotate back to 180 degree
       find the right side path similarly and store the compass reading
       Take the nearest path (left or right) by comparing the stored compass readings.

In the junction the robot will rotate back to the incoming path. And reads the compass value. Then it rotates until the compass value become 180. Then it will slowly rotates left side until either a black strip is found or reaches to 0 degree. If any path, other than incoming path, found it will stores that compass value. Similarly it will calculate the path on right side also. Then robot takes the path which is near to the 180 degree, i.e south.


System requirement


Hardware :
core components we had used to build the robot are:
  1. Color sensor: The Color Sensor enables our robot to distinguish not only between black and white, and also a range of bright and pastel colors.
  2. Ultrasonic sensor: The Ultrasonic Sensor is able to detect an object and measure its proximity in inches or centimeters.
  3. Compass sensor :the Compass Sensor is able to measure the earth's magnetic field and calculates a magnetic heading to tell which direction our robot is facing
  4. Servo motor: We use two servo motor to move the robot and one servo motor to rotate the ultrasonic sensor within 0-180 degree to detect obstacle.
  5. Lego brick: The NXT Intelligent Brick, it is the robot’s “brain,” features a powerful 32-bit microprocessor and Flash memory, plus support for Bluetooth and USB 2.0

software :
Java SE Development kit 32 bit
NXT USB Driver 32bit
leJOS NXJ 0.8.5beta win32
eclipse java indigo SR1 win32

3 comments:

  1. Hi, I have been trying to understand how this works for a school project. I was wondering if you could sent a photo of the program as I am having trouble understanding the program. Thanks :)

    ReplyDelete
  2. can you plz do it with pic microcontroller

    ReplyDelete