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);
}
}
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);
}
}
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));
}
}
}
Aggregations