Cambridge Rocketry Simulator – A Stochastic Six-Degrees-of-Freedom Rocket Flight Simulator

The Cambridge Rocketry Simulator can be used to simulate the flight of unguided rockets for both design and operational applications. The software consists of three parts: The first part is a GUI that enables the user to design a rocket. The second part is a verified and peer-reviewed physics model that simulates the rocket flight. This includes a Monte Carlo wrapper to model the uncertainty in the rocket ’ s dynamics and the atmospheric conditions. The third part generates visualizations of the resulting trajectories, including nominal performance and uncertainty analysis, e.g. a splash-down region with confidence bounds. The project is available on SourceForge, and is written in Java (GUI), C++ (simulation core), and Python (visualization). While all parts can be executed from the GUI, the three components share information via XML, accommodating modifications, and re-use of individual components.


Introduction
The Cambridge Rocketry Simulator is designed for use with unguided rockets including model rockets, High Power Rockets (HPR), and sounding rockets.Typically, these will perform a sub-orbital flight, collect some data, and deploy a parachute for recovery to Earth.The software models the flight dynamics of the rocket in six-degrees-of-freedom and of the parachute descent in three-degrees-of-freedom.It has a range of uses.Firstly, it can guide the design process.For example, it allows the engineer to select the appropriate size motor for a desired apogee; or to design the fins for an appropriate margin of stability; or to optimise the timing of stage separation or parachute deployment.Secondly, it enables the operator to predict the landing location, which helps in determining the required launch safety exclusion zone, as well as facilitating the retrieval of the reusable components of the rocket.In order to map uncertainties in the dynamics and the atmospheric conditions into confidence bounds around the predicted landing location, a Monte Carlo approach is combined with a numerical integration scheme.
Most research performed on predicting the trajectories of projectiles is done by numerical integration.The exception is the work of Chudinov [8], who predicts the trajectories by applying an analytical solution.While this approach is beneficial in terms of computation costs, the prediction is limited to modelling a point mass with a quadratic drag force.At the other end of the spectrum, there are advanced simulators such as that described by Sahu [17], where the authors use advanced coupled computational fluid dynamics/rigid body dynamics to predict the rocket behaviour even as it enters supersonic speeds.However, as the additional computational cost is significant due to the calculation of unsteady aerodynamics associated with supersonic flight, it is computationally costly to perform an uncertainty analysis of parameters via a Monte Carlo method.While there are other methods available for non-linear uncertainty propagation, the Monte Carlo method is capable of handling large state spaces and arbitrary input distributions, making it the most widely used approach.That does not take away that advanced simulations remain invaluable when testing the performance of new control methods, as performed by Gomez and Miikkulainen [12], who test their control method for a finless rocket via simulations.Uncertainty propagation is also useful for Impact Point Prediction (IPP), where the impact point of a projectile is determined while it is in-flight.Yuan et al. [20] incorporates the uncertainty due to the presence of wind to increase the accuracy on the confidence bounds on the landing location.Rogers [16] applies an uncertainty analysis not only to predict the impact point, but also to guide the rocket such that it avoids objects and reaches the target location without collision.With the exception of the analytical solution, all research is done via a six-degrees-of-freedom rocket model and parameters describing the projectile's properties.
There are various software packages that facilitate conceptual studies of rocket design, including commercial solutions such as RockSim [1], open-source solutions such as OpenRocket [13], and even computer games such as the Kerbal Space Program [18].All these packages simulate the performance of a rocket under nominal conditions, returning the expected performance to the user.While RockSim Pro does display confidence bounds around the predicted landing location to the user, it is only available to USA citizens.
The Cambridge Rocketry Simulator has four advantages over these software packages.Firstly, it is free and opensource [6].Secondly, the physics model is verified, peerreviewed, and published [5].Thirdly, by using a Monte Carlo wrapper, it incorporates uncertainties in both rocket dynamics and atmospheric conditions, making it possible to produce a splash-down area with confidence bounds.Finally, the atmospheric model supports a 3-dimensional wind vector, air density, and air temperature, all as a function of altitude.These atmospheric data may be populated from a recent meteorological forecast to maximize the  accuracy of predictions.And with the introduction of the third version of the Cambridge Rocketry Simulator, as presented in this paper, parts of the Graphical User Interface (GUI) from Open-Rocket [13] are integrated to assist the user in their rocket design.The software package is useful in predicting the trajectories of rockets in academic activities [3,19,7,10], or when sampling the atmosphere using sounding rockets.Without the prediction of the trajectories, or more specifically, the confidence bounds of the landing location, you may never get permission from the aviation authorities to launch your rocket [9].Furthermore, the output of the simulator, the rocket trajectories, have been used in the trajectory modelling research described by Eerland, Box, and Sóbester [11].
The remainder of this paper covers the implementation and architecture, quality control, the availability, and reuse potential of the software.

