Collision Avoidance Maneuver in Script

Control flow commands, Target, Vary, Minimize, NonlinearConstraint, etc.

Collision Avoidance Maneuver in Script

Postby canna12 » Thu Jan 16, 2014 9:06 pm

Hi everyone,

I'm trying to mock up a collision avoidance maneuver in GMAT. The idea is to show two spacecraft that get very very close (<1km separation) and then apply an impulsive burn to one of them. It's more a proof of concept than a calculation engine. Here's the setup:

    --RedSat and BlueSat are in very similar orbits. At the beginning of the mission, they're about 2.5 km separated. The separation magnitude falls as the mission goes on
    --The array ds contains the X, Y, and Z components of the separation, in the EarthMJ2000Eq frame
    --The variable mag contains the vector magnitude of ds (mag = sqrt(ds(1,1)^2 + ds(2,1)^2 + ds(3,1)^2))
    --The ImpulsiveBurn CAM is initialized to zeroes for all components

With these initial conditions, the mission sequence is simply a While loop that runs until RedSat.ElapsedDays >= 2.5. Inside the loop are two steps: a Propagate that simply propagates both satellites one step (no stopping conditions), and a ScriptEvent with the following contents:

Code: Select all
GMAT ds(1,1) = RedSat.X - BlueSat.X;
GMAT ds(2,1) = RedSat.Y - BlueSat.Y;
GMAT ds(3,1) = RedSat.Z - BlueSat.Z;
GMAT mag = sqrt(ds(1,1)^2 + ds(2,1)^2 + ds(3,1)^2);
GMAT E = RedSat.Epoch.UTCGregorian;
Report R1 ds(1,1) ds(2,1) ds(3,1) mag;

If mag < 1 %We're too close! Avoid! Avoid!
   Report R1 E warning; %warning is a string variable that says 'The spacecraft are too close!'
   
   GMAT CAM.Element1 = 1.0;
   
   Maneuver CAM(BlueSat);

EndIf;



I also have a plot that draws the separation mag over time, and another that draws the BlueSat.VX. As expected, as soon as the RedSat and BlueSat get within 1.0km of each other, the If block springs into action and writes the warning, then sets the delta-V of CAM.Element1, then apparently applies the maneuver CAM to BlueSat.

I can zoom in on the plot of BlueSat.VX and see a discontinuous jump at the time the spacecraft break the 1km barrier -- however it's not a jump of 1.0km/s. I can change the size of CAM.Element1 to, say, 10.0 and see a bigger jump, but the jump still is smaller than 10km/s. I think I have the CoordinateSystem settings matched between the plot and the CAM, so I would expect to see equal jumps. So this is strange, but it's not my main problem.

The biggest problem is that the value of mag continues to fall slowly, even after the maneuver has been "applied". I don't understand this. Attached are two pictures, one of each plot. The BlueSat.VX plot is zoomed in to the point where you can see the discontinuity, and the mag plot is zoomed in to the same timestamp. The maneuver seems to have no effect on the separation between the two spacecraft. I've attached the plots in question and can provide more detail if it would help.

Is there a reason this is happening? I'm extremely confused by this behavior.
Attachments
mag.PNG
This is the plot of the magnitude of the separation between the spacecraft, over time. See how the shape of the graph does not change even after the relatively large (1.0km/s) delta-V applied at approximately 21546.54
mag.PNG (9.85 KiB) Viewed 9342 times
BlueSatVX.PNG
Plot of BlueSat's VX.
canna12
 
Posts: 6
Joined: Thu Jan 16, 2014 8:26 pm

Re: Collision Avoidance Maneuver in Script

Postby shughes » Fri Jan 17, 2014 5:35 pm

Can you attach your complete script?

In your first plot, of RMAG, the delta V causes a change in slope that may be hard to see, not sure. Can you plot VMAG, then you should see a jump.

Regarding the second plot, the RSS will be will be 1.0, you are looking at inertial X maneuver component, but the maneuver was applied in VNB X.
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Collision Avoidance Maneuver in Script

Postby canna12 » Fri Jan 17, 2014 6:49 pm

Hi shughes, thanks for your help. Attached is my complete script. I took your advice and plotted the VMAG of BlueSat and found that it did exhibit a jump -- but it's still not quite what I would have expected. Then I plotted all 3 components of BlueSat's velocity and the magnitude on the same plot (it too is attached). As you can see, the only component that exhibits the bump is VX, and the magnitude bumps accordingly. But why isn't the bump in VX equal to 1.0 km/s? One thing I may not have mentioned is that I set the coordinate system of the ImpulsiveBurn to EarthMJ2000Eq and ImpulsiveBurn.Element1 to 1.0km/s, so I would expect that a plot of BlueSat.EarthMJ2000Eq.VX would show a bump of 1.0km/s. Here are the relevant excerpts from the script:


Code: Select all
Create ImpulsiveBurn CAM;
GMAT CAM.CoordinateSystem = EarthMJ2000Eq;
GMAT CAM.Element1 = 0;
GMAT CAM.Element2 = 0;
GMAT CAM.Element3 = 0;
GMAT CAM.DecrementMass = false;
GMAT CAM.Isp = 300;
GMAT CAM.GravitationalAccel = 9.810000000000001;

(Later, during the mission sequence...)

If mag < 1 %We're too close! Avoid! Avoid!
     Report R1 E warning;
         
     GMAT CAM.Element1 = 1.0;
         
     Maneuver CAM(BlueSat);
EndIf


Thank you so much for your help!
Attachments
CAM.script
The complete script containing a Collision Avoidance Maneuver event
(8.69 KiB) Downloaded 308 times
BlueSatAllV.PNG
All 3 components of BlueSat, plus the magnitude, zoomed in to the point where the maneuver takes place
BlueSatVMAG.PNG
Screenshot of the plot of BlueSat's VMAG
canna12
 
Posts: 6
Joined: Thu Jan 16, 2014 8:26 pm

Re: Collision Avoidance Maneuver in Script

Postby shughes » Fri Jan 17, 2014 7:14 pm

Hi canna12, the confusion is that changing a component of a vector by delta X does not change the norm of that vector by Delta x. For example, say the vector is [1 2 3] and Delta X = 1.

sqrt( 1^2 + 2^2 + 3^2 ) = 3.7417
sqrt( (1+1)^2 + 2^2 + 3^2 ) = 4.1231

In the case of your example

before maneuver: norm([2.531101361935224 7.251567037651543 1.05561726713248]) = 7.4862
after maneuver: norm([1.531101361935223 7.251567037651543 1.05561726713248]) =7.7528

difference in RSS = 0.2666
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Collision Avoidance Maneuver in Script

Postby canna12 » Fri Jan 17, 2014 7:47 pm

shughes,

I agree with your math completely. I'm not concerned that VX and VMAG don't change equally -- the reason I attached that plot was to show that only VX is affected by the maneuver. So, if I'm thinking about this correctly, the maneuver must have been applied entirely in the VX direction, since only the VX component was affected. Basically, I wanted to show that my maneuver coordinate system and EarthMJ2000Eq were the same. This is what I expect.

Here's a listing of mag and all 3 BlueSat velocity components. Note that I don't see any discontinuities in BlueSat's velocity here -- all 3 components are rising or falling fairly slowly, and after the warning is raised they continue rising or falling in the same direction:
Code: Select all
mag (km)               BlueSat.VX             BlueSat.VY             BlueSat.VZ
1.021878543917709      6.380941654534041      3.78809128130898       1.690044662931501     
1.01977859028142       5.946723550964848      4.427986905666288      1.667206244843322     
1.01745482097511       5.450994913697701      5.019506593778929      1.626813046134569     
1.014920183559352      4.899301133294454      5.556425973781102      1.5693580351243       
1.012189764146624      4.297757206485561      6.033161322483482      1.495516930548169     
1.009280669834472      3.652975930920326      6.444817772384519      1.406138773979384     
1.006211789891768      2.971976920917951      6.787238869273081      1.30223265518194       
1.003003729404682      2.262141381085149      7.05702258878145       1.184960160388188     
0.9996784266208969     1.531101361935223      7.251567037651543      1.05561726713248
warning               
The spacecraft are less than 1km apart!
0.9962588584213091     0.7866502674342694     7.369084901778059      0.9156171786999851     
The spacecraft are less than 1km apart!
0.9927689100989213     0.03668800580738509    7.408606192485503      0.7664789490859088     
The spacecraft are less than 1km apart!
0.9892329774244428     -0.7108946665543018    7.369984281107881      0.6098040718424764     
The spacecraft are less than 1km apart!
0.9856757787758701     -1.448287173578862     7.253881954653298      0.4472602916181471     
The spacecraft are less than 1km apart!
0.9821221464556597     -2.167834992432379     7.061753375332713      0.280564215537352     
The spacecraft are less than 1km apart!
0.9785968559815984     -2.862106265369278     6.795822488216655      0.1114656372807863   


Even with the explanation you've given, I still can't understand why the separation plot doesn't change dramatically at the maneuver epoch. These two spacecraft are drifting toward each other rather slowly (about 0.002km per propagation step), then a dV of 1.0km/s is applied to one spacecraft -- I feel like I should be seeing a major jump or spike or something. Please let me know what you think, and thanks again for your help.
canna12
 
Posts: 6
Joined: Thu Jan 16, 2014 8:26 pm

Re: Collision Avoidance Maneuver in Script

Postby shughes » Fri Jan 17, 2014 9:41 pm

well, you found a bug. Apparently the spacecraft cloned in the formation are not getting updated when you do the maneuver. I submitted a ticket here: http://li64-187.members.linode.com:8080/browse/GMT-4368

Thank you very much for reporting this.

The workaround is to use this Propagate command: Propagate DefaultProp(RedSat,BlueSat);
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Collision Avoidance Maneuver in Script

Postby canna12 » Fri Jan 17, 2014 9:44 pm

Thanks for the workaround, and thanks for submitting the bug! Sorry if I made more work for you...

I just performed the workaround you provided and it works just like I would expect. Thanks again!
canna12
 
Posts: 6
Joined: Thu Jan 16, 2014 8:26 pm

Re: Collision Avoidance Maneuver in Script

Postby shughes » Wed Jan 29, 2014 8:31 pm

This bug has been fixed and the correction will be in R2014a. Thanks again for reporting this.
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm


Return to GMAT Commands

Who is online

Users browsing this forum: No registered users and 1 guest

cron