Search in sources :

Example 6 with ElevationDetector

use of org.orekit.propagation.events.ElevationDetector in project Orekit by CS-SI.

the class AttitudesSequenceTest method testResetDuringTransitionBackward.

@Test
public void testResetDuringTransitionBackward() 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 backward 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(), targetR), 0.03 * reorientationAngle);
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) ICGEMFormatReader(org.orekit.forces.gravity.potential.ICGEMFormatReader) ElevationDetector(org.orekit.propagation.events.ElevationDetector) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) ArrayList(java.util.ArrayList) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) FieldOrbit(org.orekit.orbits.FieldOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Example 7 with ElevationDetector

use of org.orekit.propagation.events.ElevationDetector in project Orekit by CS-SI.

the class EcksteinHechlerPropagatorTest method setting.

@Test
public void setting() throws OrekitException {
    final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, provider);
    final OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final TopocentricFrame topo = new TopocentricFrame(earthShape, new GeodeticPoint(0.389, -2.962, 0), null);
    ElevationDetector detector = new ElevationDetector(60, 1.0e-9, topo).withConstantElevation(0.09);
    Assert.assertEquals(0.09, detector.getMinElevation(), 1.0e-12);
    Assert.assertTrue(topo == detector.getTopocentricFrame());
    propagator.addEventDetector(detector);
    AbsoluteDate farTarget = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
    SpacecraftState propagated = propagator.propagate(farTarget);
    final double elevation = topo.getElevation(propagated.getPVCoordinates().getPosition(), propagated.getFrame(), propagated.getDate());
    final double zVelocity = propagated.getPVCoordinates(topo).getVelocity().getZ();
    Assert.assertTrue(farTarget.durationFrom(propagated.getDate()) > 7800.0);
    Assert.assertTrue("Incorrect value " + farTarget.durationFrom(propagated.getDate()) + " !< 7900", farTarget.durationFrom(propagated.getDate()) < 7900.0);
    Assert.assertEquals(0.09, elevation, 1.0e-11);
    Assert.assertTrue(zVelocity < 0);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) ElevationDetector(org.orekit.propagation.events.ElevationDetector) TopocentricFrame(org.orekit.frames.TopocentricFrame) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 8 with ElevationDetector

use of org.orekit.propagation.events.ElevationDetector in project Orekit by CS-SI.

the class VisibilityCheck method main.

/**
 * Program entry point.
 * @param args program arguments (unused here)
 */
public static void main(String[] args) {
    try {
        // configure Orekit
        File home = new File(System.getProperty("user.home"));
        File orekitData = new File(home, "orekit-data");
        if (!orekitData.exists()) {
            System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
            System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
            System.exit(1);
        }
        DataProvidersManager manager = DataProvidersManager.getInstance();
        manager.addProvider(new DirectoryCrawler(orekitData));
        // Initial state definition : date, orbit
        AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
        // gravitation coefficient
        double mu = 3.986004415e+14;
        // inertial frame for orbit definition
        Frame inertialFrame = FramesFactory.getEME2000();
        Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
        Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
        PVCoordinates pvCoordinates = new PVCoordinates(position, velocity);
        Orbit initialOrbit = new KeplerianOrbit(pvCoordinates, inertialFrame, initialDate, mu);
        // Propagator : consider a simple Keplerian motion (could be more elaborate)
        Propagator kepler = new KeplerianPropagator(initialOrbit);
        // Earth and frame
        Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame);
        // Station
        final double longitude = FastMath.toRadians(45.);
        final double latitude = FastMath.toRadians(25.);
        final double altitude = 0.;
        final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude);
        final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1");
        // Event definition
        final double maxcheck = 60.0;
        final double threshold = 0.001;
        final double elevation = FastMath.toRadians(5.0);
        final EventDetector sta1Visi = new ElevationDetector(maxcheck, threshold, sta1Frame).withConstantElevation(elevation).withHandler(new VisibilityHandler());
        // Add event to be detected
        kepler.addEventDetector(sta1Visi);
        // Propagate from the initial date to the first raising or for the fixed duration
        SpacecraftState finalState = kepler.propagate(initialDate.shiftedBy(1500.));
        System.out.println(" Final state : " + finalState.getDate().durationFrom(initialDate));
    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Orbit(org.orekit.orbits.Orbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) ElevationDetector(org.orekit.propagation.events.ElevationDetector) PVCoordinates(org.orekit.utils.PVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) EventDetector(org.orekit.propagation.events.EventDetector) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) DirectoryCrawler(org.orekit.data.DirectoryCrawler) DataProvidersManager(org.orekit.data.DataProvidersManager) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint) File(java.io.File)

Aggregations

GeodeticPoint (org.orekit.bodies.GeodeticPoint)8 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)8 TopocentricFrame (org.orekit.frames.TopocentricFrame)8 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)8 ElevationDetector (org.orekit.propagation.events.ElevationDetector)8 AbsoluteDate (org.orekit.time.AbsoluteDate)8 Test (org.junit.Test)7 SpacecraftState (org.orekit.propagation.SpacecraftState)7 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)5 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)4 Orbit (org.orekit.orbits.Orbit)4 PVCoordinates (org.orekit.utils.PVCoordinates)4 ArrayList (java.util.ArrayList)3 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)3 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)3 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)3 HolmesFeatherstoneAttractionModel (org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel)3 ICGEMFormatReader (org.orekit.forces.gravity.potential.ICGEMFormatReader)3 Frame (org.orekit.frames.Frame)3 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)3