FlintHill / SUAS-Competition

SUAS Competition Code for team Animus Ferus
4 stars 10 forks source link

Ensure Consistent Performance During Interop. Disconnect #132

Open jvillemare opened 6 years ago

jvillemare commented 6 years ago

Problem

Certain systems experience total crashes, or fail to resume after the connection to the Interoperability server has been disconnected.

Identification

interop-server-dependencies 1

Above is the list of the files in the repo identified to be dependent upon the Interop. server for information for obstacles, targets, and more.

What needs to be done now is testing to see how the four different systems, Image Processing, SDA, Competition Viewer, Manual Target Submission System (MTSS, aka GCS:WebUI), act after a disconnect.

What's Known

Three out of the four systems use flask_gcs.py in order to connect to the Interop. server, while Image Processing uses interop_client.py to directly connect to the Interop. server.

Possible Solutions

_For Image Processing that uses interop_client.py:_ @jmoxrox indicates that a possible solution follows the psuedocode of:

init():
   p = null

submit_x_target(): // submit_manual_target, or submit_autonomous_target
   if p is Process:
      if interop connected:
          p.append(target)
          p.submit_targets()
          p = null

   if interop connected:
       interop.submit(target)
   else:
       p = new Process(Queue)
       p.append(target)

Essentially, submitting targets when Interop. is available, and when it's not available, creating a queue of targets, and waiting for an Interop. connection to submit them.

MTSS' manual targets are sent to interop_client.py, and would also need a queue implemented and tested.

_For all other systems using flask_gcs.py:_ A unique solution may be required for all different subsystems that are started and fed information by flask_gcs.py.

Work

It would make the most sense for @jmoxrox to implement queues for autonomous (Image Processing) and manual image processing (MTSS) in interop_client.py, as he has made me aware that he is more familiar with creating processes and using managers.

@BrightStraightReality simply needs to ensure that SDA does not fail when Interop. is disconnected, and if it does, inform me what the best action would be.

I will work on fixing Competition Viewer's Interop. disconnect, as I have written all of it.

jvillemare commented 6 years ago

Unfortunately, due to the nature of the tasks I have, I cannot segment the work I need to do into different branches. I have since created the new branch interop-disconnect-and-duplicates-fixes which currently comprises the following changes:

I plan to possibly enclose fixes for SDA so it continues to run on an Interop. disconnect, but, I'll need to work more with @BrightStraightReality on that in the very near future.

jvillemare commented 6 years ago

The four commits above this comment, 7e3554f, 9b7720f, 99e7d12, d7bb035, make the following changes:

There are also a few code comments that are being kept as this is a WIP.

jvillemare commented 6 years ago

Major Status Update

Pull Request #137 was successfully merged today, and it has not only brought reconnect fixes to the Interop. client, but also a duplicates handling fix for MTSS. Both of these are explained below.

Interop. Disconnect Handler

Now, whenever there the connection to the Interop. server is disconnected, and some script attempts to use a method inside the interop_client.py file, the interop_client.py instance will wait an amount of time specified in SUASSystem's settings file, under the variable INTEROP_DISCONNECT_RETRY_RATE, and then re-instantiate the connection to the Interop. server and try again until the function is successful.

This has been tested, and works with SDA, Competition Viewer, and MTSS.

After an Interop. disconnect for each subsystem:

Image Processing was not tested because it was not fully integrated/working with GPS coordinates and filters until very recently. We are planning to do testing on Image Processing, and see how it handles an Interop. disconnect shortly in the future.

MTSS Duplicate Target Handler

image

Whenever a target is submitted through MTSS, the flask_gcs.py scripts checks the submitted target against the JSONs of the targets that have already been cropped and submitted to Interop. server, and if the flask_gcs.py finds any targets that match even one characteristic of a submitted target, a list of the previously submitted, potentially matching targets is sent to MTSS, and the Duplicates Targets Detected modal is displayed.

The modal is a little rough with some styling problems that I can't quite seem to fix, and I couldn't properly resize the preview of the current crop and the previously submitted crop to be of the same sizes (due to time and willpower constraints), but, it works, it's functional, and it's easy to use.