Azimuth and Elevation between two satellites

Hi all. I’m new to Orekit. Now, I have a problem that I want to calculate the azimuth and elevation between two satellites(given in TLE). I tried using TopocentricFrame to define one of the two satellites spacecraftstate point, the elevation is pretty right comparing to STK results, but not the azimuth. So what I can do to fix this?

Thanks in advance.
seongyong

Hi there and welcome to this forum,

Not sure what you mean by AzEl between satellites, as you need some sort of horizon to define the second angle I would think. Do you have a link describing STK’s definition?
As fas as TopocentricFrame is concerned, it only makes sense for a geographical site on a celestial body like the Earth. Note that in Orekit the convention for the azimuth origin is NOT such that it’s the arctan2 of the XY components.

Cheers,
Romain.

@Serrof
Thank you so much for replying me.
Now, I am doing this. I created a SatLinkDetector to limit the distance and AzEi of the communication between two satellites, like this(Referenced from here):

public class SatLinkDetector extends AbstractDetector<SatLinkDetector> {

    private final double distance;
    private final double minElevation;
    private final double maxElevation;
    private final PVCoordinatesProvider secondary;

    public SatLinkDetector(final double distance, final double minElevation, final double maxElevation, final PVCoordinatesProvider secondary) {
        this(distance, minElevation, maxElevation, secondary, DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER, new ContinueOnEvent<>());
    }

    private SatLinkDetector(final double distance,
                            final double minElevation,
                            final double maxElevation,
                            final PVCoordinatesProvider secondary,
                            final double maxCheck,
                            final double threshold,
                            final int maxIter,
                            final EventHandler<? super SatLinkDetector> handler) {
        super(maxCheck, threshold, maxIter, handler);
        this.distance = distance;
        this.minElevation = minElevation;
        this.maxElevation = maxElevation;
        this.secondary = secondary;
    }

    @Override
    public double g(SpacecraftState s) {

        // PV of the primary
        final Vector3D pPrimary = s.getPVCoordinates().getPosition();

        // PV of the secondary
        final Vector3D pSecondary = secondary.getPVCoordinates(s.getDate(), s.getFrame()).getPosition();

        OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
                Constants.WGS84_EARTH_FLATTENING, FramesFactory.getTIRF(IERSConventions.IERS_2010, true));

        // LLA
        final GeodeticPoint geodeticPoint = earth.transform(pSecondary, s.getFrame(), s.getDate());
        final TopocentricFrame observe = new TopocentricFrame(earth, geodeticPoint, "Test");
        // Elevation
        final double elevation = FastMath.toDegrees(observe.getElevation(pPrimary, s.getFrame(), s.getDate()));
        final double azimuth = FastMath.toDegrees(observe.getAzimuth(pPrimary, s.getFrame(), s.getDate()));
        final double range = Vector3D.distance(pPrimary, pSecondary) - distance;

        if (elevation < maxElevation && elevation > minElevation && range <= 0) {
            return 1;
        } else {
            return -1;
        }
    }

    @Override
    protected SatLinkDetector create(final double newMaxCheck, final double newThreshold, final int newMaxIter,
                                     final EventHandler<? super SatLinkDetector> newHandler) {
        return new SatLinkDetector(distance, minElevation, maxElevation, secondary, newMaxCheck, newThreshold, newMaxIter, newHandler);
    }
}

Am I doing this right?

Hi @seongyong,

Beware you’re using TIRF instead of ITRF here. I don’t know if it’s intended but you will be missing pole motion (see the documentation on frames)

hi @seongyong,

Another, perhaps simpler/more modular way of doing this, would be to combine several simpler detectors using the BooleanDetector. It would allow you to later on add other events to your final detector using logical expression (and/or/not).

Of course you can create your own detector as you already do :+1: !

Cheers,
Vincent

Thank you all for replying!
I found the problem, the Azimuth I calculated was in a wrong frame.
I used the NorthEastUp Frame maybe,

But actually, I want things like this,
image
So, how can I calculate the Azimuth in this frame?

Thanks for all your answers!
Now, I tried something in the g function of my detector like this, and I got what I wanted:

        // AzEi
        LofOffset VVLH = new LofOffset(s.getFrame(), LOFType.VVLH);
        SpacecraftState converted = new SpacecraftState(s.getOrbit(), VVLH.getAttitude(s.getOrbit(), s.getDate(), s.getFrame()));
        TimeStampedPVCoordinates pv2 = converted.toTransform().transformPVCoordinates(secondary.getPVCoordinates(s.getDate(), s.getFrame()));
        double elevation = FastMath.toDegrees(-pv2.getPosition().getDelta());
        double azimuth = FastMath.toDegrees(pv2.getPosition().getAlpha());

Hope this could help somebody else.
Thanks.

1 Like