use of org.orekit.errors.OrekitExceptionWrapper in project Orekit by CS-SI.
the class AbstractIntegratedPropagator method propagate.
/**
* Propagation with or without event detection.
* @param tEnd target date to which orbit should be propagated
* @param activateHandlers if true, step and event handlers should be activated
* @return state at end of propagation
* @exception OrekitException if orbit cannot be propagated
*/
protected SpacecraftState propagate(final AbsoluteDate tEnd, final boolean activateHandlers) throws OrekitException {
try {
if (getInitialState().getDate().equals(tEnd)) {
// don't extrapolate
return getInitialState();
}
// space dynamics view
stateMapper = createMapper(getInitialState().getDate(), stateMapper.getMu(), stateMapper.getOrbitType(), stateMapper.getPositionAngleType(), stateMapper.getAttitudeProvider(), getInitialState().getFrame());
// set propagation orbit type
final Orbit initialOrbit = stateMapper.getOrbitType().convertType(getInitialState().getOrbit());
if (Double.isNaN(getMu())) {
setMu(initialOrbit.getMu());
}
if (getInitialState().getMass() <= 0.0) {
throw new OrekitException(OrekitMessages.SPACECRAFT_MASS_BECOMES_NEGATIVE, getInitialState().getMass());
}
integrator.clearEventHandlers();
// set up events added by user
setUpUserEventDetectors();
// convert space flight dynamics API to math API
final ODEState mathInitialState = createInitialState(getInitialIntegrationState());
final ExpandableODE mathODE = createODE(integrator, mathInitialState);
equationsMapper = mathODE.getMapper();
// initialize mode handler
if (modeHandler != null) {
modeHandler.initialize(activateHandlers, tEnd);
}
// mathematical integration
final ODEStateAndDerivative mathFinalState;
try {
beforeIntegration(getInitialState(), tEnd);
mathFinalState = integrator.integrate(mathODE, mathInitialState, tEnd.durationFrom(getInitialState().getDate()));
afterIntegration();
} catch (OrekitExceptionWrapper oew) {
throw oew.getException();
}
// get final state
SpacecraftState finalState = stateMapper.mapArrayToState(stateMapper.mapDoubleToDate(mathFinalState.getTime(), tEnd), mathFinalState.getPrimaryState(), mathFinalState.getPrimaryDerivative(), meanOrbit);
finalState = updateAdditionalStates(finalState);
for (int i = 0; i < additionalEquations.size(); ++i) {
final double[] secondary = mathFinalState.getSecondaryState(i + 1);
finalState = finalState.addAdditionalState(additionalEquations.get(i).getName(), secondary);
}
if (resetAtEnd) {
resetInitialState(finalState);
setStartDate(finalState.getDate());
}
return finalState;
} catch (MathRuntimeException mre) {
throw OrekitException.unwrap(mre);
}
}
use of org.orekit.errors.OrekitExceptionWrapper in project Orekit by CS-SI.
the class AngularAzElMeasurementCreator 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();
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);
// Satellite position at signal departure
final Vector3D satelliteAtDeparture = currentState.shiftedBy(-downLinkDelay).getPVCoordinates().getPosition();
// Initialize measurement
final double[] angular = new double[2];
final double[] sigma = { 1.0, 1.0 };
final double[] baseweight = { 10.0, 10.0 };
// Compute measurement
// Elevation
angular[1] = station.getBaseFrame().getElevation(satelliteAtDeparture, currentState.getFrame(), currentState.getDate());
// Azimuth
angular[0] = station.getBaseFrame().getAzimuth(satelliteAtDeparture, currentState.getFrame(), currentState.getDate());
addMeasurement(new AngularAzEl(station, date, angular, sigma, baseweight));
}
}
}
use of org.orekit.errors.OrekitExceptionWrapper in project Orekit by CS-SI.
the class AngularRaDecMeasurementCreator 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();
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);
// Satellite position at signal departure
final Vector3D satelliteAtDeparture = currentState.shiftedBy(-downLinkDelay).getPVCoordinates().getPosition();
// Initialize measurement
final double[] angular = new double[2];
final double[] sigma = { 1.0, 1.0 };
final double[] baseweight = { 10.0, 10.0 };
// Inertial frame used
final Frame inertialFrame = context.initialOrbit.getFrame();
// Station position at signal arrival
// Set the reference date of offset drivers arbitrarily to avoid exception
station.getPrimeMeridianOffsetDriver().setReferenceDate(date);
station.getPolarOffsetXDriver().setReferenceDate(date);
station.getPolarOffsetYDriver().setReferenceDate(date);
final Transform offsetToInertialArrival = station.getOffsetToInertial(inertialFrame, date);
final Vector3D stationPArrival = offsetToInertialArrival.transformVector(Vector3D.ZERO);
// Vector station position at signal arrival - satellite at signal departure
// In inertial reference frame
final Vector3D staSat = satelliteAtDeparture.subtract(stationPArrival);
// Compute measurement
// Right ascension
final double baseRightAscension = staSat.getAlpha();
angular[0] = MathUtils.normalizeAngle(baseRightAscension, 0.0);
// Declination
angular[1] = staSat.getDelta();
addMeasurement(new AngularRaDec(station, inertialFrame, date, angular, sigma, baseweight));
}
}
}
use of org.orekit.errors.OrekitExceptionWrapper 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.orekit.errors.OrekitExceptionWrapper 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);
}
}
Aggregations