Groho is a simulator for space travel within the solar system.
Even our tiny corner of the universe, the solar system, is unimaginably vast and lonely. Using this simulator, I hope we can gain an intuition and appreciation for basic orbital manuevers, and a sense of scale and time for travel between the planets. In this way we can get a feel for what life will be like for our descendants who set sail away from the home planet
Groho (গ্রহ) is the Bengali word for planet. Grohomondol (গ্রহমণ্ডল) is the word for planetary system but is more of a mouthful.
You can put the compiled code, your scenario files and the data files anywhere on disk. For simplicity, in the tutorial here, especially so that the example scenario file can work out of the box, I mention a fixed directory structure.
I haven't had time to make things super easy. This assumes some knowledge of
how to compile C++ programs and install Python programs with pip
The software consists of two parts: a simulator, which is a C++ program that needs to be compiled, and a visualizer, which is a Python program that should be installed.
You need cmake
3.12.0 or later, a c++ compiler that can do C++17, like gcc
9.3.1 or later, or clang
11.0.3 or later, and Python 3.7 or later.
Best is to git clone
the latest code from the stable
branch.
git clone https://github.com/kghose/groho.git
From the root of the code directory, where you find this Readme.md file, in a Python 3.7 environment
pip install .
From the root of the code directory, where you find this Readme.md file:
mkdir build
cd build
cmake ..
make -j4
The simulator loads planetary and satellite data from data files put out by the Jet Propulsion Laboratory (JPL). These are called SPICE kernels and many can be found from this website
The example uses the de432s.bsp kernel. Download this file to the examples
directory.
Open a terminal and, from the root directory, do
build/groho sim examples/basic-scenario.txt simout
This will start the simulator in "server" mode, which just means it runs the
simulation and then sits watching for changes to the scenario described by
basic-scenario.txt
and reruns whenever the scenario is changed.
The
groho
executable has a few other modes that the CLI help will explain to you if you are interested.
In another terminal, in your Python 3.7 environment, start the visualizer code with
grohoviz simout exmples/basic-plot-description.yml
This starts the visualizer which will plot the simulation and then wait, watching for updates to the simulator output (which it will replot automatically) and for updates to the plotfile, which it will also replot, automatically.
At this point you should have a plot that resembles the screenshot posted above.
You can now edit the scenario file and/or the plot description file and the simulator will be rerun and the plot regenerated automatically.
Only two plot interactions are non-intuitive
- Double clicking on a panel will reset the axes limits to include all the plotted data
- The yellow bar that spans the plot on the bottom is a time slider and that can be clicked on or dragged to plot the simulation at different time points.
These can be found here
The webpage at https://ssd.jpl.nasa.gov/sbdb_query.cgi#x will generate CSV files with customized data as you need.
I use this project to keep current with my design and C++ skills.
- Here are some UML design documents
- My relevant blog posts on C++ and other topics.
- Some very unorganized notes on C++ used in this project.
There is a bunch of interesting physics and math behind orbital maneuvers. From Robert A. Braeunig's page we have the following named maneuvers:
- Hohmann transfer orbit
- One-Tangent Burn
- Spiral transfer
- Simple plane change
And, from poliastro
- Lambert’s problem
- Bi-elliptic transfer
There is a big list at https://github.com/orbitalindex/awesome-space
NASA's GMAT software (github) is probably the be-all and end-all of spacecraft simulation. It would probably have sufficed for my needs but I like to program computers and learn math, so I stubbornly rolled my own to my own (much more limited) specifications.
"SSVG is simulation software which enables users to fly their own space probes in the solar system. Each space probe has three propulsion systems: a chemical propulsion engine, an electric propulsion engine, and solar sail. Fly your own space probe in the precisely simulated Solar System."
I found SSVG on Oct 14th and browsing through the manual]SSVG-manual found that the author had a very similar concept (including the name "Flight plan") and a cool looking GUI for writing flight plans! I had, by then, however, discarded the idea of timed actions in favor of event/condition driven actions. But it is cool for me to see a "flight plan" like concept, because I have so far been unsuccessful in finding what a real flight plan, or set of propulsive maneuvers actually looks like.
I ran into the Trajectory Browser while looking for what interplanetary mission programs look like. It's awesome. However
All trajectories are pre-computed and stored in a database that contains all the solutions. In order to compute new trajectories to a non-existing object and/or if you wish to add a particular object that is not currently available, please contact us and we will have it included.
REBOUND is an N-body integrator. Groho completely punts on this aspect of the simulation and relies on the NASA/JPL ephemeris kernels (which in turn are products of a constrained N-body simulation). The REBOUND code is a good place to explore different integrators and the rebound paper is a good place to readup about Symplectic integration. If you are into that kind of thing.
I've used Orbiter since 2001 or so. It was my main instrument of thesis procrastination. It's very detailed and visually rich and a blast to play. It's an interactive simulation where you fly space craft with your keyboard and mouse. It's closed source and its internals are a little opaque. For example, I do not know what orrery model it uses or if it does an n-body simulation, if it has accurate models for the axial tilt of the planets and moons or these are just arbitrary and so on.
Bussard is a cool hacking/spaceflight game where you write complex programs to fly your spaceship to solve puzzles.
SolarSystemOrbiter - "Plot the orbits of the planets in our Solar System and calculate the Hohmann Transfer Orbits to transfer your rocket ship from one planet to the other and back."
poliastro is an open source collection of Python subroutines for solving problems in Astrodynamics and Orbital Mechanics.
Celestia - "A real-time space simulation that lets you experience our universe in three dimensions."
asterank - "Using publicly available data and scientific papers, the project evaluates the economic prospects of mining nearly 600,000 cataloged asteroids." They are live at http://www.asterank.com/.
Included in the code are the following fine pieces of software
- loguru from Emil Ernerfeldt for the logging
- CLI11 from Henry Schreiner for the CLI
- catch(2) from Phil Nash for unit tests
The code is passed through clang-format
and VS code is my go to editor.