Implementation and architecture
The software package consists of three components, each written in a different language to suit their individual purpose: A GUI, a simulator, and a visualisation module.A  schematic representation of the three components, and how they interact, is presented in Figure 1.
The GUI used to design the rocket is coded in Java, where the start-up file SwingStartup.java is located at gui/Swing/Src/net/Sf/openrocket/Startup/.This starts the design page as seen in Figure 2, where the user can select the different components to build the rocket.More details about the GUI, and the corresponding internal structure can be found in Niskanen [14].The example here shows a two-stage rocket.Once the rocket is designed, all the parameters are passed to the simulator core (written in C++) via an Extensible Markup Language (XML) datasheet.These parameters are required in the simulation, and consist of the moments of inertia, centre of pressure, drag coefficient, and the thrust curve.A full list of parameters and a description of the components are available in the user guide uSer_guide.pdf,which is located at doc/.
The core of the physical simulation, the rocketc source code, is located in cpp/ which includes a Makefile that compiles the binary and moves it to the simulator folder, found in Simulator/.The Java GUI calls the simulation binary, after which the simulation starts by reading the input XML generated by the Java code.The XML file Simulationinput.xmlcan be found in the Data folder at data/.Upon completion of the simulation an output XML file Simulationoutput.xml is generated in the same folder.
This output of the simulation is then input to the Python visualization code which is located in plotter/.This presents the user with an overview of the flight trajectories and the splash-down area.The splash down-area includes confidence bounds, as seen in Figures 3 and 4.
When running the software under Linux, the three folders, Simulator/, data/, and plotter/, are expected to be located in the users home directory ∼/.camrocSim/.Therefore, to prepare the system for execution from source code, a script called prepare_linux.Sh is included in the repository.This copies the three relevant folders to this location.The information presented in this section, and build instructions for Windows, are available in the readme.mdfile found in the repository.

Quality control
The performance of the simulator has been evaluated by comparison to telemetry data recorded in rocket flights as described by Box, Bishop, and Hunt [5].
The performance and stability of the GUI and the visualiser have been tested in two rounds of user-testing, including cross-platform testing, which was done on Ubuntu 14.04 Trusty Tahr and Windows 10.0 (Build 10240).
Furthermore, there are unit tests available for the GUI and simulator, using JUnit for the GUI (Java), and GoogleTest for the simulator (C++).Instructions on how to run these are included in the readme.mdfile.

Operating system
The Cambridge Rocketry Simulator is able to function on any operating system that supports a standard Java and Python installation, which includes Linux and Windows.
In all systems the simulator can be set-up by checking out the code repository.Detailed instructions on how to start the program and continue development are included in the documentation.input file as its single parameter.Therefore this can be ported into other applications.
Furthermore, individual classes of the simulator have reuse potential.For example the rkf45.cppclass is a general ordinary differential equation solver which implements the fourth/fifth order Runge-Kutta algorithm with Fehlberg step-size control [15].This may be used in any dynamics simulation application.
Similarly, the vmathS.cppclass may be used for modelling the six-degrees-of-freedom dynamics of rigid bodies.In particular the implementation of quaternions in this class is helpful for modelling unconstrained rotation without the need to deal with the singularities that arise when using Euler angles [2].
To assist users and developers, there is a user guide (uSer_guide.pdf)available in the doc/ directory.This includes information on the required structure of the XML files, and instructions on how to launch the simulator and plotter via the command line.
The website Cambridge Rocketry [4] is devoted to producing open-source software for simulating high power rockets, where besides the Cambridge Rocketry Simulator, an Octave/Matlab version of the simulator core named the Cambridge Rocketry Toolbox is available.The preferred method for contributors to contact the developers is via the SourceForge webpage https://sourceforge. net/p/camrocsim/, where questions can be asked on the forum, and the developers may be contacted directly.

Figure 1 :
Figure 1: A schematic representation of the three components and the corresponding programming languages.

Figure 2 :
Figure 2: GUI for designing a rocket.It contains all the basic components required to design a rocket.

Figure 3 :
Figure 3: Mean trajectories of both stages of a two-stage rocket including a staged parachute descent.The 1 and 2 σ bounds of confidence in landing position are also shown.

Figure 4 :
Figure 4: Landing position confidence bounds from Figure 3 along with the individual landing locations of 25 Monte Carlo iterations.