[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orekit Users] Technical problem to use the class CircularFieldOfView



Le 04/08/2011 17:54, Luc Maisonobe a écrit :
> Le 04/08/2011 16:51, cedric.goulard@cassidian.com a écrit :
>> Hello Luc, 
>> First,	I would like to thank you about your answers. It was fast!!!
> 
> You're welcome.
> 
>>
>> I have understood correctly the relation between the elevation threshold and
>> the half aperture of the fov. However, I would like to know how you have define
>> your instance of the CircularFieldOfViewDetector in your tests. Did you use a
>> nadir attitude and define a fov center vector as Vector3D.PLUS_K ?
> 
> Look at the attached file.

Ooops, I forgot the file. Here it is.

sorry
Luc

> 
>> Can you provide the demonstration?
> 
> Yes, but not immediately. I have only a paper copy of a demonstration I
> set up for students a few years ago and seem to have lost the TeX
> source. I'll have to recreate it :-(
> 
>>
>> More, you said that "a circular field of view detector does not consider Earth
>> masking". In fact, I want to take account of this aspect. How can I do to
>> consider the Earth masking into a circular field of view detector.
> 
> You would have to define a custom detector for Earth limb, as this there
> are no such detectors available in the library yet (we may add it later
> on). Once you have this additional detector, you should combine it with
> the fieldofview detector to build a sort of "logical and" between them,
> at g function level. This is possible for events that do represent zone
> entries and exit (like fields of view, limb, eclipse, maneuvers ...) but
> not with other events (like target dates).
> 
> If you want, we provide training for Orekit (and Apache Commons Math
> too), and building custom detectors as well as combining them is part of
> the training program. If you want to attend a training session, please
> send me a private message.
> 
> best regards,
> Luc
> 
>>
>> Best regard
>> Cedric
>>
> 

/* Copyright 2002-2011 CS Communication & Systèmes
 * Licensed to CS Communication & Systèmes (CS) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * CS licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package fr.cs.examples.attitude;

import org.apache.commons.math.geometry.euclidean.threed.Vector3D;
import org.apache.commons.math.util.FastMath;
import org.orekit.attitudes.NadirPointing;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.bodies.OneAxisEllipsoid;
import org.orekit.errors.OrekitException;
import org.orekit.frames.Frame;
import org.orekit.frames.FramesFactory;
import org.orekit.frames.TopocentricFrame;
import org.orekit.orbits.KeplerianOrbit;
import org.orekit.orbits.Orbit;
import org.orekit.propagation.Propagator;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.analytical.KeplerianPropagator;
import org.orekit.propagation.analytical.tle.TLE;
import org.orekit.propagation.analytical.tle.TLEPropagator;
import org.orekit.propagation.events.CircularFieldOfViewDetector;
import org.orekit.propagation.events.ElevationDetector;
import org.orekit.propagation.events.EventDetector;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
import org.orekit.utils.PVCoordinates;

import fr.cs.examples.Autoconfiguration;

/**
 * @author Luc Maisonobe
 * @version $Revision$ $Date$
 */
public class FovAndElevation {

    /** Program entry point.
     * @param args program arguments (unused here)
     */
    public static void main(String[] args) {
        try {

            // configure Orekit
            Autoconfiguration.configureOrekit();
            String line1 = "1 25977U 99064A   09191.04881908 -.00000525  00000-0 -65532-4 0  4293";
            String line2 = "2 25977  98.3412 192.6075 0000606 205.7418 154.3625 14.77702155515307";
            TLE tle = new TLE(line1, line2);
            TLEPropagator propagator = TLEPropagator.selectExtrapolator(tle);

            AbsoluteDate initialDate = tle.getDate();
            Frame inertialFrame = FramesFactory.getTEME();
            PVCoordinates pvCoordinates = propagator.getPVCoordinates(initialDate);
            Orbit initialOrbit = new KeplerianOrbit(pvCoordinates,
                                                    inertialFrame, initialDate,
                                                    Constants.EIGEN5C_EARTH_MU);
            System.out.println(initialOrbit);

            // earth and frame  
            Frame ITRF2005 = FramesFactory.getITRF2005(); //
            OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS,
                                                          0,
                                                          ITRF2005);

            final GeodeticPoint geodeticPoint =
                    new GeodeticPoint(FastMath.toRadians(45),
                                      FastMath.toRadians(1),
                                      100.0);
            final TopocentricFrame naiFrame = new TopocentricFrame(earth, geodeticPoint, "Station");

            // propagator : consider a simple keplerian motion (could be more elaborate)
            NadirPointing nardirAttitude = new NadirPointing(earth);
            Propagator kepler = new KeplerianPropagator(initialOrbit, nardirAttitude);

            // define the field of view of the satellite
            double halfAperture = Math.toRadians(64.905000730402614928);
            double maxCheck  = 60;
            Vector3D center = Vector3D.PLUS_K;
            EventDetector event1 = new
                    CircularFieldOfViewDetector(maxCheck, naiFrame, center, halfAperture) {
                private static final long serialVersionUID = -5312173187646720536L;
                public int eventOccurred(final SpacecraftState s, final boolean increasing)
                    throws OrekitException {
                    System.out.println("FOV + " + increasing + " " + s.getDate());
                    System.out.println("  range = " + naiFrame.getRange(s.getPVCoordinates().getPosition(),
                                                                                     s.getFrame(),
                                                                                     s.getDate()));
                    System.out.println("  azimuth = " + naiFrame.getAzimuth(s.getPVCoordinates().getPosition(),
                                                                                     s.getFrame(),
                                                                                     s.getDate()));
                    System.out.println("  range = " + naiFrame.getElevation(s.getPVCoordinates().getPosition(),
                                                                                     s.getFrame(),
                                                                                     s.getDate()));
                    return CONTINUE;
                }
            };
            kepler.addEventDetector(event1);

            EventDetector  event2 = new ElevationDetector(60,
                                                         Math.toRadians(5), naiFrame) {
                private static final long serialVersionUID = -5121772350120653699L;
                public int eventOccurred(final SpacecraftState s, final boolean increasing)
                    throws OrekitException {
                    System.out.println("elevation + " + increasing + " " + s.getDate());
                    System.out.println("  radius = " + s.getPVCoordinates().getPosition().getNorm());
                    System.out.println("  range = " + naiFrame.getRange(s.getPVCoordinates().getPosition(),
                                                                        s.getFrame(),
                                                                        s.getDate()));
                    System.out.println("  azimuth = " + naiFrame.getAzimuth(s.getPVCoordinates().getPosition(),
                                                                                     s.getFrame(),
                                                                                     s.getDate()));
                    System.out.println("  range = " + naiFrame.getElevation(s.getPVCoordinates().getPosition(),
                                                                                     s.getFrame(),
                                                                                     s.getDate()));
                    return CONTINUE;
                }
            };
            kepler.addEventDetector(event2);

            // propagate from the initial date to the first raising or for the fixed duration
            double duration = 86400.0;
            kepler.propagate(initialDate.shiftedBy(duration));

        } catch (OrekitException oe) {
            System.err.println(oe.getMessage());
        }
    }

}