blob: ddd2f0387df46697961973d8cc578a5b6310e7ef [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pierre Allard,
* Regent L'Archeveque - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.examples.satellite.impl;
import org.eclipse.apogy.core.environment.earth.HorizontalCoordinates;
import org.eclipse.apogy.core.environment.earth.surface.AstronomyUtils;
import org.eclipse.apogy.core.environment.orbit.earth.VisibilityPass;
import org.eclipse.apogy.core.environment.orbit.earth.VisibilityPassSpacecraftPosition;
import org.eclipse.apogy.examples.satellite.Satellite;
public class DefaultConstellationPlannerCustomImpl extends DefaultConstellationPlannerImpl {
@Override
public boolean isValid(VisibilityPass visibilityPass) {
// Check if there is a satellite associated to the OrbitModel.
Satellite satellite = getSatellite(visibilityPass.getOrbitModel());
if (satellite == null)
return false;
// Finds the closest point the satellite comes to the target in the pass.
VisibilityPassSpacecraftPosition closestPosition = visibilityPass.getPositionHistory()
.getSmallestSpacecraftCrossTrackAnglePosition();
if (closestPosition == null)
return false;
/*
* Verify if the satellite roll capability must be considered by the planner.
*/
if (isSatelliteRollCommandValid()) {
// Checks to see if the pass brings us close enough to the target.
if (Math.abs(closestPosition.getSpacecraftCrossTrackAngle()) > Math.abs(satellite.getMaximumRoll()))
return false;
}
/*
* Verify if passes that occur in umbra must be considered.
*/
if (isUmbraPassesValid()) {
// Gets the location of the target
double observerLongitude = visibilityPass.getSurfaceLocation().getLongitude();
double observerLatitude = visibilityPass.getSurfaceLocation().getLatitude();
// Finds the horizontal coordinates of the sun at the target at the time of the
// closest approach.
HorizontalCoordinates sunCoordinates = AstronomyUtils.INSTANCE
.getHorizontalSunPosition(closestPosition.getTime(), observerLongitude, observerLatitude);
// Returns true if the sun is at least <x> degrees above the horizon.
return sunCoordinates.getAltitude() > Math.toRadians(getSunHorizonAngleUmbraThreshold());
}
return true;
}
} // DefaultConstellationPlannerImpl