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

AI Thread Summary
The discussion centers on the challenges faced in using the SGP4 and Two-Line Element (TLE) data routines in C++ for satellite position and velocity propagation. The user has gathered TLE data for the International Space Station (ISS) and aims to write code that utilizes the "twoline2rv" function to convert TLE data into satellite data and the "sgp4" function to propagate the satellite's state vectors over a specified time interval. The user is seeking sample code or guidance to better understand the implementation, noting that while a test file is available, it has limitations and lacks sufficient documentation for beginners. The user expresses a willingness to rephrase their question for clarity but is unsure how to proceed due to the absence of an edit option.
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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top