Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Oct 23, 2014 #1
    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: Oct 23, 2014
  2. jcsd
  3. Oct 29, 2014 #2
    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?
     
  4. Oct 29, 2014 #3
    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to write C++ code using SGP4 to propagate satellite position
Loading...