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

Switching VCAS to use GNATS #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ywang542
Copy link
Contributor

Tested based on GNATS 1.9
Added sleep time in while loop according to John and Erin's comments
Raise error when simulation ended unexpectedly.

Tested based on GNATS 1.9
Added sleep time in while loop according to John and Erin's comments
Raise error when simulation ended unexpectedly.
@@ -145,19 +148,19 @@ def simulation(self, input_cmd=None):
ignore_index=True) # end cmd

# self.init_NATS()
self.environmentInterface.load_rap(os.environ.get('NATS_HOME') + '/' + 'share/tg/rap') # default wind file
self.environmentInterface.load_rap(os.environ.get('GNATS_HOME') + '/' + 'share/tg/rap') # default wind file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, this does not work because I have GNATS_HOME pointing to the GNATS_Standalone directory, not GNATS_Server. Based on the installation instructions (in particular, the GNATS examples instructions says to put the examples in the GNATS_Standalone directory), this is my understanding of how GNATS_HOME should be set up to work with Python.

Also, GnatsEnvironment stores a reference to the share directory for you, so you can use this:

Suggested change
self.environmentInterface.load_rap(os.environ.get('GNATS_HOME') + '/' + 'share/tg/rap') # default wind file
self.environmentInterface.load_rap(os.path.join(GnatsEnvironment.share_dir, 'tg', 'rap')) # default wind file

One advantage of this is that it will work when the user wants to override GNATS_HOME by using the gnats_home argument to start_jvm.

else:
time.sleep(0.1)
elif (server_runtime_sim_status == self.NATS_SIMULATION_STATUS_ENDED):
raise Exception('Simulation stopped unexpectedly. Please rerun.')

curr_t = self.starttime + self.simulationInterface.get_curr_sim_time()
ac = self.aircraftInterface.select_aircraft(aclist[0])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run vcas_example.py, I get the following error, which points to this line:

Begin flight propagation for 1.000000 seconds duration from 0.000000 to 1000.000000 second with time step 1.0 seconds (surface), 1.0 seconds (terminal area), 1.0 seconds (above TRACON)

    Simulation time:  0 hours
    Duration satisfied.  Automatically pausing at time = 1.000000 seconds
Traceback (most recent call last):
  File "paraatm/tests/vcas_example.py", line 29, in <module>
    track = sim()  # call simulation function using NatsSimulationWrapper
  File "/home/jmcfarland/work/git/para-atm/paraatm/io/gnats.py", line 277, in __call__
    self.simulation(*args, **kwargs)
  File "/home/jmcfarland/work/git/para-atm/paraatm/simulation_method/vcas.py", line 167, in simulation
    ac = self.aircraftInterface.select_aircraft(aclist[0])
  File "/home/jmcfarland/venv/para-atm/lib/python3.6/site-packages/JPype1-0.6.3-py3.6-linux-x86_64.egg/jpype/_jarray.py", line 60, in __getitem__
    return _jpype.getArrayItem(self.__javaobject__, ndx)
jpype._jexception.ArrayIndexOutOfBoundsExceptionPyRaisable: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
JVM has been shutdown

Also if I check the length of aclist, it is 0.

@jmcfarland-swri
Copy link
Collaborator

In test_para_atm.py, please move test_vcas to the end of the TestGnatsSimulationClass. This way, it will be triggered correctly according to the value of the USE_GNATS variable in this test file.

jmcfarland-swri added a commit to jmcfarland-swri/para-atm that referenced this pull request Jul 8, 2020
Move the unittest for VCAS under TestGnatsSimulation, since VCAS now
uses GNATS.

I still get an error when running the unittest, which is the same one
that has been documented already in Pull Request ymlasu#21.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants