Existing Solutions
Raspberry Pi Computer Setup and GPS Module
The Raspberry pi was chosen because of its ease in programming. To begin, a micro-memory card with the Raspbian program, a linux-based operating system, is inserted into the Raspberry pi. The Raspberry pi is then connected to power and an HDMI monitor source. This boots up the Raspbian desktop. The Raspberry has four inputs for usb connections. Because the computer is to communicate with the drone over wifi, a USB wifi dongle is needed. This was simply inserted into the drone. To enable the computer to connect to the drone, some of the configuration settings must be changed on the pi, as demonstrated on circuitbasics.com. [3] The pi is programmed for a wireless connection through the terminal, or Raspbian’s equivalent to a command prompt. The new code can be seen in the figures below:
Replaces code for ethernet cable |
Creates connection with new wifi source |
“YOUR WIFI NETWORK NAME” is the name of the drone’s wifi access point. For this drone, the wifi access is called “ardrone2_101633.” This name was placed in that spot.
The next USB connection is for the Ultimate GPS Breakout Module from Adafruit. Along with this module, the respective library is to be downloaded to the pi and then used to communicate with the GPS. The wiring for the module is simple. Pins get soldered through the module and then connected to the Raspberry pi via a USB converter. The connection can be depicted in the figures below: [2]
Pin connections to USB converter |
GPS module with soldered pins |
Coding the Drone
The coding is done in JAVA and the program used methods from two JAR files, or Java archive files, which are basically packages/libraries containing files which can be utilized in the code, to achieve its object.
The two JAR files the program depends upon are: The YADrone_032.jar and the JAVA RXTX library. The YADrone_032.jar was utilized to control the flight of the drone and the java RXTX library helped in reading in the gps data. [6]
The first step is to connect the application to the drone. This typically means creating a new AR.Drone object in the program which will correspond to the real-world AR.Drone over the wifi. To do this, a new AR.Drone object is created in JAVA and instantiated to legal initial values. For example: the maximum height is set to 10 meters.
Output after connecting |
The next step is to write the code to control the flight of the drone. This is relatively simple using the functions predefined in the jar file. The general commands used have been reproduced below:
- cmd.goLeft(speed).doFor(1000);
- cmd.hover().doFor(2000);
- cmd.goRight(speed).doFor(1000);
- cmd.forward(speed).doFor(2000);
- cmd.backward(speed).doFor(2000);
- cmd.takeOff().doFor(5000);
- cmd.landing();
The third step is to enable the program to receive GPS data.This is done by utilising the JAVA RXTX library. The code written reads in the data and prints it to the screen. The main objective of this part is to connect the serial port on the Raspberry Pi to the GPS application to ensure that the data input read into the program comes from the gps device.
The next step is to convert the latitudes and longitudes read in by the gps into cartesian coordinates. [4] The formulas used have been given below:
x = R * cos(lat) * cos(lon), y = R * cos(lat) * sin(lon), z = R *sin(lat)
Here, x,y,z - the cartesian coordinates. R- radius of Earth, lat- the latitude,lon- longitude
The last step involves combining the modules of coding built so far to accomplish the task. The procedure of coding the last step are given below:
- Read in the gps position of current location.
- Convert to coordinates.
- Ask the user about the destination.
- The coordinates of all destinations are hardcoded into system.
- Generate the difference between the coordinates and control the drone’s flight accordingly.
References
[1] “lady ada”. (2012, Aug 23). Adafruit Ultimate GPS [Online]. Available:
https://learn.adafruit.com/adafruit-ultimate-gps
[2] K. Townsend. (2013, Jan 24). Adafruit Ultimate GPS on the Raspberry Pi [Online]. Available:
[2] K. Townsend. (2013, Jan 24). Adafruit Ultimate GPS on the Raspberry Pi [Online]. Available:
https://learn.adafruit.com/adafruit-ultimate-gps-on-the-raspberry-pi
[3] circuitbasics.com. How to Set Up WiFi on the Raspberry Pi [Online]. Available:
http://www.circuitbasics.com/raspberry-pi-wifi-installing-wifi-dongle/
[3] circuitbasics.com. How to Set Up WiFi on the Raspberry Pi [Online]. Available:
http://www.circuitbasics.com/raspberry-pi-wifi-installing-wifi-dongle/
[4] H. Luchsinger. 4.11 Drone Code [Online]. Available:
[5] www.informatik.uni-hamburg.de YADrone [Online]. Available:
https://vsis-www.informatik.uni-hamburg.de/oldServer/teaching//projects/yadrone/tutorial/tutorial.html
[6] B. Berkland. (2013, Sep 28). Brad's Raspberry Pi Blog [Online]. Available:http://bradsrpi.blogspot.com/2013/09/sample-java-code-to-read-gps-data-from.html
[6] B. Berkland. (2013, Sep 28). Brad's Raspberry Pi Blog [Online]. Available:http://bradsrpi.blogspot.com/2013/09/sample-java-code-to-read-gps-data-from.html
No comments:
Post a Comment