I love traveling. But I don't like stopping to take pictures. But I STILL want pictures. So I decided to make my own Personal Automated GPS Controlled Portable Photo Taker!
This project is a backpack that takes pictures when I am close to places that I've pre-selected. And what better place to test it than in London?
I hooked up a GPS module to a Raspberry Pi (powered by a battery pack) which sends signals through WiFi to a GoPro.
- GPS: No soldering today! I just plugged the GPS module to the Raspberry Pi vis USB.
- WiFi: I turned on the WiFi of the GoPro and connected the Raspberry Pi to it. The WiFi SSD is configured by the GoPro App.
- Raspberry Pi: I plugged it to the battery pack.
All set! You can add the GoPro Arm to anything you’d like! I chose a backpack to use when I travel.
I compiled a list of coordinates of the places I wanted to visit in London. Then I wrote a script in Python (LondonGPS.py) to calculate the distance between the coordinates I am at and the coordinates of my pre-selected locations.
The script runs on startup in my Raspberry Pi so it can start running the script and checking my coordinates as soon as I turn on the battery pack.
pip install goprocam
Then, in the LondonGPS.py script I initialized the camera:
camera = GoProCamera.GoPro()
And to take pictures:
#0 is the time it waits before the picture is taken. camera.take_photo(0)
I installed gpsd-py3 through pip. To get the gpsd installed and started I followed this: https://pypi.python.org/pypi/gpsd-py3/0.2.0.
Then I pointed the gps daemon to the GPS device. On my Pi, I edited the file /etc/rc.local and added the following line:
gpsd /dev/ttyACM0 -F /var/run/gpsd.sock
In the same file on my Pi /etc/rc.local I added the command to run my script.
All the calculations are made in the python script attached below.
Check it out and make your own PERSONAL AUTOMATED GPS CONTROLLED PORTABLE PHOTO TAKER!
Comment below what you think and which places you would add! Don't forget to subscribe to my YouTube channel to be the first to know when the new videos are out: https://www.youtube.com/c/estefanniegg.
#Import all necessary libraries import time import gpsd import math from goprocam import GoProCamera from goprocam import constants #Need this to calculate the where I am earthRadius = 6371 #Wait for the Pi to boot and get the GoPro Wifi time.sleep(20) #Connect to the local gpsd gpsd.connect() #Initialize the camera object camera = GoProCamera.GoPro() #Saved Locations for this trip: #Platform 9 3/4: 51.5322° , -0.1240° #Abbey Road: 51.5321° , -0.1781° #Buckingham 51.5014°, -0.1419° #Big Ben 51.5007° , -0.1246° #Tower of London 51.5081° , -0.0759° #Tower Bridge 51.5055° , -0.0754° #Shakespeare Globe 51.5081° , -0.0972° #Sweetings 51.5125° , -0.0928° #Create location arrays: latitude = [51.5110, 51.5322, 51.5321, 51.5014, 51.5007, 51.5081, 51.5055, 51.5081, 51.5125] longitude = [-0.1863, -0.1240, -0.1781, -0.1419, -0.1246, -0.0759, -0.0754, -0.0972, -0.0928] # Main loop to check the coordinates that I am at # and the coordinates I’ve saved. while True: received = False try: packet = gpsd.get_current() received = True except Exception: print("No signal") if received == True: #get my current position currentPost = packet.position() currentLat = currentPost currentLon = currentPost for location in range(len(latitude)): # The angles need to be in radians to pass # to trig functions dLat = math.radians(latitude[location] - currentLat) dLon = math.radians(longitude[location] - currentLon) # I used the ‘haversine’ formula to calculate # the distance between two points over the # earth’s surface. # a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2) # c = 2 ⋅ atan2( √a, √(1−a) ) #d = R ⋅ c a = math.sin(dLat/2) * math.sin(dLat/2) + math.cos(math.radians(latitude[location])) * math.cos(math.radians(currentLat)) * math.sin(dLon/2) * math.sin(dLon/2) c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)) d = earthRadius * c # d is distance between the two sets of coordinates # if distance is less than 10m unit of d is in km, # take a picture if d < 0.01: camera.take_photo(0) #we need to sleep so it doesn't infinitely poll time.sleep(1)