Coder Social home page Coder Social logo

415gps's Introduction

415gps

This script is written for students in ME 415. The script gpslog.py reads serial GPS data (NMEA messages) and writes the data to a time-stamped csv file.

Before Class Setup

  1. Install Python v3. I recommend installing via Anaconda: https://www.anaconda.com/distribution/

  2. Install the pyserial package. From the command line ("Terminal" on mac/linux, "Anaconda Prompt" on windows), type conda install pyserial. If you'd prefer a GUI you can do this in Anaconda Navigator, which was installed in the prior step. See here.

  3. Download this package using the big green button above.

Running the Script

  1. Plug one of the radio transmitters into your computer via the USB port. You should see a faint green light flashing showing you that it is powered on. You now need to figure out what port the transmitter is connected to. Instructions for different operating systems are shown below.

    Windows

    • Open Device Manager, and expand the Ports (COM & LPT) list.
    • Note the number on the USB Serial Port.
    • Run script with (note this for step 4)
      python gpslog.py COM*
      
      where * is the number of your serial port

    Macintosh

    • Open a terminal and type: ls /dev/*.
    • Note the port number listed for /dev/tty.usbmodem* or /dev/tty.usbserial*.
    • Run the script with (note this for step 4)
      python gpslog.py /dev/tty.usbmodem*
      
      or
      python gpslog.py /dev/tty.usbserial*
      
      where * is the number of your serial port

    Linux

    • Open a terminal and type: ls /dev/tty*.
    • Note the port number listed for /dev/ttyUSB* or /dev/ttyACM*.
    • Run the script with (note this for step 4)
      python gpslog.py /dev/ttyUSB*
      
      where * is the number of your serial port
  2. Open up a command prompt ("Terminal" in Mac/Linux or "Anaconda Prompt" in Windows). Navigate to the previously downloaded 415gps folder (using the command cd).

  3. Connect your battery, via the ESC, to the GPS and to one of the radio transmitters. For the leads with three wires, make sure you match negative to negative (black to brown). Be careful about how long you leave your battery attached to your ESC. While the electronics power draw isn't large compared to the amount your motor will be using, over the course of an hour (if you leave it plugged in) you could end up draining the battery below acceptable levels, especially if you started with your battery being at storage voltage. If you're expecting to have your electronics powered on for a while, it's a good idea to charge your battery some first. Just remember to restore it to storage voltage if you won't be using it for a couple days so you don't degrade your battery's performance.

  4. Run the script using the command noted from step 1.

  5. You should see a bunch of timestamped data shown to screen. If you are doing this in the classroom you will see a bunch of NaNs. That is because you don't have a GPS fix. Getting a GPS fix generally requires being outside. The first time you are getting a fix may take up to a minute of the GPS being powered. In our experience the GPS and radio need to be at least 4 inches apart to get a fix due to signal interference, even outdoors.

  6. End the script by typing CTRL+c

Using the Script

The script gpslog.py will record data into a time-stamped csv file. Data is output only if the gps has a satellite fix. An example csv output file can be found in the example_output directory. The time entry in the CSV file corresponds to the time since the script was started. I used http://www.hamstermap.com to plot the coordinates.

Inside the gpslog.py script you will need to modify usrfun to allow real time data processing. There are two sections in the code that say "FOR YOU". The first is in initializevariables if you need to initialize any variables you can do so here. This function is just called once when the gps is first turned on. the other function is usrfun, which is called every time a new gps packet is received. This is where you'll add logic for figuring out which way to turn, checking if you reached a waypoint, checking your altitude, etc. Boundary checks are already done for you in that function.

Note: If you want to run your script from Spyder: https://stackoverflow.com/a/31392812, put the port argument into the command line option field.

415gps's People

Contributors

taylormcd avatar andrewning avatar

Stargazers

Ben avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.