Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merging in Dev branch #2

Merged
merged 74 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
cfd53c2
initial commit
luke-iqt Dec 18, 2020
ab039c5
Update README.md
luke-iqt Dec 18, 2020
377fb22
adding a builtin DB
luke-iqt Dec 19, 2020
6820f38
Update flighttracker.py
luke-iqt Dec 19, 2020
49b8ccd
Dockerized!
luke-iqt Dec 21, 2020
f3bc8e1
Update docker-compose.yml
luke-iqt Dec 21, 2020
665fe4b
Update flighttracker.py
luke-iqt Dec 21, 2020
3e3d447
adding azimuth calculations
luke-iqt Dec 21, 2020
de058a2
Add a camera listener
luke-iqt Dec 22, 2020
86e74dd
controlling the pan tilt hat - basic
luke-iqt Dec 22, 2020
659f083
permission to access the I2C bus
luke-iqt Dec 22, 2020
7f57e5d
Update docker-compose.yml
luke-iqt Dec 22, 2020
1ba7afd
Update docker-compose.yml
luke-iqt Dec 22, 2020
e5a30d0
Update requirements.txt
luke-iqt Dec 22, 2020
f5a6c61
Update camera.py
luke-iqt Dec 22, 2020
9d8f94b
so that is how you ref dicts
luke-iqt Dec 22, 2020
b5436c2
Update camera.py
luke-iqt Dec 22, 2020
5cfe059
Update camera.py
luke-iqt Dec 22, 2020
0dffad5
Update camera.py
luke-iqt Dec 22, 2020
98063f9
Update camera.py
luke-iqt Dec 22, 2020
aec3975
Update camera.py
luke-iqt Dec 22, 2020
f3ba1a5
better pan calculations
luke-iqt Dec 22, 2020
ee5fbd5
better messages
luke-iqt Dec 22, 2020
758cbb3
Update camera.py
luke-iqt Dec 22, 2020
f21a428
Update camera.py
luke-iqt Dec 22, 2020
41e3520
Update flighttracker.py
luke-iqt Dec 22, 2020
eee7900
Update camera.py
luke-iqt Dec 22, 2020
89126e7
Update camera.py
luke-iqt Dec 22, 2020
cff5528
Update camera.py
luke-iqt Dec 22, 2020
2c1da38
Update camera.py
luke-iqt Dec 23, 2020
b77b0b3
Update camera.py
luke-iqt Dec 23, 2020
ff1c35b
Update camera.py
luke-iqt Dec 23, 2020
e272f04
Update camera.py
luke-iqt Dec 23, 2020
398e20a
Update camera.py
luke-iqt Dec 23, 2020
9d0f0b1
Update camera.py
luke-iqt Dec 23, 2020
4c14865
Update camera.py
luke-iqt Dec 23, 2020
6bfb3fd
Update camera.py
luke-iqt Dec 23, 2020
e5b2c4c
Update camera.py
luke-iqt Dec 23, 2020
bf2ae91
Update camera.py
luke-iqt Dec 23, 2020
bc619ab
photo snapping
luke-iqt Dec 24, 2020
7807678
Update docker-compose.yml
luke-iqt Dec 26, 2020
a5e6161
better linking
luke-iqt Dec 26, 2020
7d41ef2
Update docker-compose.yml
luke-iqt Dec 26, 2020
7fb0907
Update docker-compose.yml
luke-iqt Dec 26, 2020
a917696
fix for picam?
luke-iqt Dec 26, 2020
985e835
Update README.md
luke-iqt Dec 26, 2020
5298708
Update camera.py
luke-iqt Dec 26, 2020
5e2c38d
Update camera.py
luke-iqt Dec 26, 2020
834693a
Update camera.py
luke-iqt Dec 26, 2020
6731e2d
Update camera.py
luke-iqt Dec 26, 2020
a1e0207
Update camera.py
luke-iqt Dec 26, 2020
2008809
base elevation
luke-iqt Dec 28, 2020
a101dcc
Update camera.py
luke-iqt Dec 28, 2020
06b78b1
Added a ADSB-MQTT bridge
luke-iqt Jan 5, 2021
1c6ed02
Tracking with Axis PTZ
luke-iqt Jan 7, 2021
4ca9969
corrected terms: azimuth->elevation
luke-iqt Jan 7, 2021
33c1c56
added customized folders for saving pictures
luke-iqt Jan 8, 2021
8d22750
Update utils.py
luke-iqt Jan 8, 2021
caf28f9
changing permissions
luke-iqt Jan 8, 2021
c57895e
Update dockerfile
luke-iqt Jan 8, 2021
2a12d45
Update docker-compose.yml
luke-iqt Jan 8, 2021
e672725
Update docker-compose.yml
luke-iqt Jan 8, 2021
b9053f6
correcting docker-compose build
luke-iqt Jan 8, 2021
32d8e88
cleaned up printing
luke-iqt Jan 9, 2021
aefa14f
added restart
luke-iqt Jan 9, 2021
5ab3b28
Update flighttracker.py
luke-iqt Jan 9, 2021
f372af4
fix a divide by zero error
luke-iqt Jan 9, 2021
115e620
setting altitude
luke-iqt Jan 9, 2021
077245f
Update flighttracker.py
luke-iqt Jan 9, 2021
83048c5
Update camera.py
luke-iqt Jan 9, 2021
23be7db
added additional configuration
luke-iqt Jan 11, 2021
92f6496
Update README.md
luke-iqt Jan 11, 2021
3dc8351
updating readme
luke-iqt Jan 11, 2021
4fc9f83
improved documentation
luke-iqt Jan 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
corrected terms: azimuth->elevation
  • Loading branch information
