Background

Existing Solutions

Drexel does provide tools to help new freshmen find their way around campus. For example, the DrexelOne app has a map that shows the location of every upcoming class. However, non-local students students still got lost because the app did not provide directions, and they were not familiar with the street locations and numberings. As for the drone, GPS capable drones are available, however, they cannot be programmed to take input from a user. Also, to achieve user-friendliness, the drone needs to be Drexel-specific. In other words, it needs to be able to recognize Drexel building names and pair them with GPS coordinates. Other drones on the market are very obviously not programmed for this. In addition, GPS capable drones are expensive. Even the Parrot AR.Drone’s GPS module can be above $100 alone (see 5. In the References section), when the Adafruit GPS module is only $40. [1]

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:

etcnetworkinterfaces-file1.png
Replaces code for ethernet cable
etcwpa-supplicant.png
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]
954-02.jpg
Pin connections to USB converter
raspberry_pi_gps_pi_usbconnection2.jpg
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);
The above commands make the drone go left at the specified speed for a period of 1000 milliseconds or 1 second. The following command causes it to remain at that position for a period of 2 seconds. [5] Other commands used :

  • 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:
  1. Read in the gps position of current location.
  2. Convert to coordinates.
  3. Ask the user about the destination.
  4. The coordinates of all destinations are hardcoded into system.
  5. Generate the difference between the coordinates and control the drone’s flight accordingly.
For example: If current position is (1,0,2) and destination is at (3,4,5), then the drone will go right for (3-1=2) units, forward for (4-0=4) units and upward for (5-2=3) units. The speed and time of flight will be adjusted accordingly.

References

[1] “lady ada”. (2012, Aug 23). Adafruit Ultimate GPS [Online]. Available:
[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
























No comments:

Post a Comment