Difference between revisions of "Project gps"
|Line 100:||Line 100:|
=== gps.py ===
=== gps.py ===
Revision as of 20:46, 24 March 2018
- Matthew Gilli, Electrical Engineering B.S.
- Sidney Hsu, Mechanical Engineering M.S.
- Jason Mayeda, Mechanical Engineering B.S.
- Roy Sun, Mechanical Engineering B.S.
GPS and Autonomous Vehicles
Global Positioning System (GPS) is formed by a network of satellites that provides geolocation data (time stamps, coordinates) to compatible GPS receivers. GPS data is commonly used along with a suite of other sensors in autonomous systems for navigation and control. The data provides coordinates in a global coordinate frame (latitude, longitude) that can be used to perform simply point-to-point navigation tasks. For more information about GPS fundamentals, see GPS.gov..
Due to complications with previous plug-and-play GPS modules for DonkeyCar autonomous vehicles, we sought to build our own DonkeyCar-compatible GPS module from scratch. The main flow of our project is as follows:
- Initialize a list of waypoints.
- Recieve GPS data from GP-20U7 reciever.
- Determine current position and bearing of the car with respect to the waypoint.
- Calculate throttle and steering commands to direct the car to the waypoint.
- Repeat steps 2-4 until the waypoint is reached.
- Once the car reaches a waypoint, drive in circle for X amount of time.
- Repeat steps 2-6 until all waypoints in the list have been visited.
This project was implemented with two main processes: planning and GPS interface.
- Polls for GPS data through the Pi serial port.
- Parses GPS strings for relevant coordinate and time data.
- Inputs: Bit/s
- Outputs: Car location: GPS coordinates in latitude and longitude.
- Implements control algorithms to calculate actuator commands for the car.
- Keeps track of additional stop conditions.
- Manages waypoint list.
- Inputs: Car location: GPS coordinates in latitude and longitude
- Outputs: Throttle and steering commands
To implement our navigation tasks, we used the inexpensive GP-20U7 GPS receiver. Here you can find more information on the receiver including cost, sample projects, and a data sheet.
To connect the GPS unit to the Pi, follow these pinout instructions:
GP-20U7 --> Pi VCC --> 3V GND --> GND TX --> RX
Our GPS analog to the Donkey Car manage.py. Add parts to the DK vehicle and calls Vehicle.py.
DonkeyCar, time, threading
Reads GPS data from the Pi serial port. Waits for identifier in strings to parse relevant GPS data (latitude, longitude coordinates).
numpy, serial, pynmea2
Takes GPS coordinates of current and previous time step to calculate distance and bearing to goal. Uses distance and bearing data to calculate the throttle and steering commands, respectively.
Our distance equations were based on the haversine derivations on this page.
A Python implementation of the haversine equation can be found in our planner.py part.
- Calculate the bearing θi of the vector made by the current location and the goal point, with respect to North.
- Calculate the bearing ψi of the vector made by the previous time step location and the current location, with respect to North.
Our bearing calculation method is outlined at this page.
extract lat and long coordinates lat1 = pointA lon1 = pointA lat2 = pointB lon2 = pointB
diffLon = lon2 - lon1 x = sin(diffLon) * cos(lat2) y = cos(lat1) * sin(lat2) - (sin(lat1)*cos(lat2)*cos(diffLon))
initialHeading = arctan2(x, y)
Results of a typical two point waypoint navigation. The first waypoint, "Warren Mall", is shown in red. The threshold goal circle surrounding the waypoint is shown as the dashed circle. The graph shows that the car did trigger the "drive in circle" method once the goal threshold was reached.