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.RealFieldElement;
20 import org.orekit.attitudes.Attitude;
21 import org.orekit.attitudes.FieldAttitude;
22 import org.orekit.errors.OrekitException;
23 import org.orekit.frames.Frame;
24 import org.orekit.time.AbsoluteDate;
25 import org.orekit.time.FieldAbsoluteDate;
26 import org.orekit.utils.ExtendedPVCoordinatesProvider;
27 import org.orekit.utils.FieldPVCoordinatesProvider;
28 import org.orekit.utils.PVCoordinatesProvider;
29 import org.orekit.utils.TimeStampedAngularCoordinates;
30 import org.orekit.utils.TimeStampedFieldAngularCoordinates;
31 import org.orekit.utils.TimeStampedFieldPVCoordinates;
32 import org.orekit.utils.TimeStampedPVCoordinates;
33
34
35
36
37
38
39
40 public abstract class AbstractGNSSAttitudeProvider implements GNSSAttitudeProvider {
41
42
43 private static final long serialVersionUID = 20171114L;
44
45
46 private final AbsoluteDate validityStart;
47
48
49 private final AbsoluteDate validityEnd;
50
51
52 private final ExtendedPVCoordinatesProvider sun;
53
54
55 private final Frame inertialFrame;
56
57
58
59
60
61
62
63 protected AbstractGNSSAttitudeProvider(final AbsoluteDate validityStart,
64 final AbsoluteDate validityEnd,
65 final ExtendedPVCoordinatesProvider sun,
66 final Frame inertialFrame) {
67 this.validityStart = validityStart;
68 this.validityEnd = validityEnd;
69 this.sun = sun;
70 this.inertialFrame = inertialFrame;
71 }
72
73
74 @Override
75 public AbsoluteDate validityStart() {
76 return validityStart;
77 }
78
79
80 @Override
81 public AbsoluteDate validityEnd() {
82 return validityEnd;
83 }
84
85
86 @Override
87 public Attitude getAttitude(final PVCoordinatesProvider pvProv,
88 final AbsoluteDate date,
89 final Frame frame)
90 throws OrekitException {
91
92
93
94 final TimeStampedPVCoordinates sunPV = sun.getPVCoordinates(date, inertialFrame);
95 final TimeStampedPVCoordinates svPV = pvProv.getPVCoordinates(date, inertialFrame);
96
97
98 final TimeStampedAngularCoordinates corrected = correctedYaw(new GNSSAttitudeContext(sunPV, svPV));
99
100 return new Attitude(inertialFrame, corrected).withReferenceFrame(frame);
101
102 }
103
104
105 @Override
106 public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(final FieldPVCoordinatesProvider<T> pvProv,
107 final FieldAbsoluteDate<T> date,
108 final Frame frame)
109 throws OrekitException {
110
111
112
113 final TimeStampedFieldPVCoordinates<T> sunPV = sun.getPVCoordinates(date, inertialFrame);
114 final TimeStampedFieldPVCoordinates<T> svPV = pvProv.getPVCoordinates(date, inertialFrame);
115
116
117 final TimeStampedFieldAngularCoordinates<T> corrected = correctedYaw(new GNSSFieldAttitudeContext<>(sunPV, svPV));
118
119 return new FieldAttitude<>(inertialFrame, corrected).withReferenceFrame(frame);
120
121 }
122
123
124
125
126
127
128 protected abstract TimeStampedAngularCoordinates correctedYaw(GNSSAttitudeContext context)
129 throws OrekitException;
130
131
132
133
134
135
136
137 protected abstract <T extends RealFieldElement<T>> TimeStampedFieldAngularCoordinates<T>
138 correctedYaw(GNSSFieldAttitudeContext<T> context)
139 throws OrekitException;
140
141 }