use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.
the class NadirPointingTest method testSpin.
@Test
public void testSpin() throws OrekitException {
// Elliptic earth shape
OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
// Create earth center pointing attitude provider
NadirPointing law = new NadirPointing(FramesFactory.getEME2000(), earthShape);
// Satellite on any position
KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
Propagator propagator = new KeplerianPropagator(orbit, law, mu, 2500.0);
double h = 0.1;
SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
SpacecraftState s0 = propagator.propagate(date);
SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));
// check spin is consistent with attitude evolution
double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation());
double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAngleMinus, 5.3e-9 * evolutionAngleMinus);
double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation());
double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAnglePlus, 8.1e-9 * evolutionAnglePlus);
Vector3D spin0 = s0.getAttitude().getSpin();
Rotation rM = sMinus.getAttitude().getRotation();
Rotation rP = sPlus.getAttitude().getRotation();
Vector3D reference = AngularCoordinates.estimateRate(rM, rP, 2 * h);
Assert.assertTrue(Rotation.distance(rM, rP) > 2.0e-4);
Assert.assertEquals(0.0, spin0.subtract(reference).getNorm(), 2.0e-6);
}
use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.
the class NadirPointingTest method testNonSphericEarth.
/**
* Test in the case of an elliptic earth : nadir pointing shall be :
* - the same as earth center pointing in case of equatorial or polar position
* - different from earth center pointing in any other case
*/
@Test
public void testNonSphericEarth() throws OrekitException {
// Elliptic earth shape
OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
// Create nadir pointing attitude provider
NadirPointing nadirAttitudeLaw = new NadirPointing(FramesFactory.getEME2000(), earthShape);
// Create earth center pointing attitude provider
BodyCenterPointing earthCenterAttitudeLaw = new BodyCenterPointing(FramesFactory.getEME2000(), earthShape);
// Satellite on equatorial position
// **********************************
KeplerianOrbit kep = new KeplerianOrbit(7178000.0, 1.e-8, FastMath.toRadians(50.), 0., 0., 0., PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
// Get nadir attitude
Rotation rotNadir = nadirAttitudeLaw.getAttitude(kep, date, kep.getFrame()).getRotation();
checkField(Decimal64Field.getInstance(), nadirAttitudeLaw, kep, kep.getDate(), kep.getFrame());
// Get earth center attitude
Rotation rotCenter = earthCenterAttitudeLaw.getAttitude(kep, date, kep.getFrame()).getRotation();
// For a satellite at equatorial position, earth center pointing attitude and nadir pointing
// attitude shall be the same, i.e the composition of inverse earth pointing rotation
// with nadir pointing rotation shall be identity.
Rotation rotCompo = rotCenter.composeInverse(rotNadir, RotationConvention.VECTOR_OPERATOR);
double angle = rotCompo.getAngle();
Assert.assertEquals(0.0, angle, 5.e-6);
// Satellite on polar position
// *****************************
CircularOrbit circ = new CircularOrbit(7178000.0, 1.e-5, 0., FastMath.toRadians(90.), 0., FastMath.toRadians(90.), PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
// Get nadir attitude
rotNadir = nadirAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// Get earth center attitude
rotCenter = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// For a satellite at polar position, earth center pointing attitude and nadir pointing
// attitude shall be the same, i.e the composition of inverse earth pointing rotation
// with nadir pointing rotation shall be identity.
rotCompo = rotCenter.composeInverse(rotNadir, RotationConvention.VECTOR_OPERATOR);
angle = rotCompo.getAngle();
Assert.assertEquals(angle, 0.0, 5.e-6);
// Satellite on any position
// ***************************
circ = new CircularOrbit(7178000.0, 1.e-5, 0., FastMath.toRadians(50.), 0., FastMath.toRadians(90.), PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
// Get nadir attitude
rotNadir = nadirAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// Get earth center attitude
rotCenter = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// For a satellite at any position, earth center pointing attitude and nadir pointing
// and nadir pointing attitude shall not be the same, i.e the composition of inverse earth
// pointing rotation with nadir pointing rotation shall be different from identity.
rotCompo = rotCenter.composeInverse(rotNadir, RotationConvention.VECTOR_OPERATOR);
angle = rotCompo.getAngle();
Assert.assertEquals(angle, FastMath.toRadians(0.16797386586252272), Utils.epsilonAngle);
}
use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.
the class NadirPointingTest method testVertical.
/**
* Vertical test : check that Z satellite axis is collinear to local vertical axis,
* which direction is : (cos(lon)*cos(lat), sin(lon)*cos(lat), sin(lat)),
* where lon et lat stand for observed point coordinates
* (i.e satellite ones, since they are the same by construction,
* but that's what is to test.
*/
@Test
public void testVertical() throws OrekitException {
// Elliptic earth shape
OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
// Create earth center pointing attitude provider
NadirPointing nadirAttitudeLaw = new NadirPointing(FramesFactory.getEME2000(), earthShape);
// Satellite on any position
CircularOrbit circ = new CircularOrbit(7178000.0, 1.e-5, 0., FastMath.toRadians(50.), 0., FastMath.toRadians(90.), PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
// Vertical test
// ***************
// Get observed ground point position/velocity
TimeStampedPVCoordinates pvTargetItrf = nadirAttitudeLaw.getTargetPV(circ, date, itrf);
// Convert to geodetic coordinates
GeodeticPoint geoTarget = earthShape.transform(pvTargetItrf.getPosition(), itrf, date);
// Compute local vertical axis
double xVert = FastMath.cos(geoTarget.getLongitude()) * FastMath.cos(geoTarget.getLatitude());
double yVert = FastMath.sin(geoTarget.getLongitude()) * FastMath.cos(geoTarget.getLatitude());
double zVert = FastMath.sin(geoTarget.getLatitude());
Vector3D targetVertical = new Vector3D(xVert, yVert, zVert);
// Get attitude rotation state
Rotation rotSatEME2000 = nadirAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// Get satellite Z axis in EME2000 frame
Vector3D zSatEME2000 = rotSatEME2000.applyInverseTo(Vector3D.PLUS_K);
Vector3D zSatItrf = FramesFactory.getEME2000().getTransformTo(itrf, date).transformVector(zSatEME2000);
// Check that satellite Z axis is collinear to local vertical axis
double angle = Vector3D.angle(zSatItrf, targetVertical);
Assert.assertEquals(0.0, FastMath.sin(angle), Utils.epsilonTest);
}
use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.
the class NadirPointingTest method testSlidingDerivatives.
/**
* Test the derivatives of the sliding target
*/
@Test
public void testSlidingDerivatives() throws OrekitException {
// Elliptic earth shape
OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
// Create earth center pointing attitude provider
NadirPointing nadirAttitudeLaw = new NadirPointing(FramesFactory.getEME2000(), earthShape);
// Satellite on any position
CircularOrbit circ = new CircularOrbit(7178000.0, 1.e-5, 0., FastMath.toRadians(50.), 0., FastMath.toRadians(90.), PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
for (double dt = -0.1; dt < 0.1; dt += 0.05) {
Orbit o = circ.shiftedBy(dt);
sample.add(nadirAttitudeLaw.getTargetPV(o, o.getDate(), o.getFrame()));
}
TimeStampedPVCoordinates reference = TimeStampedPVCoordinates.interpolate(circ.getDate(), CartesianDerivativesFilter.USE_P, sample);
TimeStampedPVCoordinates target = nadirAttitudeLaw.getTargetPV(circ, circ.getDate(), circ.getFrame());
Assert.assertEquals(0.0, Vector3D.distance(reference.getPosition(), target.getPosition()), 1.0e-15 * reference.getPosition().getNorm());
Assert.assertEquals(0.0, Vector3D.distance(reference.getVelocity(), target.getVelocity()), 3.0e-11 * reference.getVelocity().getNorm());
Assert.assertEquals(0.0, Vector3D.distance(reference.getAcceleration(), target.getAcceleration()), 1.3e-5 * reference.getAcceleration().getNorm());
}
use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.
the class BodyCenterPointingTest method doTestSpin.
private <T extends RealFieldElement<T>> void doTestSpin(final Field<T> field) throws OrekitException {
final double ehMu = 3.9860047e14;
final double ae = 6.378137e6;
final double c20 = -1.08263e-3;
final double c30 = 2.54e-6;
final double c40 = 1.62e-6;
final double c50 = 2.3e-7;
final double c60 = -5.5e-7;
// Satellite position as circular parameters
final T zero = field.getZero();
final T a = zero.add(7178000.0);
final T e = zero.add(7e-5);
final T i = zero.add(FastMath.toRadians(50.));
final T pa = zero.add(FastMath.toRadians(45.));
final T raan = zero.add(FastMath.toRadians(270.));
final T m = zero.add(FastMath.toRadians(5.3 - 270));
// Computation date
FieldAbsoluteDate<T> date_R = new FieldAbsoluteDate<>(field, new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getUTC());
// Orbit
FieldKeplerianOrbit<T> circ = new FieldKeplerianOrbit<>(a, e, i, pa, raan, m, PositionAngle.MEAN, FramesFactory.getEME2000(), date_R, ehMu);
// WGS84 Earth model
OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
// Earth center pointing attitude provider
BodyCenterPointing earthCenterAttitudeLaw = new BodyCenterPointing(circ.getFrame(), earth);
final FieldAbsoluteDate<T> date = FieldAbsoluteDate.getJ2000Epoch(field).shiftedBy(584.);
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(3220103.), zero.add(69623.), zero.add(6449822.));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(6414.7), zero.add(-2006.), zero.add(-3180.));
final FieldCircularOrbit<T> initialOrbit = new FieldCircularOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, ehMu);
FieldEcksteinHechlerPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(initialOrbit, ae, ehMu, c20, c30, c40, c50, c60);
propagator.setAttitudeProvider(earthCenterAttitudeLaw);
double h = 0.01;
FieldSpacecraftState<T> s0 = propagator.propagate(date);
FieldSpacecraftState<T> sMinus = propagator.propagate(date.shiftedBy(-h));
FieldSpacecraftState<T> sPlus = propagator.propagate(date.shiftedBy(h));
// check spin is consistent with attitude evolution
T errorAngleMinus = FieldRotation.distance(sMinus.shiftedBy(zero.add(h)).getAttitude().getRotation(), s0.getAttitude().getRotation());
T evolutionAngleMinus = FieldRotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAngleMinus.getReal(), 1.0e-6 * evolutionAngleMinus.getReal());
T errorAnglePlus = FieldRotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(zero.add(-h)).getAttitude().getRotation());
T evolutionAnglePlus = FieldRotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAnglePlus.getReal(), 1.0e-6 * evolutionAnglePlus.getReal());
FieldVector3D<T> spin0 = s0.getAttitude().getSpin();
FieldVector3D<T> reference = FieldAngularCoordinates.estimateRate(sMinus.getAttitude().getRotation(), sPlus.getAttitude().getRotation(), 2 * h);
Assert.assertTrue(spin0.getNorm().getReal() > 1.0e-3);
Assert.assertEquals(0.0, spin0.subtract(reference).getNorm().getReal(), 1.0e-13);
}
Aggregations