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.