OpenRocket - Run from CLI and/or Java

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

John D

New Member
Joined
Feb 18, 2019
Messages
1
Reaction score
1
Hi there,

I wonder if it is possible to run a simulation in OpenRocket without the need of the GUI or the need of interact with the GUI. I am aware of simulation listeners, but these require some interaction with user interface. In brief, I want to run a simulation and get its results without interaction via mouse and integrate it as part of another software piece.

Thanks in advance!
 
There is some info on the wiki for scripting:

https://wiki.openrocket.info/Scripting_with_Python_and_JPype

It seems old and I never got it to work well.

What language is your project in? If you can use java, you can import the open rocket jar as a library and have full access to everything. The source is on github if you need a reference to what’s what:

https://github.com/openrocket/openrocket

This let me do everything the way I wanted to.

Good luck!

Hi, @gtg738w .

Have you been able to write a code that starts the software, loads a project and runs the simulation?
If so, could you give me at least the minimum idea of the code? What methods have you used to make everything happen and get the results?

I really appreciate any help you can provide.

-Yuri Achermann
 
Sure, I was able to do the following:

Point to the file and load the model-
Code:
    orkFile = new File("filename.ork");
    OpenRocketDocument doc = null;
    GeneralRocketLoader loader = new GeneralRocketLoader(orkFile);

    try {
        doc = loader.load();
    } catch (Exception ex) {
        response.getWriter().print(ex);
    }


The you can change any aspect of it and run the simulation-
Code:
    doc.getSimulation(config).getOptions().setWindSpeedAverage(windSp);
    doc.getSimulation(config).getOptions().setLaunchRodAngle(launchRodAngle);

    try {
        doc.getSimulation(config).simulate();
    } catch (SimulationException e) {
        e.printStackTrace();
    }


Then you can access the data from the sim-
Code:
    doc.getSimulation(config).getSimulatedData().getBranch(0).get(FlightDataType.TYPE_LONGITUDE)

Hope that helps
 
Hi guys,
has anyone done progress with this kind of work?
With the example by @gtg738w i´m always getting Nullpointerexeptions and i'm unable to load on the doc variable.
I'm not really deep into Java so if someone have this kind of functional code for OpenRocket it would really really help me :)
 
Back
Top