Skip to content

Commit

Permalink
better readme
Browse files Browse the repository at this point in the history
  • Loading branch information
robotastic committed Mar 1, 2024
1 parent 30fb333 commit bd8f68b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,22 @@
<h1 align="center">EdgeTech-Template</h1>

<p align="center">
This repo is a template of how to build on <a href="https://github.com/IQTLabs/edgetech-core">IQT Labs EdgeTech-Core</a> functionality to instantiate an <a href="https://projects.eclipse.org/projects/iot.mosquitto">MQTT</a> client. The philosophy behind EdgeTech-Core is to minimize development requirements for standing up the software stack of an "edge" system. The template includes all of the files and code scaffolds required to build in the EdgeTech framework. All of this functionality is wrapped in a Docker container for cross-platform compatibility.
This repo is designed to be part of a SkyScan system. SkyScan automatically points a Pan Tilt Zoom (PTZ) camera at an aircraft based on the location information broadcast in an ADS-B message. SkyScan C2 ingests a ledger of potentional aircraft and selects one to point the camera at. It is run as a Docker container and messages are passed to it using MQTT.
<br/>
<br/>
You'll need to rename various files and directories as well as customize based on your functional needs, but the EdgeTech framework and scaffolding should minimize the development requirements. If you don't find that to be the case, submit a pull request and help us make this repository better!
<h3>Configuration</h3>
SkyScan C2 makes it selection based on the distance of aircraft from the camera location. Based on where the camera is located and weather conditions, it may not be able to see all of the surrounding aircrarft. You can have SkyScan C2 ignore these obscured aircraft by configuring the following environment variables:
- **MIN_TILT**: The minimum tilt angle above the horizon for the camera. This is useful for when trees or buildings might obscure the horizon
- **MIN_ALTITUDE**: The minimum altitude of an aircraft. This is useful when there are nearby aircraft that are on the ground and should be ignored.
- **MAX_ALTITUDE**: The maximum altitude of an aircraft. This is useful when there are clouds and you want to ignore any aircrafts that are in the clouds.
<br/>
<br/>
<h3>Docker Compose</h3>
SkyScan is designed to be stood up as a series of Docker containers. Docker Compose makes it easy to do coordinate all of the containers. The <a href="https://github.com/IQTLabs/edgetech-skyscan">EdgeTech SkyScan</a> repo provides an example of a `docker-compose.yaml` file that can be used to startup an instance. The `docker-compose.yaml` file include in this repo provides a minimal example of how to start and configure a SkyScan C2 container. You can use this Docker Compose file as a starting point if you wish to include the SkyScan C2 container in a custom system.
<br/>
<br/>
<h3>Environment Files</h3>
Environment files are used to capture the configuration of SkyScan C2.
<br/>
<br/>
<a href="https://github.com/IQTLabs/edgetech-template/pulls">Make Contribution</a>
Expand Down
20 changes: 9 additions & 11 deletions skyscan-c2/c2_pub_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(
self.rho_c,
self.tau_c,
)
logging.info(f"Initial E_XYZ_to_uvw: {self.E_XYZ_to_uvw}")


# create MQTT client connection
self.connect_client()
Expand Down Expand Up @@ -262,7 +262,6 @@ def _calculate_camera_angles(self: Any, data: Any) -> tuple[float, float, float]
self.tau_o = math.degrees(
math.atan2(r_uvw_o_1_t[2], axis_ptz_utilities.norm(r_uvw_o_1_t[0:2]))
) # [deg]
logging.info(f"Camera pan and tilt to object: {self.rho_o}, {self.tau_o} [deg]")

return self.rho_o, self.tau_o, self.distance3d

Expand Down Expand Up @@ -377,7 +376,6 @@ def _config_callback(
def _target_selection_callback(
self: Any, _client: mqtt.Client, _userdata: Dict[Any, Any], msg: Any
) -> None:
logging.debug("Ledger recieved")
payload_dict = json.loads(str(msg.payload.decode("utf-8")))

if "ObjectLedger" in payload_dict.keys():
Expand All @@ -388,7 +386,6 @@ def _target_selection_callback(
object_ledger_df["age"] = time() - object_ledger_df["timestamp"]

if len(object_ledger_df):
logging.debug("Ledger not empty")
### some logic to select which target
target = None

Expand Down Expand Up @@ -422,10 +419,10 @@ def _target_selection_callback(
object_ledger_df["altitude"] > self.max_altitude
)

logging.info(f"Object ledger: {object_ledger_df.to_string()}")
#logging.info(f"Object ledger: {object_ledger_df.to_string()}")
if not object_ledger_df.empty and not self.override_object:
logging.debug("Standard distance thresholding")
object_ledger_df = object_ledger_df[
target_ledger_df = object_ledger_df[
(
object_ledger_df["relative_distance"]
<= self.object_distance_threshold
Expand All @@ -434,13 +431,13 @@ def _target_selection_callback(
& (object_ledger_df["min_altitude_fail"] == False)
& (object_ledger_df["max_altitude_fail"] == False)
]
if not object_ledger_df.empty:
if not target_ledger_df.empty:
logging.debug("Object[s] within distance threshold")
target = object_ledger_df.sort_values(
target = target_ledger_df.sort_values(
by="relative_distance", ascending=True
).iloc[0]
else:
logging.info("No object[s] within distance threshold")
logging.debug("No object[s] within distance threshold")
elif self.override_object and not object_ledger_df.empty:
logging.debug("Override object selection")
selection_df = object_ledger_df[
Expand Down Expand Up @@ -550,8 +547,9 @@ def main(self: Any) -> None:
)
self.add_subscribe_topic(self.config_topic, self._config_callback)
self.add_subscribe_topic(self.ledger_topic, self._target_selection_callback)
self.add_subscribe_topic(self.manual_override_topic, self._target_selection_callback)

self.add_subscribe_topic(
self.manual_override_topic, self._target_selection_callback
)

while True:
try:
Expand Down

0 comments on commit bd8f68b

Please sign in to comment.