SHARE
TWEET

Untitled

a guest Jun 18th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void ExampleOfTrackingWithRadar()
  2.         {
  3.             // An example using STK Components in C# . Radar analysis with a tracked aircraft.
  4.             // This example snippet (NUnit test) features the following mission requirements:
  5.             //     - Target aircraft position updated externally from live data which we will simulate
  6.             //     - Transmitter to receiver Power
  7.             //     - Mitchell-Walker probability of detection
  8.             //     - ~34 Radar, 1 aircraft
  9.             //     - ~7Hz analysis rate
  10.             // Note- This architecture can handle additional aircraft.
  11.  
  12.             // basic setup steps
  13.             ExampleEntity.RegisterEntityClass();
  14.             var earth = CentralBodiesFacet.GetFromContext().Earth;
  15.             var now = JulianDate.Now;
  16.             var analysisInterval = new TimeInterval(now, now.AddMinutes(1.0));
  17.             int numberOfRadars = 34;
  18.             var context = new TransactionContext();
  19.  
  20.             // we arrange in a circle about Central Park
  21.             var centralParkManhattan = new Cartographic(Trig.DegreesToRadians(-73.968285), Trig.DegreesToRadians(40.785091), 0.0);
  22.             var initialAircraftPosition = new Cartographic(Trig.DegreesToRadians(-73.968285), Trig.DegreesToRadians(40.785091), 1000);
  23.  
  24.             // create TrackingLibrary aircraft
  25.             var aircraftEntity = new ExampleEntity(context, "UAV_1");
  26.  
  27.             var aircraftParameter = new EntityParameter<ExampleEntity>();
  28.             var aircraft = new Platform
  29.             {
  30.                 LocationPoint = new EntityPoint<ExampleEntity>(aircraftParameter),
  31.                 OrientationAxes = new EntityAxes<ExampleEntity>(aircraftParameter) // we wind up not using this, but we could use this to set live orientation data
  32.             };
  33.             context.DoTransactionally(transaction =>
  34.             {
  35.                 aircraftEntity.LastUpdate.SetValue(transaction, now);
  36.                 aircraftEntity.Position.SetValue(transaction, earth.Shape.CartographicToCartesian(initialAircraftPosition));
  37.             });
  38.  
  39.             AddRadarTargetExtensions(aircraft, earth);
  40.  
  41.             // use this as the target platform in AddTransmitterExtensions and AddReceiverExtensions to effectively turn off targeting
  42.             var fixedLocationPlatform = new Platform("fixedLocation");
  43.             fixedLocationPlatform.LocationPoint = new PointCartographic(earth, initialAircraftPosition);
  44.  
  45.             // Create some spiffy radars
  46.             var radarPlatforms = Enumerable.Range(0, numberOfRadars).Select(index =>
  47.             {
  48.                 var radar = new MonostaticRadar();
  49.                 var geodesic = new EllipsoidGeodesic(earth.Shape, centralParkManhattan, (double)index / numberOfRadars * Constants.TwoPi, 10000.0); // 10Km distance
  50.                 radar.Transmitter = new Platform(string.Format("radar transmitter {0}", index));
  51.                 radar.Receiver = new Platform(string.Format("radar receiver {0}", index));
  52.  
  53.                 // location
  54.                 radar.Transmitter.LocationPoint = new PointCartographic(earth, geodesic.FinalPoint);
  55.                 radar.Receiver.LocationPoint = new PointCartographic(earth, geodesic.FinalPoint);
  56.  
  57.                 // add transmitter and receiver extensions (including orientation axes)
  58.                 AddTransmitterExtensions(radar.Transmitter, aircraft, earth);
  59.                 AddReceiverExtensions(radar.Receiver, aircraft, earth);
  60.                 return radar;
  61.             }).ToList();
  62.  
  63.             // create analysis scalars
  64.             var analysisScalars = Enumerable.Range(0, numberOfRadars).Select(index =>
  65.             {
  66.                 var scalars = new RadarScalars();
  67.                 var transmitterToTargetLink = new LinkSpeedOfLight(radarPlatforms[index].Transmitter, aircraft, earth.InertialFrame);
  68.                 transmitterToTargetLink.Extensions.Add(new WirelessLinkExtension()); // default propagation models. change to desired models
  69.  
  70.                 var targetToReceiverLink = new LinkSpeedOfLight(aircraft, radarPlatforms[index].Receiver, earth.InertialFrame);
  71.                 targetToReceiverLink.Extensions.Add(new WirelessLinkExtension());
  72.  
  73.                 var propagationGraph = new SignalPropagationGraph();
  74.                 propagationGraph.AddLink(transmitterToTargetLink);
  75.                 propagationGraph.AddLink(targetToReceiverLink);
  76.  
  77.                 IntendedSignalStrategy intendedSignalStrategy = new IntendedSignalByTransmitter(radarPlatforms[index].Transmitter);
  78.                 scalars.ripScalar = new TransmitterToTargetReceivedIsotropicPowerScalar(radarPlatforms[index].Transmitter, aircraft, radarPlatforms[index].Receiver, intendedSignalStrategy, propagationGraph);
  79.                 scalars.mwScalar = new MitchellWalkerProbabilityOfDetectionScalar(radarPlatforms[index].Transmitter, aircraft, radarPlatforms[index].Receiver, intendedSignalStrategy, propagationGraph);
  80.  
  81.                 return scalars;
  82.             }).ToList();
  83.  
  84.             // create all needed evaluators
  85.             var group = new EvaluatorGroup();
  86.             var analysisScalarEvaluators = Enumerable.Range(0, numberOfRadars).Select(index =>
  87.             {
  88.                 var evaluators = new RadarScalarEvaluators();
  89.                 var mwEvaluator = analysisScalars[index].mwScalar.GetEvaluator(group);
  90.                 evaluators.MwScalarEvaluator = group.Parameterize(mwEvaluator, TransactionParameter.Instance, aircraftParameter);
  91.                 var ripEvaluator = analysisScalars[index].ripScalar.GetEvaluator(group);
  92.                 evaluators.RipScalarEvaluator = group.Parameterize(ripEvaluator, TransactionParameter.Instance, aircraftParameter);
  93.  
  94.                 return evaluators;
  95.             }).ToList();
  96.  
  97.             // run live analysis      
  98.             var timeStep = Duration.FromSeconds(0.142);
  99.             int circleDivisions = 360;
  100.  
  101.             // simulate a route
  102.             var aircraftRoute = new Cartesian[circleDivisions];
  103.             for (int i = 0; i < circleDivisions; i++)
  104.             {
  105.                 var geodesic = new EllipsoidGeodesic(earth.Shape, centralParkManhattan, (double)i / circleDivisions * Constants.TwoPi, 1000.0); // 1Km distance
  106.                 var position = earth.Shape.CartographicToCartesian(geodesic.FinalPoint);
  107.                 aircraftRoute[i] = position;
  108.             }
  109.  
  110.             // this loop represents simulating updating the position of the aircraft and performing the analysis at a rate of ~7Hz (see the timestep above)
  111.             int div = 0;
  112.             for (JulianDate date = analysisInterval.Start; date < analysisInterval.Stop; date += timeStep)
  113.             {
  114.                 context.DoTransactionally(transaction =>
  115.                 {
  116.                     // update position & stamp with date of last update
  117.                     aircraftEntity.LastUpdate.SetValue(transaction, date);
  118.                     aircraftEntity.Position.SetValue(transaction, aircraftRoute[div]);
  119.  
  120.                     Console.WriteLine("-----");
  121.                     Console.WriteLine(" Time " + date + "Aircraft " + aircraftEntity.CallSign + " Position " + aircraftEntity.Position.GetValue(transaction));
  122.  
  123.                     for (int i = 0; i < numberOfRadars; i++)
  124.                     {
  125.                         double ripResults = analysisScalarEvaluators[i].RipScalarEvaluator.Evaluate(date, transaction, aircraftEntity);
  126.                         double mwResults = analysisScalarEvaluators[i].MwScalarEvaluator.Evaluate(date, transaction, aircraftEntity);
  127.  
  128.                         Console.WriteLine(" Radar Station " + i +
  129.                                           " MW PDet " + mwResults + " RIP " + CommunicationAnalysis.ToDecibels(ripResults));
  130.                     }
  131.  
  132.                     Console.WriteLine("-----");
  133.  
  134.                     div = (div + 1) % circleDivisions;
  135.                 });
  136.             }
  137.         }
  138.  
  139.         /// <summary>
  140.         /// Decorates the platform> that is a radar target.
  141.         /// </summary>
  142.         /// <param name="targetPlatform">The platform representing the radar target.</param>
  143.         /// <param name="earth">The Earth.</param>
  144.         public void AddRadarTargetExtensions(Platform targetPlatform, CentralBody earth)
  145.         {
  146.             SwerlingTargetModel aircraftSwerlingModel = SwerlingTargetModel.II;
  147.             // we use this frame to fake velocity from points in ECEF. Normally you would use FixedFrame
  148.             targetPlatform.OrientationAxes = new AxesVehicleVelocityLocalHorizontal(earth.InertialFrame, targetPlatform.LocationPoint);
  149.  
  150.             double[] clockAngles = { 0.0, Constants.HalfPi, Math.PI, Constants.ThreeHalvesPi };
  151.             double[] rcsCoeffs = { 20.0, 10.0, 0.0, 10.0 };
  152.  
  153.             var sphericalCrossSection = new SphericalTabularMonostaticCrossSectionScatteringCoefficient(clockAngles, rcsCoeffs);
  154.  
  155.             // Construct the radar cross section platform extension with a constant cross section coefficient
  156.             var targetExtension = new TargetRadarCrossSectionExtension(sphericalCrossSection);
  157.  
  158.             //Additional signal data can be added to each frequency band which will be added to the processed reflected signal, which can be discovered by downstream processors.  Below we are
  159.             //adding a data structure to the signal data which indicates the frequency band Swerling case of this target, used by the downstream Mitchell-Walker probability-of-detection algorithm.
  160.             targetExtension.FrequencyBands[0].SignalData.Add(new SignalSwerlingTargetModel(aircraftSwerlingModel));
  161.  
  162.             targetPlatform.Extensions.Add(targetExtension);
  163.         }
  164.  
  165.         /// <summary>
  166.         /// Decorates a radar receiver platform with the necessary items needed to receive radar signals.
  167.         /// </summary>
  168.         /// <param name="receiverPlatform">The platform that represents the radar receiver.</param>
  169.         /// <param name="targetPlatform">The target platform. This is used for active targeting only.</param>
  170.         /// <param name="earth">The Earth.</param>
  171.         public void AddReceiverExtensions(Platform receiverPlatform, Platform targetPlatform, CentralBody earth)
  172.         {
  173.             int pulseCount = 20;
  174.             double wavelength = 0.1; //meters
  175.             double frequency = Constants.SpeedOfLight / wavelength;
  176.             double pulseRepetitionFrequency = 1.0e6;
  177.             double pulseWidth = 1 / (2 * pulseRepetitionFrequency);
  178.             double noiseBandwidth = 1.0 / pulseWidth;
  179.             double halfNoiseBandwidth = noiseBandwidth / 2.0;
  180.             double lowNoiseAmplifierGain = 1e4;
  181.             double antennaNoiseTemperature = 290.0;
  182.             double antennaDiameter = 3.0; //meters;
  183.             double antennaEfficiency = 0.8;
  184.             double antennaBacklobeGain = 0.001;
  185.  
  186.             // use AxesAlignedConstrained axes type
  187.             var earthZaxis = new VectorFixed(earth.FixedFrame.Axes, UnitCartesian.UnitZ);
  188.             Axes targetTrackingAxes = new AxesAlignedConstrained(new VectorTrueDisplacement(targetPlatform.LocationPoint,
  189.                                                                                             receiverPlatform.LocationPoint), AxisIndicator.Third, earthZaxis, AxisIndicator.First);
  190.  
  191.             receiverPlatform.OrientationAxes = targetTrackingAxes;
  192.  
  193.             var parabolicGainPattern = new ParabolicGainPattern(antennaDiameter, antennaEfficiency, antennaBacklobeGain);
  194.  
  195.             // we configure the extension that we will add to the platform
  196.             var receiverAntennaExtension = new RadarReceivingAntennaExtension(parabolicGainPattern, antennaNoiseTemperature);
  197.             receiverPlatform.Extensions.Add(receiverAntennaExtension);
  198.  
  199.             var filter = new RectangularFilter(receiverAntennaExtension.OutputSignalProcessor, 0.0, frequency, -halfNoiseBandwidth, halfNoiseBandwidth);
  200.  
  201.             // low noise amplifier
  202.             var lowNoiseAmplifier = new ConstantGainAmplifier(filter, lowNoiseAmplifierGain);
  203.  
  204.             // configure signal output extension
  205.             var signalOutput = new SignalOutputExtension(lowNoiseAmplifier);
  206.             receiverPlatform.Extensions.Add(signalOutput);
  207.  
  208.             // process the received radar signal
  209.             var waveformIntegrator = new PerfectFixedNumberOfPulsesWaveformIntegrator(pulseCount);
  210.  
  211.             waveformIntegrator.AttachSignalProcessorAsInput(lowNoiseAmplifier);
  212.  
  213.             var processedWaveformOutput = new ProcessedRadarWaveformOutputExtension(waveformIntegrator);
  214.             receiverPlatform.Extensions.Add(processedWaveformOutput);
  215.         }
  216.  
  217.         /// <summary>
  218.         /// Decorates a transmitter platform with the necessary items to transmit radar signals.
  219.         /// </summary>
  220.         /// <param name="transmitterPlatform">The platform that represents the radar transmitter.</param>
  221.         /// <param name="targetPlatform">The target platform. This is used for active targeting only.</param>
  222.         /// <param name="earth">The Earth.</param>
  223.         public void AddTransmitterExtensions(Platform transmitterPlatform, Platform targetPlatform, CentralBody earth)
  224.         {
  225.             //Transmit waveform properties.
  226.             double pulseRepetitionFrequency = 1.0e6;
  227.             double pulseWidth = 1 / (2 * pulseRepetitionFrequency);
  228.             int pulseCount = 20;
  229.             //Transmitter properties
  230.             double wavelength = 0.1; //meters
  231.             double frequency = Constants.SpeedOfLight / wavelength;
  232.             double amplifierGain = 1e4;
  233.             double antennaDiameter = 3.0; //meters;
  234.             double antennaEfficiency = 0.8;
  235.             double antennaBacklobeGain = 0.001;
  236.  
  237.             var parabolicGainPattern = new ParabolicGainPattern(antennaDiameter, antennaEfficiency,
  238.                                                                 antennaBacklobeGain);
  239.             // use AxesAlignedConstrained axes type
  240.             var earthZaxis = new VectorFixed(earth.FixedFrame.Axes, UnitCartesian.UnitZ);
  241.             Axes targetTrackingAxes = new AxesAlignedConstrained(new VectorTrueDisplacement(targetPlatform.LocationPoint,
  242.                                                                                             transmitterPlatform.LocationPoint), AxisIndicator.Third, earthZaxis, AxisIndicator.First);
  243.  
  244.             transmitterPlatform.OrientationAxes = targetTrackingAxes;
  245.  
  246.             // transmitter identification extension
  247.             var transmitterIdentifier = new IdentifiableTransmitterExtension();
  248.             var additionalSignalData = new SignalDataCollection
  249.             {
  250.                 transmitterIdentifier.Identifier
  251.             };
  252.  
  253.             // add a pulsed signal source
  254.             var pulsedSignalData = new PulsedSignalData(pulseRepetitionFrequency, pulseWidth, pulseCount);
  255.             var pulsedSignalSource = new PulsedSignalSource(pulsedSignalData, additionalSignalData);
  256.  
  257.             // add modulator
  258.             var modulator = new PulsedSignalModulator(pulsedSignalSource, Constants.SpeedOfLight / wavelength);
  259.  
  260.             // add amplifier. in this case a simple gain amplifier
  261.             var amplifier = new ConstantGainAmplifier(modulator, amplifierGain);
  262.  
  263.             // add transmitter extension
  264.             var transmittingAntennaExtension = new RadarTransmittingAntennaExtension(amplifier, parabolicGainPattern);
  265.  
  266.             transmitterPlatform.Extensions.Add(transmittingAntennaExtension);
  267.             transmitterPlatform.Extensions.Add(transmitterIdentifier);
  268.         }
  269.  
  270.         /// <summary>
  271.         /// The parameterized scalar values representing the analysis.
  272.         /// </summary>
  273.         public class RadarScalarEvaluators
  274.         {
  275.             /// <summary>
  276.             /// Gets or sets the Mitchell-Walker probability of detection scalar evaluator.
  277.             /// </summary>
  278.             public ParameterizedMotionEvaluator2<Transaction, ExampleEntity, double> MwScalarEvaluator { get; set; }
  279.  
  280.             /// <summary>
  281.             /// Gets or sets the RIP scalar evaluator.
  282.             /// </summary>
  283.             public ParameterizedMotionEvaluator2<Transaction, ExampleEntity, double> RipScalarEvaluator { get; set; }
  284.         }
  285.  
  286.         /// <summary>
  287.         /// The scalars involved in analyzing the radar system.
  288.         /// </summary>
  289.         public class RadarScalars
  290.         {
  291.             /// <summary>
  292.             /// Gets or sets the Mitchell-Walker probability of detection scalar.
  293.             /// </summary>
  294.             public MitchellWalkerProbabilityOfDetectionScalar mwScalar { get; set; }
  295.  
  296.             /// <summary>
  297.             /// Gets or sets the Transmitter to target RIP scalar.
  298.             /// </summary>
  299.             public TransmitterToTargetReceivedIsotropicPowerScalar ripScalar { get; set; }
  300.         }
  301.  
  302.         /// <summary>
  303.         /// A pair of platforms that represent a monostatic radar.
  304.         /// </summary>
  305.         public class MonostaticRadar
  306.         {
  307.             /// <summary>
  308.             /// Gets or sets the radar transmitter platform.
  309.             /// </summary>
  310.             public Platform Transmitter { get; set; }
  311.  
  312.             /// <summary>
  313.             /// Gets or sets the radar receiver platform.
  314.             /// </summary>
  315.             public Platform Receiver { get; set; }
  316.         }
  317.  
  318.         /// <summary>
  319.         /// An example of an entity that may be used with the tracking library.
  320.         /// </summary>
  321.         public class ExampleEntity : IEntityIdentifier,
  322.                                      IEntityLastUpdate,
  323.                                      IEntityVelocity,
  324.                                      IEntityOrientation
  325.         {
  326.             /// <summary>
  327.             /// Register's the entity's descriptors.
  328.             /// </summary>
  329.             public static void RegisterEntityClass()
  330.             {
  331.                 EntityDescriptor<ExampleEntity>.Default = new ExampleEntityDescriptor();
  332.             }
  333.  
  334.             /// <summary>
  335.             /// Initializes the example entity.
  336.             /// </summary>
  337.             /// <param name="context">The context for reading and writing entity values.</param>
  338.             /// <param name="callSign">The name of the entity.</param>
  339.             public ExampleEntity(TransactionContext context, string callSign)
  340.             {
  341.                 if (context == null)
  342.                     throw new ArgumentNullException("context");
  343.                 if (callSign == null)
  344.                     throw new ArgumentNullException("callSign");
  345.  
  346.                 m_callSign = callSign;
  347.                 m_lastUpdate = new TransactedProperty<JulianDate>(context, this);
  348.                 m_position = new TransactedProperty<Cartesian>(context, this);
  349.                 m_velocity = new TransactedProperty<Cartesian>(context, this);
  350.                 m_orientation = new TransactedProperty<UnitQuaternion>(context, this);
  351.             }
  352.  
  353.             /// <summary>
  354.             /// Gets the callsign (name) of the entity.
  355.             /// </summary>
  356.             public object EntityIdentifier
  357.             {
  358.                 get { return m_callSign; }
  359.             }
  360.  
  361.             /// <summary>
  362.             /// Gets the date of the last update of the entity.
  363.             /// </summary>
  364.             public TransactedProperty<JulianDate> LastUpdate
  365.             {
  366.                 get { return m_lastUpdate; }
  367.             }
  368.  
  369.             /// <summary>
  370.             /// Gets the position of the entity.
  371.             /// </summary>
  372.             public TransactedProperty<Cartesian> Position
  373.             {
  374.                 get { return m_position; }
  375.             }
  376.  
  377.             /// <summary>
  378.             /// Gets the velocity of the entity.
  379.             /// </summary>
  380.             public TransactedProperty<Cartesian> Velocity
  381.             {
  382.                 get { return m_velocity; }
  383.             }
  384.  
  385.             /// <summary>
  386.             /// Gets the orientation of the entity.
  387.             /// </summary>
  388.             public TransactedProperty<UnitQuaternion> Orientation
  389.             {
  390.                 get { return m_orientation; }
  391.             }
  392.  
  393.             /// <summary>
  394.             /// Gets the callsign (name) of the entity.
  395.             /// </summary>
  396.             public string CallSign
  397.             {
  398.                 get { return m_callSign; }
  399.             }
  400.  
  401.             private string m_callSign;
  402.             private TransactedProperty<Cartesian> m_position;
  403.             private TransactedProperty<Cartesian> m_velocity;
  404.             private TransactedProperty<JulianDate> m_lastUpdate;
  405.             private TransactedProperty<UnitQuaternion> m_orientation;
  406.         }
  407.  
  408.         /// <summary>
  409.         /// The example entity's descriptor.
  410.         /// </summary>
  411.         public class ExampleEntityDescriptor : EntityDescriptor<ExampleEntity>,
  412.                                                IEntityPositionDescriptor,
  413.                                                IEntityOrientationDescriptor
  414.         {
  415.             /// <summary>
  416.             /// Gets the position's reference frame, which is ECEF.
  417.             /// </summary>
  418.             public ReferenceFrame PositionReferenceFrame
  419.             {
  420.                 get { return CentralBodiesFacet.GetFromContext().Earth.FixedFrame; }
  421.             }
  422.  
  423.             /// <summary>
  424.             /// Gets the orientation axes.
  425.             /// </summary>
  426.             public Axes OrientationAxes
  427.             {
  428.                 get { return PositionReferenceFrame.Axes; }
  429.             }
  430.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top