I'm a software engineer and I've always loved Orbiter (also here). However I feel that it's growing a bit antiquated, and it would be nice to have a more modern, open source, or otherwise hackable engine. There are a lot of riffs on "realistic space sim" that would be great to explore.
I've been playing with the idea of attempting this as a side project, but I have zero interest in implementing my own orbital dynamics engine. Scientists far smarter than I have done the legwork here, and re-creating their work would likely add a year or two to my ETA. I have some background knowledge in physics, but I am a relative amateur in the field.
Ideally the library would be implemented in C, or have a C interface. If I start this project, I'll be doing it in Rust due to personal preference, which has great FFI compatibility with C. A secondary choice would be C++, which is marginally less supported. There may be a way to do it in a traditional engine like Unity or UE4 with some hacks, but those would have very similar source language requirements. (see clarification below for more specificity)
It would also ideally be licensed to be openly distributable, since it would need to be integrated and redistributed as part of the simulator.
I've looked briefly at the SPICE toolkit, which seems old-school but has the bindings I need.
I've also looked at GMAT, which seems to provide higher-level routines but seems to be primarily oriented around mission planning and less well-maintained. I'm not clear if it provides the bindings I would need to run a sim.
Of these, I know very little about what their real-time performance would be like, since they are typically built for mission analysis more that simulation.
Does anyone more experienced that I know what libraries would be suitable for this type of application (if any)?
EDIT: In response @uhoh's comment:
I'm addressing this in the body since my response requires more characters than a comment allows for.
If "SPICE toolkit" has "the bindings I need" (does it really?) then why does it matter if it "seems old-school"? It's not like we need "fresh code" because the old stuff goes rotten. Also, could you elaborate more on exactly what "this type of application" is? Specifically what features do you need that GMAT does not have for example? You haven't really specified your problem very clearly yet as far as I can tell. What exactly do you mean by "real time"? A mission to Mars needs to take six months to execute?
From your comment I see two main points:
- You want more specificity on what I intend to make.
- You want more information on my evaluation criteria for SPICE and GMAT.
I will assume you are familiar with Orbiter and Kerbal Space Program, as these are the contemporary games that simulate vehicular space travel. As stated above, I would intend to build an open source engine and base game similar to those above. Specifically, I would aim for something closer to Orbiter than KSP. I think there are a lot of fun ways you could "gamify" Orbiter (such as dynamic missions, mutliplayer), and I want to explore these concepts.
Specifically, I would aim to create an open source video game engine that can act as a starting point for interactive space simulation games. This differs from mission planning / analysis by its interactive component. The key differentiation is that a real time space simulation needs to accept course corrections to simulated entities, and update the object's orbital propagation with very low latency (roughly 8 ms). When I discuss a "real-time" simulation, this is what I mean.
These simulators generally propagate state at a pace in-sync with the wall clock, but also provide a time acceleration feature. There is generally a loss in simulation accuracy under time acceleration due to the engineer increasing the step size of their propagator. However with a sufficiently efficient propagator, it may be possible to make accuracy improvements by computing multiple physics steps from frame to frame.
The general architecture would be a graphical frontend responsible for "game loop" code, such as rendering and player input handling. However for orbital propagation, the frontend would outsource the work to an orbital dynamics module that simulates gravitational influences for all entities in the simulation. This would be augmented with a Newtonian physics engine for close-range interactions between objects.
In this post, I am trying to evaluate the viability of existing orbital dynamics libraries to fulfill this role. This would hopefully lead to less dev work for me, and a more accurate or optimized orbital dynamics component.
If you would like more specificity, I am happy to elaborate. However beyond this I am unclear what questions you have.
Toolkit Selection Criteria
I am specifically interested in leveraging existing toolkits to manage the orbit propagations of in-game entities. For the sake of scope I am limiting this to orbital dynamics, and not considering aerodynamics (although that would be pretty cool too). Because the role this is filling is primarily one of convenience, I am primarily looking for something where I can offload as much work as possible, with a bias towards developer usability.
The ideal toolkit would let me pass it a system of entities to simulate, preferably with the option of setting a propagator on an entity-by-entity basis (so that I can make latency-accuracy tradeoffs). I could then step it with sub-second time steps and have results ready in below 12ms (ideally 8ms). At any time I could apply a force vector to an object to adjust its trajectory.
Another requirement is redistributability (and ideally an open source license). A number of NASA packages (such as OTIS) are export-controlled, only available on request, and therefore are not viable as embedded components of software intended for the general public.
Many of the toolkits I have looked into so far are primarily intended for mission analysis. Therefore it is not necessarily true that they provide an interface to propagate a mission interactively. Many seem to instead follow a pattern of specifying constraints and initial conditions up front, then performing a batch compute process to identify optimal mission parameters. This would be useful as a navigational aid, but lack the interactivity to use it as the backbone of a simulation game.
This is why it matters that SPICE is "old school". Even the function names in its C API follow an archaic character-limited naming scheme, where names must be looked up and memorized as they rarely clarify what the function is doing. This slows down coding and is less than ideal. I suspect it provides functional primitives at a lower level, but does not simulate a system of objects in the way I would hope. I could be wrong here, and would be delighted to hear that I am. The upside is that it seems to be an industry standard, well documented, and very powerful. This is currently my most promising option. However it is such a vast project that I am still discovering what its capabilities are.
GMAT is neat, and seems to be a higher-level mission planning interface built on top of SPICE, but I have struggled to find documentation on it. I discovered it through the NASA Software Catalog, however their recommended support site (gmatcentral.org) is down with a 503 error. What little material I have found primarily speaks to how to use its graphical interface, rather than how to embed it as a component in a program. It is promising, as it's open source and seems to propagate an assembly of entities as part of mission planning. It is less promising in that it seems poorly documented, and tightly coupled to its current graphical interface. My hope is that since it's built on top of SPICE, a lot of the core simulation technology can be found in SPICE instead if I know where to look.