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

Mono #14

Merged
merged 31 commits into from
Apr 19, 2021
Merged

Mono #14

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
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
More configs
  • Loading branch information
luke-iqt committed Mar 22, 2021
commit 0582147a778d694b9e08b6893ddc36d1a2f74ef6
84 changes: 72 additions & 12 deletions Config.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x7f8d010481d0>"
"<paho.mqtt.client.MQTTMessageInfo at 0x7f8d01052720>"
]
},
"execution_count": 46,
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -95,24 +95,24 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x7f8d01045d10>"
"<paho.mqtt.client.MQTTMessageInfo at 0x7f8d0104a270>"
]
},
"execution_count": 43,
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraDelay'] = 99 # Update this Value\n",
"data['cameraDelay'] = 0.25 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
Expand All @@ -127,24 +127,24 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x7f8d01015f40>"
"<paho.mqtt.client.MQTTMessageInfo at 0x7f8d0104a220>"
]
},
"execution_count": 45,
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraMoveSpeed'] = 0.25 # Update this Value\n",
"data['cameraMoveSpeed'] = 99 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
Expand All @@ -157,6 +157,45 @@
"This is how far the tracker should move the center point in front of the currently tracked plane. It is a float, and is measured in seconds, example: 0.25 . It is based on the planes current heading and how fast it is going. "
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<paho.mqtt.client.MQTTMessageInfo at 0x7f8d0104a2c0>"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraLead'] = 0.25 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Camera Bearing\n",
"This is a float to correct the cameras heading to help it better align with True North. It can be from -180 to 180. "
]
},
{
"cell_type": "code",
"execution_count": 41,
Expand All @@ -177,7 +216,28 @@
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraLead'] = 0.25 # Update this Value\n",
"data['cameraBearing'] = 0 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Minimum Elevation\n",
"The minimum elevation above the horizon which the Tracker will follow an airplane. Int value between 0-90 degrees."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['minElevation'] = 45 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
Expand Down
13 changes: 9 additions & 4 deletions axis-ptz/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
cameraZoom = None
cameraMoveSpeed = None
cameraDelay = None
cameraBearing = 0
object_topic = None
flight_topic = None
config_topic = "skyscan/config/json"
Expand Down Expand Up @@ -76,8 +77,7 @@ def setXY(x,y):

def setPan(bearing):
global pan
camera_bearing = args.bearing
diff_heading = getHeadingDiff(bearing, camera_bearing)
diff_heading = getHeadingDiff(bearing, cameraBearing)


if pan != bearing: #abs(pan - diff_heading) > 2: #only update the pan if there has been a big change
Expand Down Expand Up @@ -239,6 +239,7 @@ def update_config(config):
global cameraZoom
global cameraMoveSpeed
global cameraDelay
global cameraBearing

if "cameraZoom" in config:
cameraZoom = int(config["cameraZoom"])
Expand All @@ -247,9 +248,11 @@ def update_config(config):
cameraDelay = float(config["cameraDelay"])
logging.info("Setting Camera Delay to: {}".format(cameraDelay))
if "cameraMoveSpeed" in config:
cameraMoveSpeed = int("cameraMoveSpeed")
cameraMoveSpeed = int(config["cameraMoveSpeed"])
logging.info("Setting Camera Move Speed to: {}".format(cameraMoveSpeed))

if "cameraBearing" in config:
cameraBearing = float(config["cameraBearing"])
logging.info("Setting Bearing Correction to: {}".format(cameraBearing))
#############################################
## MQTT Callback Function ##
#############################################
Expand Down Expand Up @@ -297,6 +300,7 @@ def main():
global cameraDelay
global cameraMoveSpeed
global cameraZoom
global cameraBearing
global cameraConfig
global flight_topic
global object_topic
Expand Down Expand Up @@ -339,6 +343,7 @@ def main():
cameraDelay = args.camera_delay
cameraMoveSpeed = args.camera_move_speed
cameraZoom = args.camera_zoom
cameraBearing = args.camera_bearing
cameraConfig = vapix_config.CameraConfiguration(args.axis_ip, args.axis_username, args.axis_password)

threading.Thread(target = moveCamera, daemon = True).start()
Expand Down
5 changes: 4 additions & 1 deletion mqtt-message.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ The JSON blob has different config values. There are no required fields. The fol
- cameraZoom - int value from 0 - 9999
- cameraDelay - float value for the number of seconds to wait after sending the camera move API command, before sending the take picture API command.
- cameraMoveSpeed - This is how fast the camea will move. It is an Int number between 0-99 (max)
- cameraLead - This is how far the tracker should move the center point in front of the currently tracked plane. It is a float, and is measured in seconds, example: 0.25 . It is based on the planes current heading and how fast it is going.
- cameraLead - This is how far the tracker should move the center point in front of the currently tracked plane. It is a float, and is measured in seconds, example: 0.25 . It is based on the planes current heading and how fast it is going.
- cameraBearing - This is a float to correct the cameras heading to help it better align with True North. It can be from -180 to 180.
- minElevation - The minimum elevation above the horizon which the Tracker will follow an airplane. Int value between 0-90 degrees.
-
5 changes: 4 additions & 1 deletion tracker/flighttracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,14 @@ def dict(self):

def update_config(config):
global camera_lead
global min_elevation

if "cameraLead" in config:
camera_lead = float(config["cameraLead"])
logging.info("Setting Camera Lead to: {}".format(camera_lead))

if "minElevation" in config:
min_elevation = int(config["minElevation"])
logging.info("Setting Min. Elevation to: {}".format(minElevation))

def on_message(client, userdata, message):
global camera_altitude
Expand Down