SilentSys / orhelper

orhelper is a module which aims to facilitate interacting and scripting with OpenRocket from Python
GNU General Public License v2.0
15 stars 16 forks source link

MotorIgnitionException when simulating re-saved simple.ork #13

Open Jashaszun opened 6 months ago

Jashaszun commented 6 months ago

I'm trying to run a very basic test of orhelper by stripping down simple_plot.py and playing around with simple.ork by modifying it and saving to modified.ork.

My environment is Ubuntu 22.04.3 LTS, Python 3.10, OpenJDK1.8 (openjdk-8-jre) with simple.ork, modified.ork, and OpenRocket-15.03.jar in the same directory as this script (orhelper-test.py):

import orhelper
from orhelper import FlightDataType, FlightEvent

with orhelper.OpenRocketInstance() as instance:
    orh = orhelper.Helper(instance)

    doc = orh.load_doc('simple.ork')
    sim = doc.getSimulation(0)
    orh.run_simulation(sim)

    data = orh.get_timeseries(sim, [FlightDataType.TYPE_TIME, FlightDataType.TYPE_ALTITUDE, FlightDataType.TYPE_VELOCITY_Z])
    events = orh.get_events(sim)

    ejectionChargeTime = events[FlightEvent.EJECTION_CHARGE]
    print(f"Ejection charge time: {ejectionChargeTime[0]}")

It runs fine with simple.ork, but if I make a copy of simple.ork by simply opening OpenRocket, opening simple.ork, Saving As modified.ork (with all simulated data), and using modified.ork in my script, I get a MotorIgnitionException from orh.run_simulation(sim):

Exception while calling OpenRocket
Traceback (most recent call last):
  File "Simulation.java", line 336, in net.sf.openrocket.document.Simulation.simulate
Exception: Java Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/path/to/orhelper-test.py", line 9, in <module>
    orh.run_simulation(sim)
  File "/path/to/venv/lib/python3.10/site-packages/orhelper/_orhelper.py", line 255, in run_simulation
    sim.simulate(listener_array)
net.sf.openrocket.simulation.exception.net.sf.openrocket.simulation.exception.MotorIgnitionException: <unprintable net.sf.openrocket.simulation.exception.MotorIgnitionException object>
1.17s - Error on build_exception_info_response.
Traceback (most recent call last):
  File "/home/me/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 1494, in build_exception_info_response
    stack_str += '%s: %s\n' % (stype, frames_list.exc_desc)
jpype._core.JVMNotRunning: Java Virtual Machine is not running

0.11s - Error on build_exception_info_response.
Traceback (most recent call last):
  File "/home/me/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 1494, in build_exception_info_response
    stack_str += '%s: %s\n' % (stype, frames_list.exc_desc)
jpype._core.JVMNotRunning: Java Virtual Machine is not running

Traceback (most recent call last):
  File "Simulation.java", line 336, in net.sf.openrocket.document.Simulation.simulate
Exception: Java Exception

This is with OpenRocket v23.09 used to re-save simple.ork. I tried to use the v15.03 jar to see if that would resolve this issue, but OpenJDK1.8 doesn't seem to support that:

$ java -jar OpenRocket-15.03.jar 
java: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE

Is this a known issue with saved ork files from more recent versions of OpenRocket? Or is there something I need to set in my OpenRocket preferences?

Jashaszun commented 6 months ago

Ok, apparently the issue running OpenRocket-15.03.jar was due to running it from the VSCode terminal: https://stackoverflow.com/questions/75921414/java-symbol-lookup-error-snap-core20-current-lib-x86-64-linux-gnu-libpthread

Running it from the regular terminal is successful. I opened simple.ork, updated the 0th simulation's ejection charge time from 3s to 5s, saved it as modified-15.03.ork, and ran my script on that file, and it works.

So it does look like it's something about the file format that OpenRocket's updated between v15.03 and v23.09.