Search in sources :

Example 6 with UnivariateSolver

use of org.hipparchus.analysis.solvers.UnivariateSolver in project Orekit by CS-SI.

the class InterSatellitesRangeMeasurementCreator method handleStep.

public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
    try {
        final AbsoluteDate date = currentState.getDate();
        final Vector3D position = currentState.toTransform().getInverse().transformPosition(antennaPhaseCenter1);
        final UnivariateSolver solver = new BracketingNthOrderBrentSolver(1.0e-12, 5);
        final double downLinkDelay = solver.solve(1000, new UnivariateFunction() {

            public double value(final double x) throws OrekitExceptionWrapper {
                try {
                    final Vector3D other = ephemeris.propagate(date.shiftedBy(-x)).toTransform().getInverse().transformPosition(antennaPhaseCenter2);
                    final double d = Vector3D.distance(position, other);
                    return d - x * Constants.SPEED_OF_LIGHT;
                } catch (OrekitException oe) {
                    throw new OrekitExceptionWrapper(oe);
                }
            }
        }, -1.0, 1.0);
        final AbsoluteDate transitDate = currentState.getDate().shiftedBy(-downLinkDelay);
        final Vector3D otherAtTransit = ephemeris.propagate(transitDate).toTransform().getInverse().transformPosition(antennaPhaseCenter2);
        final double downLinkDistance = Vector3D.distance(position, otherAtTransit);
        if ((++count % 2) == 0) {
            // generate a two-way measurement
            final double upLinkDelay = solver.solve(1000, new UnivariateFunction() {

                public double value(final double x) throws OrekitExceptionWrapper {
                    final Vector3D self = currentState.shiftedBy(-downLinkDelay - x).toTransform().getInverse().transformPosition(antennaPhaseCenter1);
                    final double d = Vector3D.distance(otherAtTransit, self);
                    return d - x * Constants.SPEED_OF_LIGHT;
                }
            }, -1.0, 1.0);
            final Vector3D selfAtEmission = currentState.shiftedBy(-downLinkDelay - upLinkDelay).toTransform().getInverse().transformPosition(antennaPhaseCenter1);
            final double upLinkDistance = Vector3D.distance(otherAtTransit, selfAtEmission);
            addMeasurement(new InterSatellitesRange(0, 1, true, date, 0.5 * (downLinkDistance + upLinkDistance), 1.0, 10));
        } else {
            // generate a one-way measurement
            addMeasurement(new InterSatellitesRange(0, 1, false, date, downLinkDistance, 1.0, 10));
        }
    } catch (OrekitExceptionWrapper oew) {
        throw new OrekitException(oew.getException());
    } catch (OrekitException oe) {
        throw new OrekitException(oe);
    }
}
Also used : OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateSolver(org.hipparchus.analysis.solvers.UnivariateSolver) OrekitException(org.orekit.errors.OrekitException) AbsoluteDate(org.orekit.time.AbsoluteDate) BracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver)

Example 7 with UnivariateSolver

use of org.hipparchus.analysis.solvers.UnivariateSolver in project Orekit by CS-SI.

the class RangeMeasurementCreator method handleStep.

public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
    try {
        for (final GroundStation station : context.stations) {
            final AbsoluteDate date = currentState.getDate();
            final Frame inertial = currentState.getFrame();
            final Vector3D position = currentState.toTransform().getInverse().transformPosition(antennaPhaseCenter);
            if (station.getBaseFrame().getElevation(position, inertial, date) > FastMath.toRadians(30.0)) {
                final UnivariateSolver solver = new BracketingNthOrderBrentSolver(1.0e-12, 5);
                final double downLinkDelay = solver.solve(1000, new UnivariateFunction() {

                    public double value(final double x) throws OrekitExceptionWrapper {
                        try {
                            final Transform t = station.getOffsetToInertial(inertial, date.shiftedBy(x));
                            final double d = Vector3D.distance(position, t.transformPosition(Vector3D.ZERO));
                            return d - x * Constants.SPEED_OF_LIGHT;
                        } catch (OrekitException oe) {
                            throw new OrekitExceptionWrapper(oe);
                        }
                    }
                }, -1.0, 1.0);
                final AbsoluteDate receptionDate = currentState.getDate().shiftedBy(downLinkDelay);
                final Vector3D stationAtReception = station.getOffsetToInertial(inertial, receptionDate).transformPosition(Vector3D.ZERO);
                final double downLinkDistance = Vector3D.distance(position, stationAtReception);
                final double upLinkDelay = solver.solve(1000, new UnivariateFunction() {

                    public double value(final double x) throws OrekitExceptionWrapper {
                        try {
                            final Transform t = station.getOffsetToInertial(inertial, date.shiftedBy(-x));
                            final double d = Vector3D.distance(position, t.transformPosition(Vector3D.ZERO));
                            return d - x * Constants.SPEED_OF_LIGHT;
                        } catch (OrekitException oe) {
                            throw new OrekitExceptionWrapper(oe);
                        }
                    }
                }, -1.0, 1.0);
                final AbsoluteDate emissionDate = currentState.getDate().shiftedBy(-upLinkDelay);
                final Vector3D stationAtEmission = station.getOffsetToInertial(inertial, emissionDate).transformPosition(Vector3D.ZERO);
                final double upLinkDistance = Vector3D.distance(position, stationAtEmission);
                addMeasurement(new Range(station, receptionDate, 0.5 * (downLinkDistance + upLinkDistance), 1.0, 10));
            }
        }
    } catch (OrekitExceptionWrapper oew) {
        throw new OrekitException(oew.getException());
    } catch (OrekitException oe) {
        throw new OrekitException(oe);
    }
}
Also used : Frame(org.orekit.frames.Frame) OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateSolver(org.hipparchus.analysis.solvers.UnivariateSolver) OrekitException(org.orekit.errors.OrekitException) Transform(org.orekit.frames.Transform) AbsoluteDate(org.orekit.time.AbsoluteDate) BracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver)

