use of org.orekit.bodies.GeodeticPoint 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);
}
use of org.orekit.bodies.GeodeticPoint in project Orekit by CS-SI.
the class AttitudesSequenceTest method testOutOfSyncCalls.
@Test
public void testOutOfSyncCalls() 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 Handler nadirToTarget = new Handler(nadirPointing, targetPointing);
attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, nadirToTarget);
final Handler targetToNadir = new Handler(targetPointing, nadirPointing);
attitudesSequence.addSwitchingCondition(targetPointing, nadirPointing, eventDetector, false, true, transitionTime, AngularDerivativesFilter.USE_RR, targetToNadir);
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.setMasterMode(10, (state, isLast) -> {
Attitude nadirAttitude = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
Attitude targetAttitude = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
Attitude stateAttitude = state.getAttitude();
if (nadirToTarget.dates.isEmpty() || state.getDate().durationFrom(nadirToTarget.dates.get(0)) < 0) {
// we are stabilized in nadir pointing, before first switch
checkEqualAttitudes(nadirAttitude, stateAttitude);
} else if (state.getDate().durationFrom(nadirToTarget.dates.get(0)) <= transitionTime) {
// we are in transition from nadir to target
checkBetweenAttitudes(nadirAttitude, targetAttitude, stateAttitude);
} else if (targetToNadir.dates.isEmpty() || state.getDate().durationFrom(targetToNadir.dates.get(0)) < 0) {
// we are stabilized in target pointing between the two switches
checkEqualAttitudes(targetAttitude, stateAttitude);
} else if (state.getDate().durationFrom(targetToNadir.dates.get(0)) <= transitionTime) {
// we are in transition from target to nadir
checkBetweenAttitudes(targetAttitude, nadirAttitude, stateAttitude);
} else {
// we are stabilized back in nadir pointing, after second switch
checkEqualAttitudes(nadirAttitude, stateAttitude);
}
});
propagator.propagate(initialDate.shiftedBy(6000));
}
use of org.orekit.bodies.GeodeticPoint in project SpriteOrbits by ProjectPersephone.
the class SpriteProp method run.
/**
* run the application.
* @param out output file
* @param propagationDuration duration of the propagation
* @param step fixed step between output lines
* @param utc UTC time scale
*/
public void run(final PrintStream out, final double propagationDuration, final double step, final TimeScale utc) throws OrekitException {
final AbsoluteDate start = spritesPropagators.get(0).getInitialState().getDate();
final AbsoluteDate end = start.shiftedBy(propagationDuration * Constants.JULIAN_DAY);
/*out.format(Locale.US, "# file generated on %s%n",
new AbsoluteDate(new Date(), utc).toString(utc));
out.format(Locale.US, "# propagating %d sprites from %s to %s%n",
spritesPropagators.size(), start.toString(utc), end.toString(utc));
out.format(Locale.US, "# column 1: date (UTC)%n");
out.format(Locale.US, "# column 2: date offset since start (seconds)%n");
out.format(Locale.US, "# column 3: KickSat geodetic latitude (degrees)%n");
out.format(Locale.US, "# column 4: KickSat geodetic longitude (degrees)%n");
out.format(Locale.US, "# column 5: KickSat geodetic altitude (meters)%n");
out.format(Locale.US, "# column 3i+3: sprite i geodetic latitude (degrees)%n");
out.format(Locale.US, "# column 3i+4: sprite i geodetic longitude (degrees)%n");
out.format(Locale.US, "# column 3i+5: sprite i geodetic altitude (meters)%n");
*/
// in order to speed up computation, we let the numerical propagator choose its
// steps, and create ephemerides, then we will use the ephemerides with fixed
// steps for output
List<Propagator> ephemerides = new ArrayList<Propagator>(spritesPropagators.size());
for (final Propagator spritePropagator : spritesPropagators) {
spritePropagator.setEphemerisMode();
spritePropagator.propagate(end);
ephemerides.add(spritePropagator.getGeneratedEphemeris());
}
boolean firstTime = true;
for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(step)) {
if (!firstTime) {
out.format(Locale.US, ",");
} else {
firstTime = false;
}
/*out.format(Locale.US, "%s %9.1f", date.toString(utc), date.durationFrom(start));
final GeodeticPoint kickSatGP = geodeticPosition(kickSatPropagator, date);
out.format(Locale.US, " %8.3f %8.3f %8.1f",
FastMath.toDegrees(kickSatGP.getLatitude()),
FastMath.toDegrees(kickSatGP.getLongitude()),
kickSatGP.getAltitude());
for (final Propagator ephemeride : ephemerides) {
final GeodeticPoint spriteGP = geodeticPosition(ephemeride, date);
out.format(Locale.US, " %8.3f %8.3f %8.1f",
FastMath.toDegrees(spriteGP.getLatitude()),
FastMath.toDegrees(spriteGP.getLongitude()),
spriteGP.getAltitude());
}
*/
out.format(Locale.US, "{\"date\":\"%s\",\"offset\":%.1f,", date.toString(utc), date.durationFrom(start));
final GeodeticPoint kickSatGP = geodeticPosition(kickSatPropagator, date);
out.format(Locale.US, "\"kicksat\":{\"lat\":%.3f,\"lng\":%.3f,\"alt\":%.1f},", FastMath.toDegrees(kickSatGP.getLatitude()), FastMath.toDegrees(kickSatGP.getLongitude()), kickSatGP.getAltitude());
out.format(Locale.US, "\"sprites\":[");
boolean firstSprite = true;
for (final Propagator ephemeride : ephemerides) {
final GeodeticPoint spriteGP = geodeticPosition(ephemeride, date);
if (!firstSprite) {
out.format(Locale.US, ",");
} else {
firstSprite = false;
}
out.format(Locale.US, "{\"lat\":%.3f,\"lng\":%.3f,\"alt\":%.1f}", FastMath.toDegrees(spriteGP.getLatitude()), FastMath.toDegrees(spriteGP.getLongitude()), spriteGP.getAltitude());
}
out.format(Locale.US, "]}");
out.println();
}
}
use of org.orekit.bodies.GeodeticPoint in project SpriteOrbits by ProjectPersephone.
the class SpritePropOrig method run.
/**
* run the application.
* @param out output file
* @param propagationDuration duration of the propagation
* @param step fixed step between output lines
* @param utc UTC time scale
*/
public void run(final PrintStream out, final double propagationDuration, final double step, final TimeScale utc) throws OrekitException {
final AbsoluteDate start = spritesPropagators.get(0).getInitialState().getDate();
final AbsoluteDate end = start.shiftedBy(propagationDuration * Constants.JULIAN_DAY);
out.format(Locale.US, "# file generated on %s%n", new AbsoluteDate(new Date(), utc).toString(utc));
out.format(Locale.US, "# propagating %d sprites from %s to %s%n", spritesPropagators.size(), start.toString(utc), end.toString(utc));
out.format(Locale.US, "# column 1: date (UTC)%n");
out.format(Locale.US, "# column 2: date offset since start (seconds)%n");
out.format(Locale.US, "# column 3: KickSat geodetic latitude (degrees)%n");
out.format(Locale.US, "# column 4: KickSat geodetic longitude (degrees)%n");
out.format(Locale.US, "# column 5: KickSat geodetic altitude (meters)%n");
out.format(Locale.US, "# column 3i+3: sprite i geodetic latitude (degrees)%n");
out.format(Locale.US, "# column 3i+4: sprite i geodetic longitude (degrees)%n");
out.format(Locale.US, "# column 3i+5: sprite i geodetic altitude (meters)%n");
// in order to speed up computation, we let the numerical propagator choose its
// steps, and create ephemerides, then we will use the ephemerides with fixed
// steps for output
List<Propagator> ephemerides = new ArrayList<Propagator>(spritesPropagators.size());
for (final Propagator spritePropagator : spritesPropagators) {
spritePropagator.setEphemerisMode();
spritePropagator.propagate(end);
ephemerides.add(spritePropagator.getGeneratedEphemeris());
}
for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(step)) {
out.format(Locale.US, "%s %9.1f", date.toString(utc), date.durationFrom(start));
final GeodeticPoint kickSatGP = geodeticPosition(kickSatPropagator, date);
out.format(Locale.US, " %8.3f %8.3f %8.1f", FastMath.toDegrees(kickSatGP.getLatitude()), FastMath.toDegrees(kickSatGP.getLongitude()), kickSatGP.getAltitude());
for (final Propagator ephemeride : ephemerides) {
final GeodeticPoint spriteGP = geodeticPosition(ephemeride, date);
out.format(Locale.US, " %8.3f %8.3f %8.1f", FastMath.toDegrees(spriteGP.getLatitude()), FastMath.toDegrees(spriteGP.getLongitude()), spriteGP.getAltitude());
}
out.println();
}
}
use of org.orekit.bodies.GeodeticPoint in project Orekit by CS-SI.
the class LofOffsetPointing method losIntersectionWithBody.
/**
* Compute line of sight intersection with body.
* @param scToBody transform from spacecraft frame to body frame
* @return intersection point in body frame (only the position is set!)
* @exception OrekitException if line of sight does not intersect body
*/
private TimeStampedPVCoordinates losIntersectionWithBody(final Transform scToBody) throws OrekitException {
// compute satellite pointing axis and position/velocity in body frame
final Vector3D pointingBodyFrame = scToBody.transformVector(satPointingVector);
final Vector3D pBodyFrame = scToBody.transformPosition(Vector3D.ZERO);
// Line from satellite following pointing direction
// we use arbitrarily the Earth radius as a scaling factor, it could be anything else
final Line pointingLine = new Line(pBodyFrame, pBodyFrame.add(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, pointingBodyFrame), 1.0e-10);
// Intersection with body shape
final GeodeticPoint gpIntersection = shape.getIntersectionPoint(pointingLine, pBodyFrame, shape.getBodyFrame(), scToBody.getDate());
final Vector3D pIntersection = (gpIntersection == null) ? null : shape.transform(gpIntersection);
// Check there is an intersection and it is not in the reverse pointing direction
if ((pIntersection == null) || (Vector3D.dotProduct(pIntersection.subtract(pBodyFrame), pointingBodyFrame) < 0)) {
throw new OrekitException(OrekitMessages.ATTITUDE_POINTING_LAW_DOES_NOT_POINT_TO_GROUND);
}
return new TimeStampedPVCoordinates(scToBody.getDate(), pIntersection, Vector3D.ZERO, Vector3D.ZERO);
}
Aggregations