use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.
the class ElevationDetectorTest method testEventForMask.
@Test
public void testEventForMask() throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
Propagator propagator = new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
// Earth and frame
// equatorial radius in meter
double ae = 6378137.0;
// flattening
double f = 1.0 / 298.257223563;
// terrestrial frame at an arbitrary date
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833), FastMath.toRadians(2.333), 0.0);
TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
double[][] maskValues = { { FastMath.toRadians(0), FastMath.toRadians(5) }, { FastMath.toRadians(30), FastMath.toRadians(4) }, { FastMath.toRadians(60), FastMath.toRadians(3) }, { FastMath.toRadians(90), FastMath.toRadians(2) }, { FastMath.toRadians(120), FastMath.toRadians(3) }, { FastMath.toRadians(150), FastMath.toRadians(4) }, { FastMath.toRadians(180), FastMath.toRadians(5) }, { FastMath.toRadians(210), FastMath.toRadians(6) }, { FastMath.toRadians(240), FastMath.toRadians(5) }, { FastMath.toRadians(270), FastMath.toRadians(4) }, { FastMath.toRadians(300), FastMath.toRadians(3) }, { FastMath.toRadians(330), FastMath.toRadians(4) } };
ElevationMask mask = new ElevationMask(maskValues);
ElevationDetector detector = new ElevationDetector(topo).withElevationMask(mask).withHandler(new StopOnIncreasing<ElevationDetector>());
Assert.assertSame(mask, detector.getElevationMask());
AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 20, 0, 0, utc);
propagator.resetInitialState(propagator.propagate(startDate));
propagator.addEventDetector(detector);
final SpacecraftState fs = propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
double elevation = topo.getElevation(fs.getPVCoordinates().getPosition(), fs.getFrame(), fs.getDate());
Assert.assertEquals(0.065, elevation, 2.0e-5);
}
use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.
the class FieldOfViewTest method testRollPitchYawHexagonalFootprint.
@Test
public void testRollPitchYawHexagonalFootprint() throws OrekitException {
Utils.setDataRoot("regular-data");
FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(3.0), 6, 0.0);
OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
KeplerianOrbit orbit = new KeplerianOrbit(new PVCoordinates(new Vector3D(7.0e6, 1.0e6, 4.0e6), new Vector3D(-500.0, 8000.0, 1000.0)), FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, Constants.EIGEN5C_EARTH_MU);
Propagator propagator = new KeplerianPropagator(orbit);
propagator.setAttitudeProvider(new LofOffset(orbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(10), FastMath.toRadians(20), FastMath.toRadians(5)));
SpacecraftState state = propagator.propagate(orbit.getDate().shiftedBy(1000.0));
Transform inertToBody = state.getFrame().getTransformTo(earth.getBodyFrame(), state.getDate());
Transform fovToBody = new Transform(state.getDate(), state.toTransform().getInverse(), inertToBody);
List<List<GeodeticPoint>> footprint = fov.getFootprint(fovToBody, earth, FastMath.toRadians(0.1));
Vector3D subSat = earth.projectToGround(state.getPVCoordinates(earth.getBodyFrame()).getPosition(), state.getDate(), earth.getBodyFrame());
Assert.assertEquals(1, footprint.size());
List<GeodeticPoint> loop = footprint.get(0);
Assert.assertEquals(210, loop.size());
double minEl = Double.POSITIVE_INFINITY;
double maxEl = 0;
double minDist = Double.POSITIVE_INFINITY;
double maxDist = 0;
for (int i = 0; i < loop.size(); ++i) {
Assert.assertEquals(0.0, loop.get(i).getAltitude(), 1.0e-15);
TopocentricFrame topo = new TopocentricFrame(earth, loop.get(i), "atLimb");
final double elevation = topo.getElevation(state.getPVCoordinates().getPosition(), state.getFrame(), state.getDate());
minEl = FastMath.min(minEl, elevation);
maxEl = FastMath.max(maxEl, elevation);
final double dist = Vector3D.distance(subSat, earth.transform(loop.get(i)));
minDist = FastMath.min(minDist, dist);
maxDist = FastMath.max(maxDist, dist);
}
Assert.assertEquals(48.0026, FastMath.toDegrees(minEl), 0.001);
Assert.assertEquals(60.1975, FastMath.toDegrees(maxEl), 0.001);
Assert.assertEquals(1221543.6, minDist, 1.0);
Assert.assertEquals(1804921.6, maxDist, 1.0);
}
use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.
the class FieldOfViewTest method testFOVPartiallyTruncatedAtLimb.
@Test
public void testFOVPartiallyTruncatedAtLimb() throws OrekitException {
Utils.setDataRoot("regular-data");
FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(40.0), 6, 0.0);
OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
KeplerianOrbit orbit = new KeplerianOrbit(new PVCoordinates(new Vector3D(7.0e6, 1.0e6, 4.0e6), new Vector3D(-500.0, 8000.0, 1000.0)), FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, Constants.EIGEN5C_EARTH_MU);
Propagator propagator = new KeplerianPropagator(orbit);
propagator.setAttitudeProvider(new NadirPointing(orbit.getFrame(), earth));
SpacecraftState state = propagator.propagate(orbit.getDate().shiftedBy(1000.0));
Transform inertToBody = state.getFrame().getTransformTo(earth.getBodyFrame(), state.getDate());
Transform fovToBody = new Transform(state.getDate(), state.toTransform().getInverse(), inertToBody);
List<List<GeodeticPoint>> footprint = fov.getFootprint(fovToBody, earth, FastMath.toRadians(1.0));
Vector3D subSat = earth.projectToGround(state.getPVCoordinates(earth.getBodyFrame()).getPosition(), state.getDate(), earth.getBodyFrame());
Assert.assertEquals(1, footprint.size());
List<GeodeticPoint> loop = footprint.get(0);
Assert.assertEquals(246, loop.size());
double minEl = Double.POSITIVE_INFINITY;
double maxEl = 0;
double minDist = Double.POSITIVE_INFINITY;
double maxDist = 0;
for (int i = 0; i < loop.size(); ++i) {
Assert.assertEquals(0.0, loop.get(i).getAltitude(), 3.0e-7);
TopocentricFrame topo = new TopocentricFrame(earth, loop.get(i), "atLimb");
final double elevation = topo.getElevation(state.getPVCoordinates().getPosition(), state.getFrame(), state.getDate());
minEl = FastMath.min(minEl, elevation);
maxEl = FastMath.max(maxEl, elevation);
final double dist = Vector3D.distance(subSat, earth.transform(loop.get(i)));
minDist = FastMath.min(minDist, dist);
maxDist = FastMath.max(maxDist, dist);
}
Assert.assertEquals(0.0, FastMath.toDegrees(minEl), 2.0e-12);
Assert.assertEquals(7.8897, FastMath.toDegrees(maxEl), 0.001);
Assert.assertEquals(4584829.6, minDist, 1.0);
Assert.assertEquals(5347029.8, maxDist, 1.0);
}
use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.
the class BackAndForthDetectorTest method testBackAndForth.
@Test
public void testBackAndForth() throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
final AbsoluteDate date0 = new AbsoluteDate(2006, 12, 27, 12, 0, 0.0, utc);
final AbsoluteDate date1 = new AbsoluteDate(2006, 12, 27, 22, 50, 0.0, utc);
final AbsoluteDate date2 = new AbsoluteDate(2006, 12, 27, 22, 58, 0.0, utc);
// Orbit
final double a = 7274000.;
final double e = 0.00127;
final double i = FastMath.toRadians(90.);
final double w = FastMath.toRadians(0.);
final double raan = FastMath.toRadians(12.5);
final double lM = FastMath.toRadians(60.);
Orbit iniOrb = new KeplerianOrbit(a, e, i, w, raan, lM, PositionAngle.MEAN, FramesFactory.getEME2000(), date0, Constants.WGS84_EARTH_MU);
// Propagator
KeplerianPropagator propagator = new KeplerianPropagator(iniOrb);
// Station
final GeodeticPoint stationPosition = new GeodeticPoint(FastMath.toRadians(0.), FastMath.toRadians(100.), 110.);
final BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
final TopocentricFrame stationFrame = new TopocentricFrame(earth, stationPosition, "");
// Detector
final Visibility visi = new Visibility();
propagator.addEventDetector(new ElevationDetector(stationFrame).withConstantElevation(FastMath.toRadians(10.)).withHandler(visi));
// Forward propagation (AOS + LOS)
propagator.propagate(date1);
propagator.propagate(date2);
// Backward propagation (AOS + LOS)
propagator.propagate(date1);
propagator.propagate(date0);
Assert.assertEquals(4, visi.getVisiNb());
}
use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.
the class AttitudesSequenceTest method testResetDuringTransitionForward.
@Test
public void testResetDuringTransitionForward() throws OrekitException {
// Initial state definition : date, orbit
final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
final TopocentricFrame volgograd = new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(48.7), FastMath.toRadians(44.5), 24.0), "Волгоград");
final AttitudesSequence attitudesSequence = new AttitudesSequence();
final double transitionTime = 250.0;
final AttitudeProvider nadirPointing = new NadirPointing(initialOrbit.getFrame(), earth);
final AttitudeProvider targetPointing = new TargetPointing(initialOrbit.getFrame(), volgograd.getPoint(), earth);
final ElevationDetector eventDetector = new ElevationDetector(volgograd).withConstantElevation(FastMath.toRadians(5.0)).withHandler(new ContinueOnEvent<>());
final List<AbsoluteDate> nadirToTarget = new ArrayList<>();
attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, (previous, next, state) -> nadirToTarget.add(state.getDate()));
final double[][] tolerance = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
final AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 300.0, tolerance[0], tolerance[1]);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false));
propagator.addForceModel(new HolmesFeatherstoneAttractionModel(earth.getBodyFrame(), GravityFieldFactory.getNormalizedProvider(8, 8)));
propagator.setInitialState(new SpacecraftState(initialOrbit, nadirPointing.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame())));
propagator.setAttitudeProvider(attitudesSequence);
attitudesSequence.registerSwitchEvents(propagator);
propagator.propagate(initialDate.shiftedBy(6000));
// check that if we restart a forward propagation from an intermediate state
// we properly get an interpolated attitude despite we missed the event trigger
final AbsoluteDate midTransition = nadirToTarget.get(0).shiftedBy(0.5 * transitionTime);
SpacecraftState state = propagator.propagate(midTransition.shiftedBy(-60), midTransition);
Rotation nadirR = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
Rotation targetR = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
final double reorientationAngle = Rotation.distance(nadirR, targetR);
Assert.assertEquals(0.5 * reorientationAngle, Rotation.distance(state.getAttitude().getRotation(), nadirR), 0.03 * reorientationAngle);
}
Aggregations