1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.gnss.attitude;
18
19 import org.hipparchus.Field;
20 import org.hipparchus.CalculusFieldElement;
21 import org.hipparchus.util.FastMath;
22 import org.orekit.frames.Frame;
23 import org.orekit.time.AbsoluteDate;
24 import org.orekit.utils.ExtendedPositionProvider;
25 import org.orekit.utils.TimeStampedAngularCoordinates;
26 import org.orekit.utils.TimeStampedFieldAngularCoordinates;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 public class GPSBlockIIR extends AbstractGNSSAttitudeProvider {
42
43
44 public static final double DEFAULT_YAW_RATE = FastMath.toRadians(0.2);
45
46
47 private static final double END_MARGIN = 1800.0;
48
49
50 private final double yawRate;
51
52
53
54
55
56
57
58
59 public GPSBlockIIR(final double yawRate,
60 final AbsoluteDate validityStart, final AbsoluteDate validityEnd,
61 final ExtendedPositionProvider sun, final Frame inertialFrame) {
62 super(validityStart, validityEnd, sun, inertialFrame);
63 this.yawRate = yawRate;
64 }
65
66
67 @Override
68 protected TimeStampedAngularCoordinates correctedYaw(final GNSSAttitudeContext context) {
69
70
71 final double aNoon = FastMath.atan(context.getMuRate() / yawRate);
72 final double cNoon = FastMath.cos(aNoon);
73 final double cNight = -cNoon;
74
75 if (context.setUpTurnRegion(cNight, cNoon)) {
76
77 final double absBeta = FastMath.abs(context.beta(context.getDate()));
78 context.setHalfSpan(absBeta * FastMath.sqrt(aNoon / absBeta - 1.0), END_MARGIN);
79 if (context.inTurnTimeRange()) {
80
81
82 final double beta = context.getSecuredBeta();
83 final double phiStart = context.getYawStart(beta);
84 final double dtStart = context.timeSinceTurnStart();
85 final double phiDot;
86 final double linearPhi;
87
88 if (context.inSunSide()) {
89
90 phiDot = -FastMath.copySign(yawRate, beta);
91 linearPhi = phiStart + phiDot * dtStart;
92 } else {
93
94 phiDot = FastMath.copySign(yawRate, beta);
95 linearPhi = phiStart + phiDot * dtStart;
96 }
97
98 if (context.linearModelStillActive(linearPhi, phiDot)) {
99
100 return context.turnCorrectedAttitude(linearPhi, phiDot);
101 }
102
103 }
104
105 }
106
107
108 return context.nominalYaw(context.getDate());
109
110 }
111
112
113 @Override
114 protected <T extends CalculusFieldElement<T>> TimeStampedFieldAngularCoordinates<T> correctedYaw(final GNSSFieldAttitudeContext<T> context) {
115
116 final Field<T> field = context.getDate().getField();
117
118
119 final T aNoon = FastMath.atan(context.getMuRate().divide(yawRate));
120 final double cNoon = FastMath.cos(aNoon.getReal());
121 final double cNight = -cNoon;
122
123 if (context.setUpTurnRegion(cNight, cNoon)) {
124
125 final T absBeta = FastMath.abs(context.beta(context.getDate()));
126 context.setHalfSpan(absBeta.multiply(FastMath.sqrt(aNoon.divide(absBeta).subtract(1.0))), END_MARGIN);
127 if (context.inTurnTimeRange()) {
128
129
130 final T beta = context.getSecuredBeta();
131 final T phiStart = context.getYawStart(beta);
132 final T dtStart = context.timeSinceTurnStart();
133 final T phiDot;
134 final T linearPhi;
135
136 if (context.inSunSide()) {
137
138 phiDot = field.getZero().newInstance(-FastMath.copySign(yawRate, beta.getReal()));
139 linearPhi = phiStart.add(phiDot.multiply(dtStart));
140 } else {
141
142 phiDot = field.getZero().newInstance(FastMath.copySign(yawRate, beta.getReal()));
143 linearPhi = phiStart.add(phiDot.multiply(dtStart));
144 }
145
146 if (context.linearModelStillActive(linearPhi, phiDot)) {
147
148 return context.turnCorrectedAttitude(linearPhi, phiDot);
149 }
150
151 }
152
153 }
154
155
156 return context.nominalYaw(context.getDate());
157
158 }
159
160 }