Example 8 with UnivariateSolver

use of org.hipparchus.analysis.solvers.UnivariateSolver in project Orekit by CS-SI.

the class RangeRateMeasurementCreator method handleStep.

public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
    for (final GroundStation station : context.stations) {
        final AbsoluteDate date = currentState.getDate();
        final Frame inertial = currentState.getFrame();
        final Vector3D position = currentState.getPVCoordinates().getPosition();
        final Vector3D velocity = currentState.getPVCoordinates().getVelocity();
        if (station.getBaseFrame().getElevation(position, inertial, date) > FastMath.toRadians(30.0)) {
            final UnivariateSolver solver = new BracketingNthOrderBrentSolver(1.0e-12, 5);
            final double downLinkDelay = solver.solve(1000, new UnivariateFunction() {

                public double value(final double x) throws OrekitExceptionWrapper {
                    try {
                        final Transform t = station.getOffsetToInertial(inertial, date.shiftedBy(x));
                        final double d = Vector3D.distance(position, t.transformPosition(Vector3D.ZERO));
                        return d - x * Constants.SPEED_OF_LIGHT;
                    } catch (OrekitException oe) {
                        throw new OrekitExceptionWrapper(oe);
                    }
                }
            }, -1.0, 1.0);
            final AbsoluteDate receptionDate = currentState.getDate().shiftedBy(downLinkDelay);
            final PVCoordinates stationAtReception = station.getOffsetToInertial(inertial, receptionDate).transformPVCoordinates(PVCoordinates.ZERO);
            // line of sight at reception
            final Vector3D receptionLOS = (position.subtract(stationAtReception.getPosition())).normalize();
            // relative velocity, spacecraft-station, at the date of reception
            final Vector3D deltaVr = velocity.subtract(stationAtReception.getVelocity());
            final double upLinkDelay = solver.solve(1000, new UnivariateFunction() {

                public double value(final double x) throws OrekitExceptionWrapper {
                    try {
                        final Transform t = station.getOffsetToInertial(inertial, date.shiftedBy(-x));
                        final double d = Vector3D.distance(position, t.transformPosition(Vector3D.ZERO));
                        return d - x * Constants.SPEED_OF_LIGHT;
                    } catch (OrekitException oe) {
                        throw new OrekitExceptionWrapper(oe);
                    }
                }
            }, -1.0, 1.0);
            final AbsoluteDate emissionDate = currentState.getDate().shiftedBy(-upLinkDelay);
            final PVCoordinates stationAtEmission = station.getOffsetToInertial(inertial, emissionDate).transformPVCoordinates(PVCoordinates.ZERO);
            // line of sight at emission
            final Vector3D emissionLOS = (position.subtract(stationAtEmission.getPosition())).normalize();
            // relative velocity, spacecraft-station, at the date of emission
            final Vector3D deltaVe = velocity.subtract(stationAtEmission.getVelocity());
            // range rate at the date of reception
            final double rr = twoWay ? 0.5 * (deltaVr.dotProduct(receptionLOS) + deltaVe.dotProduct(emissionLOS)) : deltaVr.dotProduct(receptionLOS);
            addMeasurement(new RangeRate(station, date, rr, 1.0, 10, twoWay));
        }
    }
}
Also used : Frame(org.orekit.frames.Frame) OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) UnivariateSolver(org.hipparchus.analysis.solvers.UnivariateSolver) PVCoordinates(org.orekit.utils.PVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) BracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) OrekitException(org.orekit.errors.OrekitException) Transform(org.orekit.frames.Transform)

Aggregations

UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)8 BracketingNthOrderBrentSolver (org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver)8 UnivariateSolver (org.hipparchus.analysis.solvers.UnivariateSolver)8 OrekitException (org.orekit.errors.OrekitException)8 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)7 OrekitExceptionWrapper (org.orekit.errors.OrekitExceptionWrapper)7 Frame (org.orekit.frames.Frame)6 Transform (org.orekit.frames.Transform)6 AbsoluteDate (org.orekit.time.AbsoluteDate)6 MathRuntimeException (org.hipparchus.exception.MathRuntimeException)2 GeodeticPoint (org.orekit.bodies.GeodeticPoint)2 Map (java.util.Map)1 RealFieldUnivariateFunction (org.hipparchus.analysis.RealFieldUnivariateFunction)1 FieldBracketingNthOrderBrentSolver (org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver)1 FieldLine (org.hipparchus.geometry.euclidean.threed.FieldLine)1 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)1 Line (org.hipparchus.geometry.euclidean.threed.Line)1 FieldGeodeticPoint (org.orekit.bodies.FieldGeodeticPoint)1 FieldTransform (org.orekit.frames.FieldTransform)1 SpacecraftState (org.orekit.propagation.SpacecraftState)1