Like the title says, I am trying to use the TLE of the ISS to get its LLA at a specific date.
I am very new to astrodynamics and orekit. I am trying to follow the examples and tutorials in the documentation, but the results I am getting are completely off. If I had to guess, I’d guess the problem is coming from an incorrect setup in my TLELocation constructor or the method getLocation(…).
Thank you for any help or suggestions.
TLELocation.java
public class TLELocation {
private TLE input;
private Frame inertialFrame;
private Frame earthFrame;
private TLEPropagator testPropagator;
private BodyShape earth;
public TLELocation(String line1, String line2)
{
if(line1.length() < 69 || line2.length() < 69)
throw new InvalidTLEException("Invalid TLE");
input = new TLE(line1, line2, DateTimeUtil.getUTC());
//The TEME frame is used for the SGP4 model in TLE propagation.
inertialFrame = FramesFactory.getEME2000();
//Get an unspecified International Terrestrial Reference Frame.
earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
//Modeling of a one-axis ellipsoid.
//One-axis ellipsoids is a good approximate model for most planet-size and larger natural bodies.
earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
Constants.WGS84_EARTH_FLATTENING,
earthFrame);
testPropagator = TLEPropagator.selectExtrapolator(input);
}
public HVector3D getLocation(AbsoluteDate date)
{
PVCoordinates inertial = testPropagator.getPVCoordinates(date);
PVCoordinates fixedEarth = inertialFrame.getTransformTo(earthFrame, date).transformPVCoordinates(inertial);
return new HVector3D(fixedEarth.getPosition());
}
public Vector3D geodeticLocation(AbsoluteDate date)
{
GeodeticPoint point = earth.transform(getLocation(date).getVector3D(), earthFrame, date);
Vector3D vector3D = new Vector3D(FastMath.toDegrees(point.getLatitude()),
FastMath.toDegrees(point.getLongitude()),
point.getAltitude());
return vector3D;
}
}
TLELocationTest.java
public class TLELocationTest {
private TLELocation tleLocation;
private TLE tle;
private String dateStr;
private AbsoluteDate absoluteDate;
@BeforeAll
public void setUp() throws IOException {
File orekitData = new File("orekit_data");
DataProvidersManager manager = DataContext.getDefault().getDataProvidersManager();
manager.addProvider(new DirectoryCrawler(orekitData));
//==========================================================//
tle = getIssTleFromCelesTrackAPI();
tleLocation = new TLELocation(tle.getLine1(), tle.getLine2());
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
Long currentTime = new Date().getTime();
dateStr = formatter.format(new Date(currentTime));
absoluteDate = DateTimeUtil.parseDate(dateStr);
}
@Test //Latitude
public void testGetGeodeticLocationGetLatitude() throws IOException {
Vector3D vector3D = tleLocation.geodeticLocation(absoluteDate);
Location actualLocation = new Location(vector3D.getX(), vector3D.getY());
Location expectedLocation = getISSLocation();
Assertions.assertEquals(expectedLocation.getLatitude(), actualLocation.getLatitude(), 1.0);
}
@Test //Longitude
public void testGetGeodeticLocationGetLongitude() throws IOException {
Vector3D vector3D = tleLocation.geodeticLocation(absoluteDate);
Location actualLocation = new Location(vector3D.getX(), vector3D.getY());
Location expectedLocation = getISSLocation();
Assertions.assertEquals(expectedLocation.getLongitude(), actualLocation.getLongitude(), 1.0);
}
//private methods
.
.
.
}
HVector.java
public class HVector3D {
private final double a, b, c, d;
public HVector3D(Vector3D v)
{
this.a = v.getX();
this.b = v.getY();
this.c = v.getZ();
this.d = 1;
}
public HVector3D(Vector3D v, double d)
{
this.a = v.getX();
this.b = v.getY();
this.c = v.getZ();
this.d = d;
}
public HVector3D(double a, double b, double c, double d)
{
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
public HVector3D()
{
this.a = 0.0;
this.b = 0.0;
this.c = 0.0;
this.d = 1.0;
}
public double dotProduct(final HVector3D v)
{
return MathArrays.linearCombination(a, v.a, b, v.b, c, v.c, d, v.d);
}
public double getA()
{
return this.a;
}
public double getB()
{
return this.b;
}
public double getC()
{
return this.c;
}
public double getD()
{
return this.d;
}
public HVector3D toHessianNormal()
{
Vector3D temp = new Vector3D(this.a, this.b, this.c);
double distance = this.d / temp.getNorm();
return new HVector3D(temp.normalize(), distance);
}
@Override
public String toString()
{
return this.a + " " + this.b + " " + this.c + " " + this.d;
}
public Vector3D getVector3D()
{
return new Vector3D(a/d, b/d, c/d);
}
public double distance(HVector3D v)
{
final double dx = FastMath.abs(v.a - a);
final double dy = FastMath.abs(v.b - b);
final double dz = FastMath.abs(v.c - c);
return dx + dy + dz;
}
}