luke-iqt committed Jan 7, 2021
commit 4ca9969a17be4668c0d0e902990499ad283ba26c
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.env
notes.md
axis-ptz/*.jpg
6 changes: 6 additions & 0 deletions adsb-mqtt/adsb-mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,17 @@ def dump1090Read(self) -> str:
try:
buffer = self.__dump1090_sock.recv(4096)
except ConnectionResetError:
logging.critical("Connection Reset Error")
self.dump1090Close()
yield None
except socket.error:
logging.critical("Socket Error")
self.dump1090Close()
yield None
buffer = buffer.decode("utf-8")
buffering = True
if buffer == "":
logging.critical("Buffer Empty")
self.dump1090Close()
return None
while buffering:
Expand All @@ -393,9 +396,11 @@ def dump1090Read(self) -> str:
try:
more = self.__dump1090_sock.recv(4096)
except ConnectionResetError:
logging.critical("Connection Reset Error")
self.dump1090Close()
yield None
except socket.error:
logging.critical("Socket Error")
self.dump1090Close()
yield None
if not more:
Expand All @@ -404,6 +409,7 @@ def dump1090Read(self) -> str:
if not isinstance(more, str):
more = more.decode("utf-8")
if more == "":
logging.critical("Receive Empty")
self.dump1090Close()
return None
buffer += more
Expand Down
2 changes: 1 addition & 1 deletion adsb-mqtt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def deg2rad(deg: float) -> float:
"""
return deg * (math.pi/180)

def azimuth(distance: float, altitude, camera_altitude):
def elevation(distance: float, altitude, camera_altitude):
baseElevation = camera_altitude
ratio = ( altitude - baseElevation) / distance
a = math.atan(ratio) * (180 /math.pi)
Expand Down
24 changes: 14 additions & 10 deletions axis-ptz/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import errno
import paho.mqtt.client as mqtt
from json.decoder import JSONDecodeError
from sensecam_control import vapix_control
from sensecam_control import vapix_control,vapix_config



tiltCorrect = 15
args = None
camera = None
cameraConfig = None
pan = 0
tilt = 0
actualPan = 0
Expand Down Expand Up @@ -67,13 +68,13 @@ def setPan(bearing):
return True
return False

def setTilt(azimuth):
def setTilt(elevation):
global tilt
if azimuth < 90:
if abs(tilt-azimuth) > 2:
tilt = azimuth
if elevation < 90:
if abs(tilt-elevation) > 2:
tilt = elevation

#logging.info("Setting Tilt to: %d"%azimuth)
#logging.info("Setting Tilt to: %d"%elevation)

def moveCamera():
global actualPan
Expand All @@ -88,8 +89,9 @@ def moveCamera():
actualTilt = tilt
actualPan = pan
lockedOn = True
camera.absolute_move(pan, tilt, 5000, 50)

camera.absolute_move(pan, tilt, 9999, 50)
time.sleep(0.1)
cameraConfig.get_jpeg_request("1920x1080", camera=1,compression=10)


#if lockedOn == True:
Expand Down Expand Up @@ -120,9 +122,9 @@ def on_message(client, userdata, message):
except:
print("Caught it!")

logging.info("{}\tBearing: {} \tAzimuth: {}".format(update["icao24"],update["bearing"],update["azimuth"]))
logging.info("{}\tBearing: {} \tElevation: {}".format(update["icao24"],update["bearing"],update["elevation"]))
bearingGood = setPan(update["bearing"])
setTilt(update["azimuth"])
setTilt(update["elevation"])
currentPlane = update["icao24"]

def main():
Expand All @@ -131,6 +133,7 @@ def main():
global pan
global tilt
global camera
global cameraConfig

parser = argparse.ArgumentParser(description='An MQTT based camera controller')

Expand Down Expand Up @@ -163,6 +166,7 @@ def main():

logging.info("---[ Starting %s ]---------------------------------------------" % sys.argv[0])
camera = vapix_control.CameraControl(args.axis_ip, args.axis_username, args.axis_password)
cameraConfig = vapix_config.CameraConfiguration(args.axis_ip, args.axis_username, args.axis_password)
threading.Thread(target = moveCamera, daemon = True).start()
# Sleep for a bit so we're not hammering the HAT with updates
time.sleep(0.005)
Expand Down
66 changes: 66 additions & 0 deletions axis-ptz/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python3



import argparse
import logging
import coloredlogs
import sys
import os
import time
from sensecam_control import vapix_control,vapix_config


def main():

global camera
global cameraConfig

parser = argparse.ArgumentParser(description='An MQTT based camera controller')


parser.add_argument('-u', '--axis-username', help="Username for the Axis camera", required=True)
parser.add_argument('-p', '--axis-password', help="Password for the Axis camera", required=True)
parser.add_argument('-a', '--axis-ip', help="IP address for the Axis camera", required=True)

args = parser.parse_args()
print("hello")

styles = {'critical': {'bold': True, 'color': 'red'}, 'debug': {'color': 'green'}, 'error': {'color': 'red'}, 'info': {'color': 'white'}, 'notice': {'color': 'magenta'}, 'spam': {'color': 'green', 'faint': True}, 'success': {'bold': True, 'color': 'green'}, 'verbose': {'color': 'blue'}, 'warning': {'color': 'yellow'}}
level = logging.DEBUG if '-v' in sys.argv or '--verbose' in sys.argv else logging.INFO
if 1:
coloredlogs.install(level=level, fmt='%(asctime)s.%(msecs)03d \033[0;90m%(levelname)-8s '
''
'\033[0;36m%(filename)-18s%(lineno)3d\033[00m '
'%(message)s',
level_styles = styles)
else:
# Show process name
coloredlogs.install(level=level, fmt='%(asctime)s.%(msecs)03d \033[0;90m%(levelname)-8s '
'\033[0;90m[\033[00m \033[0;35m%(processName)-15s\033[00m\033[0;90m]\033[00m '
'\033[0;36m%(filename)s:%(lineno)d\033[00m '
'%(message)s')
print("hello")
logging.info("---[ Starting %s ]---------------------------------------------" % sys.argv[0])
camera = vapix_control.CameraControl(args.axis_ip, args.axis_username, args.axis_password)
print("hello")
#############################################
## Main Loop ##
#############################################
while True:
camera.absolute_move(0, 0, 0, 50)
time.sleep(5)
camera.absolute_move(90, 0, 0, 50)
time.sleep(5)
camera.absolute_move(180, 0, 0, 50)
time.sleep(5)
camera.absolute_move(270, 0, 0, 50)
time.sleep(5)
camera.absolute_move(0, 90, 0, 50)
time.sleep(5)

if __name__ == "__main__":
try:
main()
except Exception as e:
logging.critical(e, exc_info=True)
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:

tracker:
build: ./tracker
entrypoint: "./flighttracker.py -H piaware -m mqtt -l ${LAT} -L ${LONG} -P skyscan/planes/json -T skyscan/tracking/json -M ${MIN_AZIMUTH} "
entrypoint: "./flighttracker.py -H piaware -m mqtt -l ${LAT} -L ${LONG} -P skyscan/planes/json -T skyscan/tracking/json -M ${MIN_ELEVATION} "
depends_on:
- mqtt

Expand Down
2 changes: 1 addition & 1 deletion env-example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TZ="New York"
LAT=38.890022390623265
LONG=-77.03513244930217
MIN_AZIMUTH=45
MIN_ELEVATION=45
FEEDER_ID=long-api-key-goes-here
AXIS_USERNAME=user
AXIS_PASSWORD=pass
Expand Down
14 changes: 7 additions & 7 deletions pan-tilt-pi/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def setPan(bearing):
return True
return False

def setTilt(azimuth):
def setTilt(elevation):
global tilt
if azimuth < 90:
if abs(tilt-azimuth) > 2:
tilt = azimuth
if elevation < 90:
if abs(tilt-elevation) > 2:
tilt = elevation

logging.info("Setting Tilt to: %d"%azimuth)
logging.info("Setting Tilt to: %d"%elevation)

def moveCamera():
global actualPan
Expand Down Expand Up @@ -137,9 +137,9 @@ def on_message(client, userdata, message):
except:
print("Caught it!")

#logging.info("Bearing: {} Azimuth: {}".format(update["bearing"],update["azimuth"]))
#logging.info("Bearing: {} Elevation: {}".format(update["bearing"],update["elevation"]))
bearingGood = setPan(update["bearing"])
setTilt(update["azimuth"])
setTilt(update["elevation"])
currentPlane = update["icao24"]

def main():
Expand Down
Loading