use of org.orekit.orbits.CartesianOrbit in project SpriteOrbits by ProjectPersephone.
the class SpritePropOrig method main.
/**
* @param args
*/
public static void main(String[] args) {
PrintStream out = null;
try {
// set up orekit data
// for this to work, the orekit-data.zip file avaiable at the following URL
// must be put in the current working directory
// URL: https://www.orekit.org/forge/projects/orekit/files
File userDir = new File(System.getProperty("user.dir"));
File orekitZip = new File(userDir, "orekit-data.zip");
DataProvidersManager.getInstance().addProvider(new ZipJarCrawler(orekitZip));
// reference models
// this is the frame labeled J2K in the NASA page
final Frame eme2000 = FramesFactory.getEME2000();
final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
final TimeScale utc = TimeScalesFactory.getUTC();
// central attraction coefficient MU
final double mu = Constants.EIGEN5C_EARTH_MU;
// set up some data, ideally, this should be provided as input to the program
// ISS orbit is from http://spaceflight.nasa.gov/realdata/sightings/SSapplications/Post/JavaSSOP/orbit/ISS/SVPOST.html
//
// Coasting Arc #15 (Orbit 3386)
// ---------------------------------------
//
// Vector Time (GMT): 2014/055/16:27:06.921
// Vector Time (MET): N/A
// Weight (LBS) : 911651.1
//
// ...
//
// J2K Cartesian
// --------------------------------
// X = 2998767.75
// Y = -6097451.56 meter
// ... Z = -141448.92
// XDOT = 4323.077242
// YDOT = 1994.291706 meter/sec
// ZDOT = 6000.774574
// we start small, we can increase this later
final int numberOfSprites = 12;
// (m/s)
final double relativeReleaseVelocity = 1.0;
final AbsoluteDate releaseDate = new // year, month, day
AbsoluteDate(// year, month, day
2014, // year, month, day
3, // year, month, day
1, // hours, minutes, seconds
12, // hours, minutes, seconds
0, // hours, minutes, seconds
0.0, utc);
final CartesianOrbit kickSatOrbit = new CartesianOrbit(new // position (m)
PVCoordinates(// position (m)
new Vector3D(2998767.75, -6097451.56, -141448.92), // velocity (m/s)
new Vector3D(4323.077242, 1994.291706, 6000.774574)), eme2000, new // year, day in year as NASA page above
AbsoluteDate(// year, day in year as NASA page above
new DateComponents(2014, 55), // hour in day
new TimeComponents(16, 27, 6.921), utc), mu);
// kg
final double kickSatMass = 10.0;
// m^2
final double kickSatCrossSection = 0.03;
// no units
final double kickSatDragCoeff = 2.2;
// kg
final double spriteMass = 0.01;
// m^2
final double spriteCrossSection = 2.5e-3;
// no units
final double spriteDragCoeff = 2.2;
SpritePropOrig spriteProp = new SpritePropOrig(numberOfSprites, kickSatOrbit, kickSatMass, kickSatCrossSection, kickSatDragCoeff, spriteMass, spriteCrossSection, spriteDragCoeff, relativeReleaseVelocity, releaseDate, itrf);
// days after release
final double propagationDuration = 0.2;
// seconds
final double step = 60.0;
out = new PrintStream(new File(userDir, "sprites-prop.txt"));
spriteProp.run(out, propagationDuration, step, utc);
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (OrekitException e) {
e.printStackTrace();
} finally {
if (out != null) {
out.close();
}
}
}
use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.
the class KalmanOrbitDeterminationTest method runReference.
/**
* Use the physical models in the input file
* Incorporate the initial reference values
* And run the propagation until the last measurement to get the reference orbit at the same date
* as the Kalman filter
* @param input Input configuration file
* @param orbitType Orbit type to use (calculation and display)
* @param refPosition Initial reference position
* @param refVelocity Initial reference velocity
* @param refPropagationParameters Reference propagation parameters
* @param kalmanFinalDate The final date of the Kalman filter
* @return The reference orbit at the same date as the Kalman filter
* @throws IOException Input file cannot be opened
* @throws IllegalArgumentException Issue in key/value reading of input file
* @throws OrekitException An Orekit exception... should be explicit
* @throws ParseException Parsing of the input file or measurement file failed
*/
private Orbit runReference(final File input, final OrbitType orbitType, final Vector3D refPosition, final Vector3D refVelocity, final ParameterDriversList refPropagationParameters, final AbsoluteDate kalmanFinalDate) throws IOException, IllegalArgumentException, OrekitException, ParseException {
// Read input parameters
KeyValueFileParser<ParameterKey> parser = new KeyValueFileParser<ParameterKey>(ParameterKey.class);
parser.parseInput(input.getAbsolutePath(), new FileInputStream(input));
// Gravity field
GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("eigen-5c.gfc", true));
final NormalizedSphericalHarmonicsProvider gravityField = createGravityField(parser);
// Orbit initial guess
Orbit initialRefOrbit = new CartesianOrbit(new PVCoordinates(refPosition, refVelocity), parser.getInertialFrame(ParameterKey.INERTIAL_FRAME), parser.getDate(ParameterKey.ORBIT_DATE, TimeScalesFactory.getUTC()), gravityField.getMu());
// Convert to desired orbit type
initialRefOrbit = orbitType.convertType(initialRefOrbit);
// IERS conventions
final IERSConventions conventions;
if (!parser.containsKey(ParameterKey.IERS_CONVENTIONS)) {
conventions = IERSConventions.IERS_2010;
} else {
conventions = IERSConventions.valueOf("IERS_" + parser.getInt(ParameterKey.IERS_CONVENTIONS));
}
// Central body
final OneAxisEllipsoid body = createBody(parser);
// Propagator builder
final NumericalPropagatorBuilder propagatorBuilder = createPropagatorBuilder(parser, conventions, gravityField, body, initialRefOrbit);
// Force the selected propagation parameters to their reference values
if (refPropagationParameters != null) {
for (DelegatingDriver refDriver : refPropagationParameters.getDrivers()) {
for (DelegatingDriver driver : propagatorBuilder.getPropagationParametersDrivers().getDrivers()) {
if (driver.getName().equals(refDriver.getName())) {
driver.setValue(refDriver.getValue());
}
}
}
}
// Build the reference propagator
final NumericalPropagator propagator = propagatorBuilder.buildPropagator(propagatorBuilder.getSelectedNormalizedParameters());
// Propagate until last date and return the orbit
return propagator.propagate(kalmanFinalDate).getOrbit();
}
use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.
the class OEMParserTest method testParseOEM1.
@Test
public void testParseOEM1() throws OrekitException, IOException {
//
final String ex = "/ccsds/OEMExample.txt";
final InputStream inEntry = getClass().getResourceAsStream(ex);
final OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM());
final OEMFile file = parser.parse(inEntry, "OEMExample.txt");
Assert.assertEquals(CcsdsTimeScale.UTC, file.getEphemeridesBlocks().get(0).getMetaData().getTimeSystem());
Assert.assertEquals("MARS GLOBAL SURVEYOR", file.getEphemeridesBlocks().get(0).getMetaData().getObjectName());
Assert.assertEquals("1996-062A", file.getEphemeridesBlocks().get(0).getMetaData().getObjectID());
Assert.assertEquals("MARS BARYCENTER", file.getEphemeridesBlocks().get(0).getMetaData().getCenterName());
Assert.assertEquals(1996, file.getEphemeridesBlocks().get(0).getMetaData().getLaunchYear());
Assert.assertEquals(62, file.getEphemeridesBlocks().get(0).getMetaData().getLaunchNumber());
Assert.assertEquals("A", file.getEphemeridesBlocks().get(0).getMetaData().getLaunchPiece());
Assert.assertFalse(file.getEphemeridesBlocks().get(0).getMetaData().getHasCreatableBody());
Assert.assertNull(file.getEphemeridesBlocks().get(0).getMetaData().getCenterBody());
Assert.assertEquals(new AbsoluteDate(1996, 12, 18, 12, 00, 0.331, TimeScalesFactory.getUTC()), file.getEphemeridesBlocks().get(0).getStartTime());
Assert.assertEquals(new AbsoluteDate(1996, 12, 28, 21, 28, 0.331, TimeScalesFactory.getUTC()), file.getEphemeridesBlocks().get(0).getStopTime());
Assert.assertEquals(new AbsoluteDate(1996, 12, 18, 12, 10, 0.331, TimeScalesFactory.getUTC()), file.getEphemeridesBlocks().get(0).getUseableStartTime());
Assert.assertEquals(new AbsoluteDate(1996, 12, 28, 21, 23, 0.331, TimeScalesFactory.getUTC()), file.getEphemeridesBlocks().get(0).getUseableStopTime());
Assert.assertEquals("HERMITE", file.getEphemeridesBlocks().get(0).getInterpolationMethod());
Assert.assertEquals(7, file.getEphemeridesBlocks().get(0).getInterpolationDegree());
ArrayList<String> ephemeridesDataLinesComment = new ArrayList<String>();
ephemeridesDataLinesComment.add("This file was produced by M.R. Somebody, MSOO NAV/JPL, 1996NOV 04. It is");
ephemeridesDataLinesComment.add("to be used for DSN scheduling purposes only.");
Assert.assertEquals(ephemeridesDataLinesComment, file.getEphemeridesBlocks().get(0).getEphemeridesDataLinesComment());
CartesianOrbit orbit = new CartesianOrbit(new PVCoordinates(new Vector3D(2789.619 * 1000, -280.045 * 1000, -1746.755 * 1000), new Vector3D(4.73372 * 1000, -2.49586 * 1000, -1.04195 * 1000)), FramesFactory.getEME2000(), new AbsoluteDate("1996-12-18T12:00:00.331", TimeScalesFactory.getUTC()), CelestialBodyFactory.getEarth().getGM());
Assert.assertArrayEquals(orbit.getPVCoordinates().getPosition().toArray(), file.getEphemeridesBlocks().get(0).getEphemeridesDataLines().get(0).getPosition().toArray(), 1e-10);
Assert.assertArrayEquals(orbit.getPVCoordinates().getVelocity().toArray(), file.getEphemeridesBlocks().get(0).getEphemeridesDataLines().get(0).getVelocity().toArray(), 1e-10);
Assert.assertArrayEquals((new Vector3D(1, 1, 1)).toArray(), file.getEphemeridesBlocks().get(1).getEphemeridesDataLines().get(0).getAcceleration().toArray(), 1e-10);
Assert.assertEquals(Vector3D.ZERO, file.getEphemeridesBlocks().get(1).getEphemeridesDataLines().get(1).getAcceleration());
final Array2DRowRealMatrix covMatrix = new Array2DRowRealMatrix(6, 6);
final double[] column1 = { 3.331349476038534e-04, 4.618927349220216e-04, -3.070007847730449e-04, -3.349365033922630e-07, -2.211832501084875e-07, -3.041346050686871e-07 };
final double[] column2 = { 4.618927349220216e-04, 6.782421679971363e-04, -4.221234189514228e-04, -4.686084221046758e-07, -2.864186892102733e-07, -4.989496988610662e-07 };
final double[] column3 = { -3.070007847730449e-04, -4.221234189514228e-04, 3.231931992380369e-04, 2.484949578400095e-07, 1.798098699846038e-07, 3.540310904497689e-07 };
final double[] column4 = { -3.349365033922630e-07, -4.686084221046758e-07, 2.484949578400095e-07, 4.296022805587290e-10, 2.608899201686016e-10, 1.869263192954590e-10 };
final double[] column5 = { -2.211832501084875e-07, -2.864186892102733e-07, 1.798098699846038e-07, 2.608899201686016e-10, 1.767514756338532e-10, 1.008862586240695e-10 };
final double[] column6 = { -3.041346050686871e-07, -4.989496988610662e-07, 3.540310904497689e-07, 1.869263192954590e-10, 1.008862586240695e-10, 6.224444338635500e-10 };
covMatrix.setColumn(0, column1);
covMatrix.setColumn(1, column2);
covMatrix.setColumn(2, column3);
covMatrix.setColumn(3, column4);
covMatrix.setColumn(4, column5);
covMatrix.setColumn(5, column6);
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
Assert.assertEquals(covMatrix.getEntry(i, j), file.getEphemeridesBlocks().get(2).getCovarianceMatrices().get(0).getMatrix().getEntry(i, j), 1e-10);
}
}
Assert.assertEquals(new AbsoluteDate("1996-12-28T21:29:07.267", TimeScalesFactory.getUTC()), file.getEphemeridesBlocks().get(2).getCovarianceMatrices().get(0).getEpoch());
Assert.assertEquals(LOFType.QSW, file.getEphemeridesBlocks().get(2).getCovarianceMatrices().get(0).getLofType());
Assert.assertNull(file.getEphemeridesBlocks().get(2).getCovarianceMatrices().get(0).getFrame());
Assert.assertEquals(FramesFactory.getEME2000(), file.getEphemeridesBlocks().get(2).getCovarianceMatrices().get(1).getFrame());
Assert.assertNull(file.getEphemeridesBlocks().get(2).getCovarianceMatrices().get(1).getLofType());
}
use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method testParameterDerivative.
@Test
public void testParameterDerivative() throws OrekitException {
// pos-vel (from a ZOOM ephemeris reference)
final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06, -1.32931592294715829e+04);
final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03, -1.14097953925384523e+01);
final SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel), FramesFactory.getGCRF(), new AbsoluteDate(2005, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()), Constants.EIGEN5C_EARTH_MU));
final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(state.getDate().shiftedBy(-10), 100.0, 20.0, 350.0, Vector3D.PLUS_I, "along-X-");
maneuver.init(state, state.getDate().shiftedBy(3600.0));
checkParameterDerivative(state, maneuver, "along-X-thrust", 1.0e-3, 3.0e-14);
checkParameterDerivative(state, maneuver, "along-X-flow rate", 1.0e-3, 1.0e-15);
}
use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.
the class ImpulseManeuverTest method testAdditionalStateNumerical.
@Test
public void testAdditionalStateNumerical() throws OrekitException {
final double mu = CelestialBodyFactory.getEarth().getGM();
final double initialX = 7100e3;
final double initialY = 0.0;
final double initialZ = 1300e3;
final double initialVx = 0;
final double initialVy = 8000;
final double initialVz = 1000;
final Vector3D position = new Vector3D(initialX, initialY, initialZ);
final Vector3D velocity = new Vector3D(initialVx, initialVy, initialVz);
final AbsoluteDate epoch = new AbsoluteDate(2010, 1, 1, 0, 0, 0, TimeScalesFactory.getUTC());
final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(epoch, position, velocity, Vector3D.ZERO);
final Orbit initialOrbit = new CartesianOrbit(pv, FramesFactory.getEME2000(), mu);
final double totalPropagationTime = 10.0;
final double deltaX = 0.01;
final double deltaY = 0.02;
final double deltaZ = 0.03;
final double isp = 300;
final Vector3D deltaV = new Vector3D(deltaX, deltaY, deltaZ);
final AttitudeProvider attitudeProvider = new LofOffset(initialOrbit.getFrame(), LOFType.VNC);
final Attitude initialAttitude = attitudeProvider.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame());
double[][] tolerances = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
DormandPrince853Integrator integrator = new DormandPrince853Integrator(1.0e-3, 60, tolerances[0], tolerances[1]);
NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setOrbitType(initialOrbit.getType());
PartialDerivativesEquations pde = new PartialDerivativesEquations("derivatives", propagator);
final SpacecraftState initialState = pde.setInitialJacobians(new SpacecraftState(initialOrbit, initialAttitude));
propagator.resetInitialState(initialState);
DateDetector dateDetector = new DateDetector(epoch.shiftedBy(0.5 * totalPropagationTime));
InertialProvider attitudeOverride = new InertialProvider(new Rotation(RotationOrder.XYX, RotationConvention.VECTOR_OPERATOR, 0, 0, 0));
ImpulseManeuver<DateDetector> burnAtEpoch = new ImpulseManeuver<DateDetector>(dateDetector, attitudeOverride, deltaV, isp).withThreshold(1.0e-3);
propagator.addEventDetector(burnAtEpoch);
SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));
Assert.assertEquals(1, finalState.getAdditionalStates().size());
Assert.assertEquals(36, finalState.getAdditionalState("derivatives").length);
double[][] stateTransitionMatrix = new double[6][6];
pde.getMapper().getStateJacobian(finalState, stateTransitionMatrix);
for (int i = 0; i < 6; ++i) {
for (int j = 0; j < 6; ++j) {
double sIJ = stateTransitionMatrix[i][j];
if (j == i) {
// dPi/dPj and dVi/dVj are roughly 1 for small propagation times
Assert.assertEquals(1.0, sIJ, 2.0e-4);
} else if (j == i + 3) {
// dVi/dPi is roughly the propagation time for small propagation times
Assert.assertEquals(totalPropagationTime, sIJ, 4.0e-5 * totalPropagationTime);
} else {
// other derivatives are almost zero for small propagation times
Assert.assertEquals(0, sIJ, 1.0e-4);
}
}
}
}
Aggregations