Quantcast

OpenRocket - Run from CLI and/or Java

The Rocketry Forum

Help Support The Rocketry Forum:

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!
 

gtg738w

FlightSketch - flightsketch.com
TRF Sponsor
Joined
Dec 27, 2018
Messages
219
Reaction score
160

Buckeye

Well-Known Member
TRF Supporter
Joined
Sep 6, 2009
Messages
2,511
Reaction score
361
Rocksim has such a batch executable. I used it to "call" RockSim from my own, separate, code.
 

Yuri Achermann

New Member
Joined
Feb 19, 2019
Messages
3
Reaction score
0
There is some info on the wiki for scripting:

http://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
 

gtg738w

FlightSketch - flightsketch.com
TRF Sponsor
Joined
Dec 27, 2018
Messages
219
Reaction score
160
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
 

flxtrnw

New Member
Joined
Sep 16, 2019
Messages
2
Reaction score
0
Location
Berlin
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 :)
 
Top