User Tools

Site Tools


ardrone_line_following

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
ardrone_line_following [2016/11/01 11:05] – created dwallaceardrone_line_following [2016/11/06 02:37] dwallace
Line 1: Line 1:
 ====== Making the AR.Drone do Line Following ====== ====== Making the AR.Drone do Line Following ======
  
-=Introduction= +==== Introduction ===== 
 In this tutorial we will scratch the surface of computer vision and robotics. In the past tutorials you controlled the ardrone using the keyboard and also joystick but autonomy did not come into play.  This tutorial opens the gate of machine learning ,control systems and autonomous aerial vehicles. In this tutorial we will scratch the surface of computer vision and robotics. In the past tutorials you controlled the ardrone using the keyboard and also joystick but autonomy did not come into play.  This tutorial opens the gate of machine learning ,control systems and autonomous aerial vehicles.
  
-==Goal==+==== Goal ==== 
 The purpose of this tutorial is to implement basic computer vision algorithms for the autonomy of the ardrone. The bottom camera of the ardrone is use to track a line and keep on course. I used a proportional controller in this case to make this simple and you can develop it from here to make it do complex things. All of the code developed in my tutorial is for basic autonomy of the quad-rotor ardrone.  The purpose of this tutorial is to implement basic computer vision algorithms for the autonomy of the ardrone. The bottom camera of the ardrone is use to track a line and keep on course. I used a proportional controller in this case to make this simple and you can develop it from here to make it do complex things. All of the code developed in my tutorial is for basic autonomy of the quad-rotor ardrone. 
  
-== Add the line following module ==+==== Add the line following module ====
  
-In order to continue with this tutorial make sure you finished the tutorial http://dasl.mem.drexel.edu/wiki/index.php/Controlling_the_ARDRONE_with_a_game-pad_controller +In order to continue with this tutorial make sure you finished [[ardrone_gamepad|this tutorial]].
  
 Step 1: Step 1:
 Open up a new terminal and enter: Open up a new terminal and enter:
-<br> <pre> roscd drone_teleop </pre>+ 
 +  roscd drone_teleop
  
 Step 2:  Step 2: 
 Go to folder named "bin" and create a file called "linefollow.py" and add the following code to it: Go to folder named "bin" and create a file called "linefollow.py" and add the following code to it:
  
-<source lang="python"> +<code python linefollow.py>
 #!/usr/bin/env python #!/usr/bin/env python
 import roslib; roslib.load_manifest('drone_teleop') import roslib; roslib.load_manifest('drone_teleop')
Line 170: Line 172:
    
     termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)     termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
-</source+</code
- +**Save and close the file.** 
- +
- <br> '''save and close the file.''' +
  
 Step 3:  Step 3: 
 Go to the folder bin in drone_teleop and right lick on the file "linefollow.py" and in the permissions tab click the check box "Allow executing file as a program" Go to the folder bin in drone_teleop and right lick on the file "linefollow.py" and in the permissions tab click the check box "Allow executing file as a program"
  
- +Step 4:
-step 4:+
 Go to folder named "src" in the package "roscv"(which you would have created in the previous tutorials and create a file called "linefollower.cpp" Go to folder named "src" in the package "roscv"(which you would have created in the previous tutorials and create a file called "linefollower.cpp"
  
-step 5: +Step 5:
 In the empty file and paste the following code and after that save the file. In the empty file and paste the following code and after that save the file.
-<source lang="c">+ 
 +<<code c++ linefollower.cpp>
 #include <ros/ros.h> #include <ros/ros.h>
 #include <stdio.h> #include <stdio.h>
Line 349: Line 349:
   return 0;   return 0;
 } }
 +</code>
  
-</source> +===== Make changes in the CMakeLists.txt =====
- +
-=Make changes in the CMakeLists.txt=+
  
 Step 1: Open up the file named "CMakeLists.txt" and search for the lines beginning with "rosbuild_add_executable". In that add the file you created which is "linefollower.cpp". Save and close the file. Step 1: Open up the file named "CMakeLists.txt" and search for the lines beginning with "rosbuild_add_executable". In that add the file you created which is "linefollower.cpp". Save and close the file.
  
-=Environmental setup=+===== Environmental setup =====
  
 Step 1: Step 1:
 Make sure you have a plain ground and paste tape on it so that it would form a straight line(not necessarily perfect  straight). You can do the same procedure on a tiled floor too. Here is a sample picture of such environment.  Make sure you have a plain ground and paste tape on it so that it would form a straight line(not necessarily perfect  straight). You can do the same procedure on a tiled floor too. Here is a sample picture of such environment. 
  
-[[image:line1.jpg|200px|sample line on the floor]]+{{dylanw:line1.jpg}}\\ 
  
-[[image:line2.jpg|200px|sample line on the floor]]+{{dylanw:line2.jpg}}\\ 
  
-[[image:line3.jpg|200px|sample line on the floor]]+{{dylanw:line3.jpg}}\\ 
  
 Step 2: Step 2:
 After you have set the line,run and test the program. After you have set the line,run and test the program.
 Make sure you have done the following things before you fly.  Make sure you have done the following things before you fly. 
 +
 1. Interface the drone with laptop  1. Interface the drone with laptop 
 2. Make sure you have connected the joystick to the computer (logitech dual controller) 2. Make sure you have connected the joystick to the computer (logitech dual controller)
Line 377: Line 377:
 Open up a terminal and enter the commands one after the other: Open up a terminal and enter the commands one after the other:
  
-<pre> +  roscd roscv 
-roscd roscv +  cmake . 
-cmake . +  rosmake
-rosmake +
-</pre>+
  
 Step 4: Step 4:
Line 388: Line 386:
 Enter the following commands each in a new terminal: Enter the following commands each in a new terminal:
  
-<pre> +  roscore 
-roscore +  rosrun ardrone_brown ardrone_driver 
-rosrun ardrone_brown ardrone_driver +  rosrun joy joy_node 
-rosrun joy joy_node +  rosrun roscv roscv 
-rosrun roscv roscv +  rosrun drone_teleop linefollow.py
-rosrun drone_teleop linefollow.py +
-</pre>+
  
 Step 5: Step 5:
Line 403: Line 399:
 Now the drone is in autonomous mode. Your controls wont have any effect here.It should be following the line now.To have the control of the drone hit button 8 again and it should be in manual mode. Now the drone is in autonomous mode. Your controls wont have any effect here.It should be following the line now.To have the control of the drone hit button 8 again and it should be in manual mode.
  
-=Video=+===== Video =====
  
-<html> +{{youtube>uxLbyhi_b8Q?large}}\\ 
-<iframe width="853" height="480" src="http://www.youtube.com/embed/uxLbyhi_b8Q" frameborder="0" allowfullscreen></iframe> +
-</html>+
ardrone_line_following.txt · Last modified: 2016/11/06 02:38 by dwallace