[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orekit Users] My EventDetector class can't correct detecting event?
- To: orekit-users@orekit.org
- Subject: Re: [Orekit Users] My EventDetector class can't correct detecting event?
- From: beowulf zhang <beowulf.zhang@gmail.com>
- Date: Tue, 31 May 2011 20:58:11 +0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=ccglEHcZU8pioBKAdtBKhynN9bz1L9879Nazr2bGkXw=; b=IFFXDMrAVpZdtfoj+hBYYJ+H4X0eTineUhYjGSpAgY2FaESi1tSrUxludvbzBfSCfg zS6yA9eVGVnw9NAg4aFklYiy0rY27TBHtBw3CmWAv9dSOsZfuvN/IS3PU70oqir+NFvz UAGNGavCSQaODPVyBEyeP/GhQ2X4AQwpQvjyY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=oMrKhHXFKKa8pYH8UdxRNIo6TZVCnEHXRQq47/EE3qoEKTfhrenjVbWLckLoMdZ8kq GqmqePnyuu7d/cKFDGcukTtJs4wVzsb/Jvle+bgcWEc6g3YP5myd0udUBef7acVC/LJF WLnDzTqAq0Zeq0nuye6eWmVzLgpYATC1y0Y+Y=
- In-reply-to: <20110530203907.16372gd8s7dqvwi3@messagerie.si.c-s.fr>
- References: <BANLkTinP1f3iF2ucUVSxivqNYxq5imz_4Q@mail.gmail.com> <20110530203907.16372gd8s7dqvwi3@messagerie.si.c-s.fr>
locOrbFrm object is referenced to another object.
My main function code is:
// configure Orekit
Autoconfiguration.configureOrekit();
// Initial orbit parameters
double a = 7396159; // semi major axis in meters
double e = 0.001; // eccentricity
double i = Math.toRadians(7); // inclination
double omega = Math.toRadians(180); // perigee argument
double raan = Math.toRadians(261); // right ascension of
ascending node
double lM = 0; // mean anomaly
// Inertial frame
Frame inertialFrame = FramesFactory.getEME2000();
// Initial date in UTC time scale
TimeScale utc = TimeScalesFactory.getUTC();
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01,
23, 30, 00.000, utc);
// gravitation coefficient
double mu = 3.986004415e+14;
//////////////////////////////////////////////////////////////////////////////////
// Orbit construction as Keplerian
Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM,
KeplerianOrbit.MEAN_ANOMALY,
inertialFrame,
initialDate, mu);
// Simple extrapolation with Keplerian motion
//KeplerianPropagator kepler = new
KeplerianPropagator(initialOrbit);
double stepSize = 9; // the step is ten seconds
FirstOrderIntegrator integrator = new
ClassicalRungeKuttaIntegrator(stepSize);
NumericalPropagator prop = new NumericalPropagator(integrator);
SpacecraftState initialState = new SpacecraftState(initialOrbit);
prop.setInitialState(initialState);
// Set the propagator to slave mode (could be omitted as
it is the default mode)
prop.setSlaveMode();
// 生成目标当地轨道系
LocalOrbitalFrame lof = new
LocalOrbitalFrame(inertialFrame, LOFType.QSW, prop, "LOF");
//////////////////////////////////////////////////////////////////////////////////
// 根据相对状态构造追踪星
PVCoordinates relSt = new PVCoordinates(new Vector3D(0.0,0.0,0.0),
new Vector3D(0.0,1.0,0.0));
PVCoordinates initPV = lof.getTransformTo(inertialFrame,
initialDate).transformPVCoordinates(relSt);
// Simple extrapolation with Keplerian motion
//KeplerianPropagator kepler = new
KeplerianPropagator(initialOrbit);
FirstOrderIntegrator integratorS = new
ClassicalRungeKuttaIntegrator(stepSize);
NumericalPropagator propS = new NumericalPropagator(integratorS);
SpacecraftState initialStateS = new SpacecraftState(new
CartesianOrbit(initPV,
inertialFrame, initialDate, mu));
propS.setInitialState(initialStateS);
// Set the propagator to slave mode (could be omitted as
it is the default mode)
propS.setSlaveMode();
propS.addEventDetector(new CWAxisYDetector(initialOrbit,
lof, initialDate));
//////////////////////////////////////////////////////////////////////////////////
// Overall duration in seconds for extrapolation
double duration = initialOrbit.getKeplerianPeriod() * 2.0;
PrintWriter relFile = null;
try {
relFile = new PrintWriter("relst.txt");
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
// Stop date
final AbsoluteDate finalDate = new
AbsoluteDate(initialDate, duration, utc);
// Extrapolation loop
boolean first = true;
AbsoluteDate extrapDate = initialDate;
while (extrapDate.compareTo(finalDate) <= 0) {
SpacecraftState targ = prop.propagate(extrapDate);
SpacecraftState inter = propS.propagate(extrapDate);
PVCoordinates relst = inter.getPVCoordinates(lof);
double tm = extrapDate.durationFrom(initialDate);
relFile.printf("%f %f %f %f\n",
tm, relst.getPosition().getX(),
relst.getPosition().getY(), relst.getPosition().getZ());
extrapDate = new AbsoluteDate(extrapDate, stepSize, utc);
}
relFile.close();
System.out.println("The End");
2011/5/31, MAISONOBE Luc <luc.maisonobe@c-s.fr>:
> beowulf zhang <beowulf.zhang@gmail.com> a écrit :
>
>> I write a class CWAxisYDetector derived from AbstractDetector, the code
>> is:
>>
>> public class CWAxisYDetector extends AbstractDetector {
>>
>> private LocalOrbitalFrame locOrbFrm;
>>
>> private AbsoluteDate initDate;
>>
>> protected CWAxisYDetector(Orbit targOrb, LocalOrbitalFrame lof,
>> AbsoluteDate iDate) {
>> super(targOrb.getKeplerianPeriod() / 3, 1.0e-13 *
>> targOrb.getKeplerianPeriod());
>> this.locOrbFrm = lof;
>> this.initDate = iDate;
>> }
>>
>> public int eventOccurred(SpacecraftState s, boolean increasing)
>> throws OrekitException {
>> System.out.println(s.getDate().durationFrom(initDate));
>> return CONTINUE;
>> }
>>
>> public double g(SpacecraftState s) throws OrekitException {
>> return s.getPVCoordinates(locOrbFrm).getPosition().getX();
>> }
>
> If the local orbital frame here is linked to the same spacecraft whose
> orbit is propagated, then
> s.getPVCoordinates(locOrbFrm).getPosition().getX() should always be 0
> (as well as Y and Z since the spacecraft defines the origin of this
> frame).
> So the function is essentially an observation of numerical errors in
> interpolation polynomials, it is not a function that clearly crosses
> the zero axis at one precise time.
>
> Are you sure about the frame ? Shouldn't it be related to another
> spacecraft (for relative motion observation for example) ?
>
> Luc
>
>>
>> }
>>
>> but this class can't correct detecting event, and in some integrate
>> step getinig error information:
>>
>> Exception in thread "main"
>> org.apache.commons.math.MathRuntimeException$4: function values at
>> endpoints do not have different signs. Endpoints: [0.539, 0.539],
>> Values: [0, 0]
>> at
>> org.apache.commons.math.MathRuntimeException.createIllegalArgumentException(MathRuntimeException.java:305)
>> at
>> org.apache.commons.math.analysis.solvers.BrentSolver.solve(BrentSolver.java:219)
>> at
>> org.apache.commons.math.ode.events.EventState.evaluateStep(EventState.java:229)
>> at
>> org.apache.commons.math.ode.events.CombinedEventsManager.evaluateStep(CombinedEventsManager.java:152)
>> at
>> org.apache.commons.math.ode.nonstiff.RungeKuttaIntegrator.integrate(RungeKuttaIntegrator.java:172)
>> at
>> org.orekit.propagation.numerical.NumericalPropagator.propagate(NumericalPropagator.java:419)
>> at fr.cs.examples.propagation.SlaveMode.main(SlaveMode.java:136)
>>
>> why?
>>
>>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
>