How to write C++ code using SGP4 to propagate satellite position

Click For Summary
SUMMARY

This discussion focuses on using the SGP4 library in C++ to propagate satellite positions using Two-Line Element (TLE) data. The user aims to read TLE data from a file named "isstle.txt" and utilize the "sgp4" and "twoline2rv" functions to compute satellite state vectors over a specified time interval. The conversation highlights the challenges faced by beginners due to limited documentation and emphasizes the importance of studying existing code examples, such as "testcpp.cpp," to gain a better understanding of the implementation process.

PREREQUISITES
  • Basic understanding of C++ programming
  • Familiarity with satellite orbital mechanics and TLE data
  • Knowledge of the SGP4 algorithm for satellite position propagation
  • Experience with file handling in C++
NEXT STEPS
  • Study the SGP4 algorithm and its implementation in C++
  • Learn how to parse TLE data from text files in C++
  • Explore the "testcpp.cpp" example for practical insights
  • Research best practices for documenting and commenting code for better clarity
USEFUL FOR

Beginner C++ developers, aerospace engineers, and anyone interested in satellite tracking and orbital mechanics will benefit from this discussion.

thor36
Messages
10
Reaction score
0
Greetings all !
I really hope this is the right sub-forum for my question, I have chosen it because I've seen TLE being mentioned a couple of times around here.

I have done some reading on astrodynamics and orbital mechanics, but I am relatively new to coding. I would like to write some C++ code that would make use of this software library ( Computer software in C++ ). So far I am not having success with using "sgp4" and "twoline2rv" routines. Obviously, I don't know how to use them properly, although I tried to follow and understand the routines line by line and particularly paid attention to comments.

Let's say I get the TLE data for ISS online and store it in a file called "isstle.txt", which would look like this :
ISS (ZARYA)
1 25544U 98067A 14296.89020256 .00021128 00000-0 36676-3 0 2914
2 25544 51.6464 181.6097 0002420 294.7068 172.8232 15.50795889911298

I would then like to propagate the satellite's position and velocity vectors from some initial moment ( Tstart, most likely defined by particular TLE ) to a final moment (Tend, say 2 hours after Tstart) and compute state vectors on every "time step" of length dT along the way, including at initial and final moment. These vectors would then be stored in type double arrays.

The algorithm doesn't need to follow the style of following pseudo code, but here is what I have in mind, and it may help clarify my intentions :

TLE from internet -> textfile
SatData = twoline2rv( textfile )
for ( T = Tstart : dT : Tend )
sgp4( SatData, T )
store RV to arrays​
end​

sgp4() and twoline2rv() are actual names of the functions found in the libraries mentioned earlier.
I would very much appreciate a piece of sample code that can solve this problem or at least help orient myself a little. Of course any other tips and hints are just as welcome.

Thank you very much and kind regards
T
 
Last edited:
Technology news on Phys.org
Thanks for the post! Sorry you aren't generating responses at the moment. Do you have any further information, come to any new conclusions or is it possible to reword the post?
 
Thank you for reply ! My question is very very specific, so I knew posting it is quite a long shot.

I have found a partial answer - the code distribution contains a "testcpp.cpp" file which provides a case of implementation. Using it is fine for start, but being a test example it has limitations. Therefore one is still in for a lot of code study and experimentation if he wants to implement his own algorithms. I suppose it is not a big problem for experienced coders, but to a beginner the lack of documentation and wealthier comments can be some trouble.

If it feels necessary I can try reword the post too. However, I don't see an "edit" button anymore.
 

Similar threads

Replies
1
Views
4K