use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class FieldOfViewDetectorTest method testStopOnExit.
/**
* check the default behavior to stop propagation on FoV exit.
*/
@Test
public void testStopOnExit() throws OrekitException {
// setup
double pi = FastMath.PI;
// arbitrary date
AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
AbsoluteDate endDate = date.shiftedBy(Constants.JULIAN_DAY);
Frame eci = FramesFactory.getGCRF();
Frame ecef = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, ecef);
GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(39), FastMath.toRadians(77), 0);
TopocentricFrame topo = new TopocentricFrame(earth, gp, "topo");
// iss like orbit
KeplerianOrbit orbit = new KeplerianOrbit(6378137 + 400e3, 0, FastMath.toRadians(51.65), 0, 0, 0, PositionAngle.TRUE, eci, date, Constants.EGM96_EARTH_MU);
AttitudeProvider attitude = new NadirPointing(eci, earth);
// action
FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, pi / 3, 16, 0);
FieldOfViewDetector fovDetector = new FieldOfViewDetector(topo, fov).withMaxCheck(5.0);
EventsLogger logger = new EventsLogger();
Propagator prop = new KeplerianPropagator(orbit, attitude);
prop.addEventDetector(logger.monitorDetector(fovDetector));
prop.propagate(endDate);
List<LoggedEvent> actual = logger.getLoggedEvents();
// verify
// check we have an entry and an exit event.
Assert.assertEquals(2, actual.size());
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class GeographicZoneDetectorTest method testFrance.
@Test
public void testFrance() throws OrekitException {
final BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
GeographicZoneDetector d = new GeographicZoneDetector(20.0, 1.e-3, earth, buildFrance(), FastMath.toRadians(0.5)).withHandler(new ContinueOnEvent<GeographicZoneDetector>());
Assert.assertEquals(20.0, d.getMaxCheckInterval(), 1.0e-15);
Assert.assertEquals(1.0e-3, d.getThreshold(), 1.0e-15);
Assert.assertEquals(0.5, FastMath.toDegrees(d.getMargin()), 1.0e-15);
Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, d.getMaxIterationCount());
final TimeScale utc = TimeScalesFactory.getUTC();
final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, Constants.EIGEN5C_EARTH_MU);
Propagator propagator = new EcksteinHechlerPropagator(orbit, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
EventsLogger logger = new EventsLogger();
propagator.addEventDetector(logger.monitorDetector(d));
propagator.propagate(date.shiftedBy(10 * Constants.JULIAN_DAY));
Assert.assertEquals(26, logger.getLoggedEvents().size());
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class GroundFieldOfViewDetectorTest method testCaseSimilarToElevationDetector.
/**
* Check FoV detector is similar to {@link ElevationDetector} when using
* zenith pointing.
*
* @throws OrekitException on error.
*/
@Test
public void testCaseSimilarToElevationDetector() throws OrekitException {
// setup
double pi = FastMath.PI;
// arbitrary date
AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
AbsoluteDate endDate = date.shiftedBy(Constants.JULIAN_DAY);
Frame eci = FramesFactory.getGCRF();
Frame ecef = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, ecef);
GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(39), FastMath.toRadians(77), 0);
TopocentricFrame topo = new TopocentricFrame(earth, gp, "topo");
// iss like orbit
KeplerianOrbit orbit = new KeplerianOrbit(6378137 + 400e3, 0, FastMath.toRadians(51.65), 0, 0, 0, PositionAngle.TRUE, eci, date, Constants.EGM96_EARTH_MU);
Propagator prop = new KeplerianPropagator(orbit);
// compute expected result
ElevationDetector elevationDetector = new ElevationDetector(topo).withConstantElevation(pi / 6).withMaxCheck(5.0);
EventsLogger logger = new EventsLogger();
prop.addEventDetector(logger.monitorDetector(elevationDetector));
prop.propagate(endDate);
List<LoggedEvent> expected = logger.getLoggedEvents();
// action
// construct similar FoV based detector
// half width of 60 deg pointed along +Z in antenna frame
// not a perfect small circle b/c FoV makes a polygon with great circles
FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, pi / 3, 16, 0);
// simple case for fixed pointing to be similar to elevation detector.
// could define new frame with varying rotation for slewing antenna.
GroundFieldOfViewDetector fovDetector = new GroundFieldOfViewDetector(topo, fov).withMaxCheck(5.0);
Assert.assertSame(topo, fovDetector.getFrame());
Assert.assertSame(fov, fovDetector.getFieldOfView());
logger = new EventsLogger();
prop = new KeplerianPropagator(orbit);
prop.addEventDetector(logger.monitorDetector(fovDetector));
prop.propagate(endDate);
List<LoggedEvent> actual = logger.getLoggedEvents();
// verify
Assert.assertEquals(2, expected.size());
Assert.assertEquals(2, actual.size());
for (int i = 0; i < 2; i++) {
AbsoluteDate expectedDate = expected.get(i).getState().getDate();
AbsoluteDate actualDate = actual.get(i).getState().getDate();
// same event times to within 1s.
Assert.assertEquals(expectedDate.durationFrom(actualDate), 0.0, 1.0);
}
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class GroundStation method getOffsetToInertial.
/**
* Get the transform between offset frame and inertial frame with derivatives.
* <p>
* As the East and North vector are not well defined at pole, the derivatives
* of these two vectors diverge to infinity as we get closer to the pole.
* So this method should not be used for stations less than 0.0001 degree from
* either poles.
* </p>
* @param inertial inertial frame to transform to
* @param date date of the transform
* @param factory factory for the derivatives
* @param indices indices of the estimated parameters in derivatives computations
* @return offset frame defining vectors with derivatives
* @exception OrekitException if some frame transforms cannot be computed
* @since 9.0
*/
public FieldTransform<DerivativeStructure> getOffsetToInertial(final Frame inertial, final FieldAbsoluteDate<DerivativeStructure> date, final DSFactory factory, final Map<String, Integer> indices) throws OrekitException {
final Field<DerivativeStructure> field = date.getField();
final FieldVector3D<DerivativeStructure> zero = FieldVector3D.getZero(field);
final FieldVector3D<DerivativeStructure> plusI = FieldVector3D.getPlusI(field);
final FieldVector3D<DerivativeStructure> plusK = FieldVector3D.getPlusK(field);
// take Earth offsets into account
final FieldTransform<DerivativeStructure> intermediateToBody = estimatedEarthFrameProvider.getTransform(date, factory, indices).getInverse();
// take station offset into account
final DerivativeStructure x = parametricModel(factory, eastOffsetDriver, indices);
final DerivativeStructure y = parametricModel(factory, northOffsetDriver, indices);
final DerivativeStructure z = parametricModel(factory, zenithOffsetDriver, indices);
final BodyShape baseShape = baseFrame.getParentShape();
final Transform baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), (AbsoluteDate) null);
FieldVector3D<DerivativeStructure> origin = baseToBody.transformPosition(new FieldVector3D<>(x, y, z));
origin = origin.add(computeDisplacement(date.toAbsoluteDate(), origin.toVector3D()));
final FieldGeodeticPoint<DerivativeStructure> originGP = baseShape.transform(origin, baseShape.getBodyFrame(), date);
final FieldTransform<DerivativeStructure> offsetToIntermediate = new FieldTransform<>(date, new FieldTransform<>(date, new FieldRotation<>(plusI, plusK, originGP.getEast(), originGP.getZenith()), zero), new FieldTransform<>(date, origin));
// combine all transforms together
final FieldTransform<DerivativeStructure> bodyToInert = baseFrame.getParent().getTransformTo(inertial, date);
return new FieldTransform<>(date, offsetToIntermediate, new FieldTransform<>(date, intermediateToBody, bodyToInert));
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class TopocentricFrameTest method testVisibilityCircle.
@Test
public void testVisibilityCircle() throws OrekitException, IOException {
// a few random from International Laser Ranging Service
final BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
final TopocentricFrame[] ilrs = { new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(52.3800), FastMath.toRadians(3.0649), 133.745), "Potsdam"), new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(36.46273), FastMath.toRadians(-6.20619), 64.0), "San Fernando"), new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(35.5331), FastMath.toRadians(24.0705), 157.0), "Chania") };
PolynomialFunction distanceModel = new PolynomialFunction(new double[] { 7.0892e+05, 3.1913, -8.2181e-07, 1.4033e-13 });
for (TopocentricFrame station : ilrs) {
for (double altitude = 500000; altitude < 2000000; altitude += 100000) {
for (double azimuth = 0; azimuth < 2 * FastMath.PI; azimuth += 0.05) {
GeodeticPoint p = station.computeLimitVisibilityPoint(Constants.WGS84_EARTH_EQUATORIAL_RADIUS + altitude, azimuth, FastMath.toRadians(5.0));
double d = station.getRange(earth.transform(p), earth.getBodyFrame(), AbsoluteDate.J2000_EPOCH);
Assert.assertEquals(distanceModel.value(altitude), d, 40000.0);
}
}
}
}
Aggregations