Commit 6d834ee0 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Merge branch 'issues-tabulated-provider' into develop

parents d617f752 ac2f1398
......@@ -21,6 +21,12 @@
</properties>
<body>
<release version="11.0" date="TBD" description="TBD">
<action dev="luc" type="update" issue="761">
TabulateProvider now implements BoundedAttitudeProvider.
</action>
<action dev="luc" type="fix" issue="760">
Fixed reference frame in tabulated attitude provider.
</action>
<action dev="amir" type="fix" issue="746">
Fixed combination of measurements using GNSS phase measurements.
</action>
......
/* Copyright 2002-2021 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.attitudes;
import org.hipparchus.RealFieldElement;
import org.orekit.frames.Frame;
import org.orekit.utils.FieldPVCoordinatesProvider;
import org.orekit.utils.PVCoordinatesProvider;
import org.orekit.utils.TimeStampedAngularCoordinates;
import org.orekit.utils.TimeStampedFieldAngularCoordinates;
/** This interface represents a builder for attitude.
* <p>
* It is intended to modify raw angular coordinates when build attitudes,
* for example if these coordinates are not defined from the desired reference frame.
* </p>
* @author Luc Maisonobe
* @since 11.0
*/
public interface AttitudeBuilder {
/**Build a filtered attitude.
* @param frame reference frame with respect to which attitude must be defined
* @param pvProv provider for spacecraft position and velocity
* @param rawAttitude raw rotation/rotation rate/rotation acceleration
* @return filtered attitude
*/
Attitude build(Frame frame, PVCoordinatesProvider pvProv, TimeStampedAngularCoordinates rawAttitude);
/**Build a filtered attitude.
* @param frame reference frame with respect to which attitude must be defined
* @param pvProv provider for spacecraft position and velocity
* @param rawAttitude raw rotation/rotation rate/rotation acceleration
* @return filtered attitude
* @param <T> the type of the field elements
*/
<T extends RealFieldElement<T>> FieldAttitude<T> build(Frame frame,
FieldPVCoordinatesProvider<T> pvProv,
TimeStampedFieldAngularCoordinates<T> rawAttitude);
}
/* Copyright 2002-2021 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.attitudes;
import org.hipparchus.RealFieldElement;
import org.orekit.frames.FieldTransform;
import org.orekit.frames.Frame;
import org.orekit.frames.Transform;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.utils.FieldPVCoordinatesProvider;
import org.orekit.utils.PVCoordinatesProvider;
import org.orekit.utils.TimeStampedAngularCoordinates;
import org.orekit.utils.TimeStampedFieldAngularCoordinates;
/** Builder that assumes angular coordinates are given in a fixed frame.
* @author Luc Maisonobe
* @since 11.0
*/
public class FixedFrameBuilder implements AttitudeBuilder {
/** Reference frame for raw attitudes. */
private final Frame referenceFrame;
/** Creates new instance.
* @param referenceFrame reference frame for raw attitudes
*/
public FixedFrameBuilder(final Frame referenceFrame) {
this.referenceFrame = referenceFrame;
}
/** {@inheritDoc} */
@Override
public Attitude build(final Frame frame, final PVCoordinatesProvider pvProv,
final TimeStampedAngularCoordinates rawAttitude) {
final AbsoluteDate date = rawAttitude.getDate();
final Transform t = frame.getTransformTo(referenceFrame, date);
final TimeStampedAngularCoordinates frame2Ref =
new TimeStampedAngularCoordinates(date,
t.getRotation(),
t.getRotationRate(),
t.getRotationAcceleration());
return new Attitude(frame, rawAttitude.addOffset(frame2Ref));
}
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> FieldAttitude<T>
build(final Frame frame, final FieldPVCoordinatesProvider<T> pvProv,
final TimeStampedFieldAngularCoordinates<T> rawAttitude) {
final FieldAbsoluteDate<T> date = rawAttitude.getDate();
final FieldTransform<T> t = frame.getTransformTo(referenceFrame, date);
final TimeStampedFieldAngularCoordinates<T> frame2Ref =
new TimeStampedFieldAngularCoordinates<>(date,
t.getRotation(),
t.getRotationRate(),
t.getRotationAcceleration());
return new FieldAttitude<>(frame, rawAttitude.addOffset(frame2Ref));
}
}
......@@ -38,28 +38,57 @@ import org.orekit.utils.TimeStampedFieldAngularCoordinates;
* @see TabulatedLofOffset
* @since 6.1
*/
public class TabulatedProvider implements AttitudeProvider {
/** Reference frame for tabulated attitudes. */
private final Frame referenceFrame;
public class TabulatedProvider implements BoundedAttitudeProvider {
/** Cached attitude table. */
private final transient ImmutableTimeStampedCache<TimeStampedAngularCoordinates> table;
private final transient ImmutableTimeStampedCache<? extends TimeStampedAngularCoordinates> table;
/** Filter for derivatives from the sample to use in interpolation. */
private final AngularDerivativesFilter filter;
/** First date of the range. */
private final AbsoluteDate minDate;
/** Last date of the range. */
private final AbsoluteDate maxDate;
/** Builder for filtered attitudes. */
private final AttitudeBuilder builder;
/** Creates new instance.
* <p>
* This constructor uses the first and last point samples as the min and max dates.
* </>
* @param referenceFrame reference frame for tabulated attitudes
* @param table tabulated attitudes
* @param n number of attitude to use for interpolation
* @param filter filter for derivatives from the sample to use in interpolation
* @see #TabulatedProvider(Frame, List, int, AngularDerivativesFilter, AbsoluteDate, AbsoluteDate)
*/
public TabulatedProvider(final Frame referenceFrame, final List<TimeStampedAngularCoordinates> table,
public TabulatedProvider(final Frame referenceFrame, final List<? extends TimeStampedAngularCoordinates> table,
final int n, final AngularDerivativesFilter filter) {
this.referenceFrame = referenceFrame;
this.table = new ImmutableTimeStampedCache<TimeStampedAngularCoordinates>(n, table);
this.filter = filter;
this(table, n, filter, table.get(0).getDate(), table.get(table.size() - 1).getDate(),
new FixedFrameBuilder(referenceFrame));
}
/** Creates new instance.
* @param table tabulated attitudes
* @param n number of attitude to use for interpolation
* @param filter filter for derivatives from the sample to use in interpolation
* @param minDate min date to use
* @param maxDate max date to use
* @param builder builder to use
* @since 11.0
*/
public TabulatedProvider(final List<? extends TimeStampedAngularCoordinates> table,
final int n, final AngularDerivativesFilter filter,
final AbsoluteDate minDate, final AbsoluteDate maxDate,
final AttitudeBuilder builder) {
this.table = new ImmutableTimeStampedCache<TimeStampedAngularCoordinates>(n, table);
this.filter = filter;
this.minDate = minDate;
this.maxDate = maxDate;
this.builder = builder;
}
/** {@inheritDoc} */
......@@ -74,7 +103,7 @@ public class TabulatedProvider implements AttitudeProvider {
TimeStampedAngularCoordinates.interpolate(date, filter, sample);
// build the attitude
return new Attitude(referenceFrame, interpolated);
return builder.build(frame, pvProv, interpolated);
}
......@@ -95,8 +124,18 @@ public class TabulatedProvider implements AttitudeProvider {
TimeStampedFieldAngularCoordinates.interpolate(date, filter, sample);
// build the attitude
return new FieldAttitude<>(referenceFrame, interpolated);
return builder.build(frame, pvProv, interpolated);
}
/** {@inheritDoc} */
public AbsoluteDate getMinDate() {
return minDate;
}
/** {@inheritDoc} */
public AbsoluteDate getMaxDate() {
return maxDate;
}
}
......@@ -24,6 +24,7 @@ import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.geometry.euclidean.threed.Rotation;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.Decimal64;
import org.hipparchus.util.Decimal64Field;
import org.hipparchus.util.FastMath;
import org.junit.After;
......@@ -50,8 +51,12 @@ import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.TimeComponents;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.AngularDerivativesFilter;
import org.orekit.utils.FieldPVCoordinates;
import org.orekit.utils.IERSConventions;
import org.orekit.utils.PVCoordinates;
import org.orekit.utils.TimeStampedAngularCoordinates;
import org.orekit.utils.TimeStampedFieldPVCoordinates;
import org.orekit.utils.TimeStampedPVCoordinates;
public class TabulatedProviderTest {
......@@ -67,6 +72,39 @@ public class TabulatedProviderTest {
// Earth shape
OneAxisEllipsoid earthShape;
@Test
public void testDifferentFrames() {
double samplingRate = 10.0;
int n = 8;
AttitudeProvider referenceProvider = new NadirPointing(circOrbit.getFrame(), earthShape);
List<TimeStampedAngularCoordinates> sample = createSample(samplingRate, referenceProvider);
TabulatedProvider provider = new TabulatedProvider(circOrbit.getFrame(), sample, n,
AngularDerivativesFilter.USE_R);
Attitude attE = provider.getAttitude((date, frame) -> new TimeStampedPVCoordinates(date, PVCoordinates.ZERO),
date,
circOrbit.getFrame());
Assert.assertEquals(circOrbit.getFrame().getName(), attE.getReferenceFrame().getName());
Frame gcrf = FramesFactory.getGCRF();
Attitude attG = provider.getAttitude((date, frame) -> new TimeStampedPVCoordinates(date, PVCoordinates.ZERO),
date,
gcrf);
Assert.assertEquals(gcrf.getName(), attG.getReferenceFrame().getName());
Assert.assertEquals(1.12e-7,
Rotation.distance(attE.getRotation(), attG.getRotation()), 1.0e-9);
Assert.assertEquals(circOrbit.getFrame().getTransformTo(gcrf, date).getRotation().getAngle(),
Rotation.distance(attE.getRotation(), attG.getRotation()),
1.0e-14);
FieldAttitude<Decimal64> attG64 =
provider.getAttitude((date, frame) -> new TimeStampedFieldPVCoordinates<>(date,
FieldPVCoordinates.getZero(Decimal64Field.getInstance())),
new FieldAbsoluteDate<>(Decimal64Field.getInstance(), date),
gcrf);
Assert.assertEquals(gcrf.getName(), attG64.getReferenceFrame().getName());
}
@Test
public void testWithoutRate() {
double samplingRate = 10.0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment