Compute contact windows between two satellites

Hi @jcf

In order to know if the Earth is between your two satellites, I recommend you to use the Orekit event detector InterSatDirectViewDetector.

In addition, in order to detect when the distance between the two satellites is less than a user-defined value, you can create a InterSatDistanceDetector like that:

public class InterSatDistanceDetector extends AbstractDetector<InterSatDistanceDetector> {

    /** Threshold for the distance between the two satellites. */
    private final double distance;

    /** Coordinates provider for the secondary satellite. */
    private final PVCoordinatesProvider secondary;

    /**
     * Constructor.
     * @param distance threshold for the distance between the two satellites in meters
     * @param secondary provider for the secondary satellite
     */
    public InterSatDistanceDetector(final double distance, final PVCoordinatesProvider secondary) {
        this(distance, secondary, DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER,
             new ContinueOnEvent<>());
    }

    /** Private constructor.
     * @param distance threshold for the distance between the two satellites in meters
     * @param secondary provider for the secondary satellite
     * @param maxCheck  maximum checking interval (s)
     * @param threshold convergence threshold (s)
     * @param maxIter   maximum number of iterations in the event time search
     * @param handler   event handler to call at event occurrences
     */
    private InterSatDistanceDetector(final double distance,
                                     final PVCoordinatesProvider secondary,
                                     final double maxCheck,
                                     final double threshold,
                                     final int maxIter,
                                     final EventHandler<? super InterSatDistanceDetector> handler) {
        super(maxCheck, threshold, maxIter, handler);
        this.distance  = distance;
        this.secondary = secondary;
    }

    /** {@inheritDoc} */
    @Override
    public double g(final SpacecraftState s) {

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

        // Position of the secondary at state epoch and frame
        final Vector3D pSecondary = secondary.getPVCoordinates(s.getDate(), s.getFrame()).getPosition();

        // Return the value of the function
        return Vector3D.distance(pPrimary, pSecondary) - distance;

    }

    /** {@inheritDoc} */
    @Override
    protected InterSatDistanceDetector create(final double newMaxCheck, final double newThreshold, final int newMaxIter,
                                              final EventHandler<? super InterSatDistanceDetector> newHandler) {
        return new InterSatDistanceDetector(distance, secondary, newMaxCheck, newThreshold, newMaxIter, newHandler);
    }
}

Finally, you can use the Orekit event detector BooleanDetector#andCombine(event1, event2) (i.e., event1 is the InterSatDirectViewDetector and event2 the InterSatDistanceDetector) to detect when the two satellites are visible and at a distance lower than a user define value.

I hope these comments will help you.

Best regards,
Bryan

1 Like