OpenRocket - Run from CLI and/or Java

Discussion in 'Rocketry Electronics and Software' started by John D, Feb 18, 2019.

Help Support The Rocketry Forum by donating:

  1. Feb 18, 2019 #1

    John D

    John D

    John D

    New Member

    Joined:
    Feb 18, 2019
    Messages:
    1
    Likes Received:
    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!
     
    Yuri Achermann likes this.
  2. Feb 19, 2019 #2

    gtg738w

    gtg738w

    gtg738w

    FlightSketch - flightsketch.com TRF Sponsor

    Joined:
    Dec 27, 2018
    Messages:
    192
    Likes Received:
    114
    Gender:
    Male
    Yuri Achermann likes this.
  3. Feb 19, 2019 #3

    Buckeye

    Buckeye

    Buckeye

    Well-Known Member

    Joined:
    Sep 6, 2009
    Messages:
    2,251
    Likes Received:
    186
    Rocksim has such a batch executable. I used it to "call" RockSim from my own, separate, code.
     
    Yuri Achermann likes this.
  4. Mar 17, 2019 #4

    Yuri Achermann

    Yuri Achermann

    Yuri Achermann

    New Member

    Joined:
    Feb 19, 2019
    Messages:
    3
    Likes Received:
    0
    Gender:
    Male
    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
     
  5. Mar 17, 2019 #5

    gtg738w

    gtg738w

    gtg738w

    FlightSketch - flightsketch.com TRF Sponsor

    Joined:
    Dec 27, 2018
    Messages:
    192
    Likes Received:
    114
    Gender:
    Male
    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
     
    Yuri Achermann likes this.
  6. Jan 17, 2020 #6

    flxtrnw

    flxtrnw

    flxtrnw

    New Member

    Joined:
    Sep 16, 2019
    Messages:
    2
    Likes Received:
    0
    Gender:
    Male
    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 :)
     

Share This Page

Group Builder