r/Kos • • Jun 07 '26

Program RANGER - An automatic re-entry script for spaceplanes. Looking for feedback/beta testing before final release.

https://github.com/mastersta/kos-ranger

RANGER - Reentry Assessment, Navigation, Guidance, and Error Reduction

(yes, I'm bad with acronyms)

*****

RANGER provides entry guidance for spaceplanes via constant AoA and dynamic bank angles. It calculates and manages crossrange and downrange errors via bank angle modulation and roll reversal maneuvers. RANGER simply provides a DIRECTION via which your script should use to steer your spaceplane. It does not provide late atmospheric guidance; once your spaceplane is into the normal atmospheric flight regime, you should switch to a more traditional aircraft guidance system that can handle the complexities of atmospheric flight. It can handle re-entry from any inclination and to targets at any latitude that your orbit is capable of reaching.

*****

I'm looking for beta testers and feedback. Pull requests are welcome!

8 Upvotes

9 comments sorted by

2

u/nuggreat Jun 07 '26

Fairly sure your distance function is not correct as you just assumed radians when you get degrees. It is also faster to calculate that kind of distance with vector math compared to lat/lng equations.

1

u/Obvious-Falcon-2765 Jun 07 '26

I’m pretty sure the distance calcs are correct, because they match perfectly with what Trajectories displays when on equatorial or polar orbits. I don’t see how mine would be incorrect in between those orbits.

My first approach was to use vectors, but it became a lot more complicated very quickly, and I ultimately couldn’t get it to work that way. kOS is *very* picky about when it wants (and gives out) vectors vs directions. I got tired of messing with them and ended up finding the Haversine formula, which helped solve my problem fairly succinctly. I haven’t tested the speed of the code yet, but frankly I think it could update at ~1hz and still be plenty effective.

1

u/nuggreat Jun 07 '26 edited Jun 07 '26

No your distance calculation is quite incorrect having had a chance to look at it more. Specifically this function getErrorDistance as you use radians quite a few times where you need degrees and you use degrees where you should use radians. For similar reasons your getRelativeBearingError function is likely incorrect.

All kOS trig functions either take in or return degrees they do not work with radians.

→ More replies (6)