ericstoneking / 42

Simulation for spacecraft attitude control system analysis and design
239 stars 79 forks source link

Proximity operations simulation #123

Open john-nyy opened 1 year ago

john-nyy commented 1 year ago

Hi Eric, thank you very much for all your efforts in developing and maintaining this repo. I find it really useful. I've some doubts on how to properly set up a simulation with two spacecrafts - a chaser and a target - that are in a near-range proximity. I would like to start from a simple scenario where the relative motion is a free motion simply described through CW equations (EULER-HILL propagation mode in 42 I assume) and then add the different perturbations. To do so, I thought that a good way was to use the formation flying options. As of now, I've created the followings:

I added to the report.c two output files (PosEH.42 and VelEH.42) to track the position of the chaser wrt the target (that is also the origin of F). However, the output files do not seem reasonable. Am I doing something wrong? I know that the question is not an issue but more of a help request, but I really don't know how to setup a correct proximity operations scenario and I didn't find similar simulations in the documentation or in the Demo folder.

Thanks

ericstoneking commented 1 year ago

Hi Johnny,

Take a look at Docs/Flight Regimes.pdf. Also, there are a few examples of prox ops in the Demo. Look at SC_BBM, SC_Moai, SC_ISS, SC_Shuttle, SC_ThrDemo, and all three SC_Cubesats. Select "Prox Ops" from the "Show" menu in the "42 Cam" window to see some coordinate grids. The brownish curve is the natural EH motion projected forward and backward in time.

Yes, CW = Euler-Hill.

EH might indeed be broken. I recall fiddling with orbit stuff several months ago at someone's request, and may not have fully tidied up after. You can help diagnose by describing what you did, what you expected to see, and what you actually saw.

Regards, -Eric (he/him)

john-nyy commented 1 year ago

Hi Eric, thanks for your answer. I'll paste here the tests that I'm currently doing but, as I was saying, there may be something wrong in how I'm setting up the simulation scenario.

Below there is a .zip folder containing the main input files that I'm using. I took the input files inside the Demo folder as the main reference and I'm using:

I've done some tests, adding to the report files both PosEH.42, VelEH.42 and PosF.42, VelF.42. Their profiles are comparable. Here I attach the results considering a first scenario where no perturbation is used (in Inp_Sim.txt all the flags are FALSE) and a second one where I activated the Gravity Perturbation forces with a 2,2 degree for the gravity model. In both cases, the results are pretty strange and are not comparable with the standard CW equations (I've done the same tests by running a script that retrieves the CW positions in time).

image image

As I was saying, the problems may be in the simulation scenario. I tried to replicate what I saw in the Demo folder but I may have lost something.

Thanks

ericstoneking commented 1 year ago

Hi Johnny,

Your setup looks fine.

Let's concentrate on the disturbance-free sim case first. I duplicated your setup, and I get the same results you plot above. I have a hunch to pursue, but before I dive in any deeper, please elaborate on "pretty strange" and "not comparable with standard CW equations". What, precisely, are you expecting?

Regards, -Eric (he/him)

john-nyy commented 1 year ago

Hi Eric,

I'll paste here some results considering the same simulation setting I used before (with no external perturbations and ENCKE propagation mode for the Chaser) but with different initial conditions to compare 42 with CW in different cases.

In my previous comparisons, I was mixing up two different reference systems, so I'll write here what references I'm using.

With this in mind, it is possible to compare the outputs of 42 and of the CW model in different test cases.

1) The first test is done cosidering 42 initial conditions for the Chaser CM offset wrt F equal to: pos_0 = [15; 0; -5]m, vel_0 = [0; 0; 0]m/s. Below there are the results obtained in 42 (EH coordinates) and with the CW model image (4) image (3)

2) The second test is done cosidering 42 initial conditions for the Chaser CM offset wrt F equal to: pos_0 = [15; -5; -5]m, vel_0 = [0; 0; 0]m/s. Below there are the results obtained in 42 (EH coordinates) and with the CW model image (6) image (5)

3) The third test is done cosidering 42 initial conditions for the Chaser CM offset wrt F equal to: pos_0 = [15; -5; -5]m, vel_0 = [0.001; 0; -0.01]m/s. Below there are the results obtained in 42 (EH coordinates) and with the CW model image (8) image (7)

By looking at these plots, it seems that the results are consistent once that the correct reference frame change is imposed. So i would say that the EH coordinates seems good so far.

But if I enable the gravity perturbation, something happens. Below I paste the results in 42 by enabling the gravity perturbation forces with a gravity model of 2,2. I don't have a mathematical model to do the comparison since I only implemented the CW model (I want to use 42 to consider perturbed scenarios), but the magnitudes reached for the EH coordinates are too large. I'm still using the ENCKE propagation.

image

I hope this was clear. Thanks

ericstoneking commented 1 year ago

Hi Johnny,

Yes, my L frame is +Z to nadir, +Y opposite the orbit normal, and +X completing the right-handed triad.

So your other source and 42 agree. I still have a nagging question about setting up initial conditions, Encke, and my numerical integrator, but that's more of a philosophical issue, if the results you show are of adequate accuracy for your purposes.

Moving on to adding geopotential harmonics. I agree that the amount of growth is startling, but what's your basis for concluding that it's wrong?

Here's an experiment to try:

1) Set up your chaser as your only S/C for the time being. Perform a run with FIXED orbit propagation. 42 will write out PosN.42 and VelN.42 (for SC[0] only, so we want the chaser to be SC[0] for this experiment). Save those off with unique file names.

2) Now, in your Orb_ file, set "Secular Orbit Drift Due to J2" to true. Run the sim again, and save PosN.42 and VelN.42 with unique file names.

3) Set the Secular Drift flag back to false. In Inp_Sim, set Earth Gravity Model N and M to (2,0), and set Gravity Perturbation Forces to true. In SC_Chaser.txt, set Orbit Prop to ENCKE. Run the sim again, and save PosN and VelN.

4) Compare the three sets of PosN and VelN. What I see is that the results from steps 2 and 3 are in decent agreement, and noticeably different from the pure Keplerian motion of step 1.

My source for the secular drift due to J2 is Markley and Crassidis, "Fundamentals of Spacecraft Attitude Determination and Control", Appendix C. I'm sure there are other references out there as well.

As a sanity check, you might look at the geopotential terms, and work out how much "extra" gravitational pull J2 exerts. What would that do to the mean motion and semi-major axis of an orbit that was initialized assuming only Keplerian motion?

If you browse other issues in this repo, you'll find cases of 42 not agreeing with GMAT (over long time scales, especially). So I'm not saying that 42 is as accurate as it can be with regard to orbit propagation; there is work to do (which I'll get around to someday, maybe). It's your call whether or not it meets your needs as it stands. If not, I recommend GMAT for hifi orbit propagation with gravitational perturbations. You can use 42 to use that as a reference orbit, and put Encke on top of that to handle whatever perturbations GMAT can't handle gracefully.

Regards, -Eric (he/him)