ProxThreat Demonstration

This notebook showcases the ability of the drone to detect and respond to threats in the Contingency scenario.

Copyright © 2024, United States Government, as represented by the Administrator of the National Aeronautics and Space Administration. All rights reserved.

The “"Fault Model Design tools - fmdtools version 2"” software is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. 

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
from examples.airspacelib.contingencymanagement.aircraft import ContingencyAircraftArchitecture, plot_flightpath, properties, collections
from fmdtools.define.architecture.function import FunctionArchitectureGraph

from fmdtools.sim import propagate as prop

The model builds on the Contingency model showcased in demo_notebook.ipynb.

haa = ContingencyAircraftArchitecture()

This work added a GeomArchitecture to represent the spacial boundaries of the drone and other aircraft which may be in the airspace.

As shown below, the scenario considered has one drone (called self) and another drone (called uav) that fly over the environment. self has a defined flightpath from its start to end location (from the lower left to upper right), and uav is considered a rogue uav that has a flight that interferes with the flightplan (flying from the lower right to the upper left).

The Geom objects for each define:

  • The envelope, which is the physical boundary of the object

  • The speed boundary, which defines the boundary of where the object could be at the next timestep

  • The safety boundary, which is minimum safe distance the objects must be from each other

fig, ax = haa.flows['environment'].c.show(properties=properties, collections=collections)
fig, ax = haa.flows['environment'].ga.show(fig=fig, ax=ax)
../../../_images/b19a14695aec681b6f9c2cabd3f7a59b30836224dae7e9e1036ec47c72a6611d.png

To avoid hitting the UAV, a behavior was added to the aircraft that causes it to pause its flight if it within the safety boundary of the external UAV.

This is a very simple avoidance maneuver and would not help in a wide range of scenarios (e.g., if the UAV was flying towards it rather than in front of it). Nevertheless, it can demonstrate the value of ProxThreat functionality when simulated:

res, hist = prop.nominal(haa)

As shown here, the behavior activates a few times during the flight, causing it to enter the pause mode when the closest_dist (the distance to the safety envelope of the uav) is 0:

hist.plot_line('flows.electricity.s.charge',
               'fxns.control_flight.m.mode',
               'fxns.control_flight.s.closest_dist',
               'fxns.aviate.m.mode')
(<Figure size 600x400 with 4 Axes>,
 array([<Axes: title={'center': 'flows.electricity.s.charge'}, xlabel=' '>,
        <Axes: title={'center': 'fxns.control_flight.m.mode'}, xlabel=' '>,
        <Axes: title={'center': 'fxns.control_flight.s.closest_dist'}, xlabel='time'>,
        <Axes: title={'center': 'fxns.aviate.m.mode'}, xlabel='time'>],
       dtype=object))
../../../_images/57ce8e5b7ff14125e1c4668ac7e73cf35ecb02b891f8641e677fd42e1a060783.png

We can see this behavior illustrated below, which shows the specific times in which self has paused so as to not encroach on the uav.

As shown, self goes right inside the safety envelope, where it stops.

geoms = {'self': {'shapes': {'envelope': {'color': 'blue'}}},
         'uav': {'shapes': {'safety': {'color': 'orange'}}}}
fig, ax = plot_flightpath(haa, hist, time_ticks=2.0, time_groups='nominal')
fig, ax = hist.plot_trajectories('environment.ga.points.uav.s.x',
                                 'environment.ga.points.uav.s.y',
                                 fig=fig, ax=ax, time_groups='nominal', time_ticks=2.0)
fig, ax = haa.flows['environment'].ga.show_from(hist.flows.environment.ga, 16, fig=fig, ax=ax, geoms=geoms)
fig, ax = haa.flows['environment'].ga.show_from(hist.flows.environment.ga, 18, fig=fig, ax=ax, geoms=geoms)
fig, ax = haa.flows['environment'].ga.show_from(hist.flows.environment.ga, 30, fig=fig, ax=ax, geoms=geoms)
../../../_images/78246ca2d095aab83fdb71faba01cd1cce0cacc939dc1824c8ba965f7ace2b2e.png

We can see the alternative behavior without proxthreat below:

haa2 = ContingencyAircraftArchitecture(p={'with_proxthreat': False})
res, hist = prop.nominal(haa2)
hist.plot_line('flows.electricity.s.charge',
               'fxns.control_flight.m.mode',
               'fxns.control_flight.s.closest_dist',
               'fxns.aviate.m.mode')
(<Figure size 600x400 with 4 Axes>,
 array([<Axes: title={'center': 'flows.electricity.s.charge'}, xlabel=' '>,
        <Axes: title={'center': 'fxns.control_flight.m.mode'}, xlabel=' '>,
        <Axes: title={'center': 'fxns.control_flight.s.closest_dist'}, xlabel='time'>,
        <Axes: title={'center': 'fxns.aviate.m.mode'}, xlabel='time'>],
       dtype=object))
../../../_images/d3572982c5e34e161108af0479fbb2fe5832ab923a30e8faf9d7f7a9a1e9ba33.png
fig, ax = plot_flightpath(haa2, hist, time_groups='nominal', time_ticks=2.0)
fig, ax = hist.plot_trajectories('environment.ga.points.uav.s.x',
                                 'environment.ga.points.uav.s.y',
                                 fig=fig, ax=ax, time_groups='nominal', time_ticks=2.0)
fig, ax = haa2.flows['environment'].ga.show_from(hist.flows.environment.ga, 20, fig=fig, ax=ax, geoms=geoms)
fig, ax = haa2.flows['environment'].ga.show_from(hist.flows.environment.ga, 22, fig=fig, ax=ax, geoms=geoms)
# fig, ax = haa2.flows['environment'].ga.show_from(hist.flows.environment.ga, 16, fig=fig, ax=ax, geoms=geoms)
# fig, ax = haa2.flows['environment'].ga.show_from(hist.flows.environment.ga, 18, fig=fig, ax=ax, geoms=geoms)
../../../_images/12f196dde68fe7275e9545362ee9fd7216b945f55637b52babe3d656b9b14fff.png

As shown, both aircraft get very close to each other at time t=22.0, resulting in a likely crash