Skip to content

Commit

Permalink
Add In Position and Orientation Configs
Browse files Browse the repository at this point in the history
  • Loading branch information
mchadwick-iqt committed Feb 9, 2023
1 parent 53d41bf commit 247ae28
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 33 deletions.
47 changes: 38 additions & 9 deletions axis-ptz/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
angularVelocityVertical = 0 # in meters
planeTrack = 0 # This is the direction that the plane is moving in

camera_roll = 0
camera_pitch = 0
camera_yaw = 0

currentPlane = None

camera_latitude = None
Expand Down Expand Up @@ -528,16 +532,15 @@ def moveCamera(ip, username, password):
E_XYZ_to_ENz, e_E_XYZ, e_N_XYZ, e_z_XYZ = utils.compute_E(t_lambda, t_varphi)
r_XYZ_t = utils.compute_r_XYZ(t_lambda, t_varphi, t_h)

# Compute the rotations from the XYZ coordinate system to the uvw
# (camera housing fixed) coordinate system
alpha = 0.0 # [deg]
beta = 0.0 # [deg]
gamma = 0.0 # [deg]
q_alpha, q_beta, q_gamma, E_XYZ_to_uvw, _, _, _ = compute_rotations(
e_E_XYZ, e_N_XYZ, e_z_XYZ, alpha, beta, gamma, 0.0, 0.0
)

while True:
# Compute the rotations from the XYZ coordinate system to the uvw
# (camera housing fixed) coordinate system
alpha = camera_yaw # [deg]
beta = camera_pitch # [deg]
gamma = camera_roll # [deg]
q_alpha, q_beta, q_gamma, E_XYZ_to_uvw, _, _, _ = compute_rotations(
e_E_XYZ, e_N_XYZ, e_z_XYZ, alpha, beta, gamma, 0.0, 0.0
)
if active:
if not "icao24" in currentPlane:
logging.info(" 🚨 Active but Current Plane is not set")
Expand Down Expand Up @@ -596,10 +599,15 @@ def update_config(config):
global cameraDelay
global cameraPan
global camera_lead
global camera_longitude
global camera_latitude
global camera_altitude
global cameraBearingCorrection
global inhibitPhotos
global capturePeriod
global camera_roll
global camera_pitch
global camera_yaw

if "cameraZoom" in config:
cameraZoom = int(config["cameraZoom"])
Expand All @@ -616,6 +624,12 @@ def update_config(config):
if "cameraAltitude" in config:
camera_altitude = float(config["cameraAltitude"])
logging.info("Setting Camera Altitude to: {}".format(camera_altitude))
if "cameraLatitude" in config:
camera_latitude = float(config["cameraLatitude"])
logging.info("Setting Camera Latitude to: {}".format(camera_latitude))
if "cameraLongitude" in config:
camera_longitude = float(config["cameraLongitude"])
logging.info("Setting Camera Longitude to: {}".format(camera_longitude))
if "cameraBearingCorrection" in config:
cameraBearingCorrection = float(config["cameraBearingCorrection"])
logging.info(
Expand All @@ -630,6 +644,15 @@ def update_config(config):
if "capturePeriod" in config:
capturePeriod = float(config["capturePeriod"])
logging.info("Setting Camera Capture Period (sec) to: {}".format(capturePeriod))
if "cameraRoll" in config:
camera_roll = float(config["cameraRoll"])
logging.info("Setting Camera Roll Angle to: {}".format(camera_roll))
if "cameraPitch" in config:
camera_pitch = float(config["cameraPitch"])
logging.info("Setting Camera Pitch Angle to: {}".format(camera_pitch))
if "cameraYaw" in config:
camera_yaw = float(config["cameraYaw"])
logging.info("Setting Camera Yaw Angle to: {}".format(camera_yaw))


#############################################
Expand All @@ -650,6 +673,9 @@ def on_message_impl(client, userdata, message):
global camera_longitude
global camera_latitude
global camera_altitude
global camera_roll
global camera_pitch
global camera_yaw

global active

Expand Down Expand Up @@ -704,6 +730,9 @@ def on_message_impl(client, userdata, message):
camera_longitude = float(update["long"])
camera_latitude = float(update["lat"])
camera_altitude = float(update["alt"])
camera_roll = float(update["roll"])
camera_pitch = float(update["pitch"])
camera_yaw = float(update["yaw"])
else:
logging.info(
"Message: {} Object: {} Flight: {}".format(
Expand Down
228 changes: 204 additions & 24 deletions notebook-server/Config.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,6 @@
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"source": [
"## Camera Altitude"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraAltitude'] = -2 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -331,10 +311,11 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Time Between Saving Photosa\n",
"## Time Between Saving Photos\n",
"Sets the time between photo saves - IN MILLISECONDS. This is defaulted to 1000"
]
},
Expand All @@ -350,13 +331,212 @@
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Roll Angle of Camera"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraRoll'] = 0 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Pitch Angle of Camera"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraPitch'] = 0 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Yaw Angle of Camera"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraYaw'] = 0 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Latitude of Camera"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraLatitude'] = 38.890022390623265 # Latitude of the camera\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Longitude of Camera"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraLongitude'] = -77.03513244930217 # Longitude of the camera\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Altitude of Camera"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraAltitude'] = 170 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Position of Camera"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraLatitude'] = 38.890022390623265 # Latitude of the camera\n",
"data['cameraLongitude'] = -77.03513244930217 # Longitude of the camera\n",
"data['cameraAltitude'] = 170 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Orientation of Camera"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"data = {}\n",
"data['cameraYaw'] = 0 # Update this Value\n",
"data['cameraPitch'] = 0 # Update this Value\n",
"data['cameraRoll'] = 0 # Update this Value\n",
"json_data = json.dumps(data)\n",
"client.publish(\"skyscan/config/json\",json_data)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Send Example EGI Message"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.connect(broker)\n",
"state = {}\n",
"state['time'] = time.strftime(\"%Y-%m-%dT%H:%M:%SZ\",time.gmtime())\n",
"state['lat'] = 38.890022390623265\n",
"state['long'] = -77.03513244930217\n",
"state['alt'] = 170\n",
"state['roll'] = 0\n",
"state['pitch'] = 0\n",
"state['yaw'] = 0\n",
"state['fix'] = 0\n",
"json_data = json.dumps(state)\n",
"client.publish(\"skyscan/egi\",json_data)\n"
]
}

],
"metadata": {
"kernelspec": {
"name": "python385jvsc74a57bd064065cc917a2354f02e26dd1b65d7c93af3dc848180e46cdb05a49f40c8c24c8",
"display_name": "Python 3.8.5 64-bit ('tinyml': conda)"
"display_name": "Python 3.8.5 64-bit ('tinyml': conda)",
"name": "python385jvsc74a57bd064065cc917a2354f02e26dd1b65d7c93af3dc848180e46cdb05a49f40c8c24c8"
},
"language_info": {
"codemirror_mode": {
Expand Down

0 comments on commit 247ae28

Please sign in to comment.