Code Sample |
The following is a series of code samples that create a simple route and illustrate use of the Route Design Library.
Note |
---|
The functionality described in this topic requires a license for the Route Design Library. |
The following example sets up the ProfileSpeed and ProfileDynamics for the route as well as the DefaultConnectionBehavior. The heights, speeds, and dynamics can be specified independently for each profile. A different profile can be used for different procedures, but for simplicity one set of values is used here to represent a constant height and constant speed cruise. If different heights and speeds are specified for the profiles, the connection segments set on the RoutePropagator (or added specifically by the user) will transition smoothly between them.
ProfileSpeed cruiseSpeed = new ProfileSpeed(30.0, SpeedReference.Total); // ~67 miles per hour ProfileDynamics profileDynamics = new ProfileDynamics(); double inclineAngle = Trig.DegreesToRadians(10.0); profileDynamics.AscentSpeed = cruiseSpeed.TargetSpeed * Math.Sin(inclineAngle); profileDynamics.DescentSpeed = 1.5 * profileDynamics.AscentSpeed; profileDynamics.PitchUpAcceleration = 0.4 * Constants.EarthSurfaceGravity; profileDynamics.PushOverAcceleration = 0.6 * Constants.EarthSurfaceGravity; profileDynamics.ThrustAcceleration = 0.4 * Constants.EarthSurfaceGravity; profileDynamics.ThrustDeceleration = 0.6 * Constants.EarthSurfaceGravity; RoutePropagator propagator = new RoutePropagator(); propagator.CentralBody = earth; propagator.DefaultConnectionBehavior.SurfaceShape = localTerrain.Shape; propagator.DefaultConnectionBehavior.KindOfSurfaceConnection = KindOfSurfaceConnection.RhumbLine; propagator.DefaultConnectionBehavior.Dynamics = profileDynamics; propagator.DefaultConnectionBehavior.Speed = cruiseSpeed; if (useTerrainForProfiles) { propagator.DefaultConnectionBehavior.KindOfProfile = DefaultProfileBehavior.AvoidTerrain; propagator.DefaultConnectionBehavior.TerrainSurface = localTerrain; propagator.DefaultConnectionBehavior.TerrainSamplingDistance = 100.0; // ~328 feet propagator.DefaultConnectionBehavior.MinimumHeightAboveTerrain = 400.0; // ~1312 feet } else { propagator.DefaultConnectionBehavior.KindOfProfile = DefaultProfileBehavior.StandardConnection; propagator.DefaultConnectionBehavior.TerrainSurface = new EllipsoidTerrainProvider(earth.Shape, earth.FixedFrame); }
The following example sets up a TakeoffProcedure. The 'profile' for the takeoff is included in the procedure and no additional profile is needed. Instead, the user specifies the behavior of the takeoff directly on the procedure and the procedure produces the corresponding profile. Note that the angle specified for the takeoff will override the values for the ascent velocity in the dynamics specified above but will still use the pitch accelerations.
TakeoffProcedure takeoff = new TakeoffProcedure(); takeoff.RunwayReferenceSurface = localTerrain; takeoff.Dynamics = profileDynamics; takeoff.TurningRadiusBeforeTakeoff = 10.0; // radius for taxiing onto the runway takeoff.TurningRadiusAfterTakeoff = 400.0; // ~1312 feet takeoff.RunwayStartPosition = runway.InitialPoint; takeoff.RunwayHeading = runway.Heading; takeoff.InitialSpeed = 1.0; // ~2.2 mph takeoff.TakeoffSpeed = 20.0; // ~44.7 mph takeoff.RollDistance = runway.SurfaceDistance * 0.75; takeoff.ClimbAngle = inclineAngle; takeoff.InitialHeightAboveRunway = groundHeight; takeoff.FinalHeightAboveRunway = 300.0; // ~1000 feet propagator.Segments.Add(takeoff);
The following example sets up the Profiles for the route. Depending on whether the user cares about avoiding terrain, the profile used for the procedures is either one that maintains a minimum height above the terrain surface or simply transitions smoothly. Note how the StandardTransitionProfile allows the user to specify whether its boundary conditions are fixed or whether they can be modified by the propagator. If the values for these flags are set to true, the connection profiles will be able to update the heights in the event that the route cannot reach the desired height without violating the ProfileDynamics specified above. Otherwise, if the geometry is infeasible, the system may produce a configuration error. See the section on configuration below for more information.
RouteProfile procedureProfile; cruiseHeight = waypoints[0].Height; if (useTerrainForProfiles) { double minimumHeightAboveTerrain = 200.0; // ~656 feet double samplingDistance = 100.0; // ~328 feet TerrainAvoidanceProfile profile = new TerrainAvoidanceProfile(); profile.Terrain = localTerrain; profile.MinimumHeightAboveTerrain = minimumHeightAboveTerrain; profile.SamplingDistance = samplingDistance; profile.InitialHeightAboveTerrain = cruiseHeight - terrainBaseHeight; profile.FinalHeightAboveTerrain = cruiseHeight - terrainBaseHeight; profile.Dynamics = profileDynamics; profile.Speed = cruiseSpeed; procedureProfile = profile; } else { StandardTransitionProfile profile = new StandardTransitionProfile(); profile.Dynamics = profileDynamics; profile.InitialHeight = cruiseHeight; profile.FinalHeight = cruiseHeight; profile.CruiseSpeed = cruiseSpeed; profile.HeightReferenceSurface = new EllipsoidTerrainProvider(earth.Shape, earth.FixedFrame); profile.AllowModificationOfInitialHeight = false; profile.AllowModificationOfFinalHeight = false; procedureProfile = profile; }
The following example configures the various turn procedures. Primarily, these provide a way of specifying waypoints for a route while differentiating how to handle the turn that occurs at the waypoint.
TurnAfterWaypointProcedure turnAfter = new TurnAfterWaypointProcedure(); turnAfter.Profile = procedureProfile; turnAfter.SurfaceShape = earth.Shape; turnAfter.TurningRadius = turningRadius; turnAfter.Waypoint = waypoints[wpIndex++]; propagator.Segments.Add(turnAfter); TurnBeforeWaypointProcedure turnBefore = new TurnBeforeWaypointProcedure(); turnBefore.Profile = procedureProfile; turnBefore.SurfaceShape = earth.Shape; turnBefore.TurningRadius = turningRadius; turnBefore.Waypoint = waypoints[wpIndex++]; propagator.Segments.Add(turnBefore); InscribedTurnProcedure turnShort = new InscribedTurnProcedure(); turnShort.Profile = procedureProfile; turnShort.SurfaceShape = earth.Shape; turnShort.TurningRadius = turningRadius; turnShort.Waypoint = waypoints[wpIndex++]; propagator.Segments.Add(turnShort);
The following example configures the various holding and search patterns. These represent procedures that occur over a particular area of interest. The entry points and exit points will depend on the previous and next procedures.
ConstantHeightProfile levelProfile = new ConstantHeightProfile(); levelProfile.Height = cruiseHeight; levelProfile.HeightReferenceSurface = localTerrain; levelProfile.ThrustAcceleration = profileDynamics.ThrustAcceleration; levelProfile.ThrustDeceleration = profileDynamics.ThrustDeceleration; levelProfile.Speed = cruiseSpeed.TargetSpeed; levelProfile.AllowVariationInHeight = false; levelProfile.AllowVariationInSpeed = false; CircularHoldProcedure circularHoldProcedure = new CircularHoldProcedure(); circularHoldProcedure.Profile = levelProfile; circularHoldProcedure.SurfaceShape = earth.Shape; circularHoldProcedure.TurningRadius = turningRadius; circularHoldProcedure.Center = waypoints[wpIndex++]; circularHoldProcedure.TurnDirection = ClosedTurnDirection.Right; // For a hold, either specify minimum revolutions, minimum time, or both // The maximum of the two will determine the time in the hold circularHoldProcedure.MinimumTime = Duration.FromSeconds(300.0); // 5 minutes circularHoldProcedure.MinimumRevolutions = 1.0; propagator.Segments.Add(circularHoldProcedure); Cartographic corner1 = waypoints[wpIndex++]; Cartographic corner2 = waypoints[wpIndex++]; Cartographic side = waypoints[wpIndex++]; EllipsoidRhumbLine line = new EllipsoidRhumbLine(earth.Shape, corner1, corner2); Cartographic centerSide = line.InterpolateUsingFraction(0.5); double heading = line.Heading; EllipsoidRhumbLine line2 = new EllipsoidRhumbLine(earth.Shape, corner2, side); double width = line2.SurfaceDistance; double heading2side = line2.Heading; if (Trig.GetSmallSpan(heading, heading2side) > 0) { heading2side = heading + Constants.HalfPi; } else { heading2side = heading - Constants.HalfPi; } Cartographic centerOne = new EllipsoidRhumbLine(earth.Shape, corner1, heading2side, width / 2.0).FinalPoint; Cartographic centerTwo = new EllipsoidRhumbLine(earth.Shape, corner2, heading2side, width / 2.0).FinalPoint; RacetrackHoldProcedure racetrack = new RacetrackHoldProcedure(); racetrack.Profile = levelProfile; racetrack.SurfaceShape = earth.Shape; racetrack.CenterOfTurnOne = centerOne; racetrack.CenterOfTurnTwo = centerTwo; racetrack.TurningRadiusForHold = turningRadius * 2.0; racetrack.TurningRadiusForEntryAndExit = turningRadius; racetrack.TurnDirection = ClosedTurnDirection.Left; // For a hold, either specify minimum revolutions, minimum time, or both // The maximum of the two will determine the time in the hold racetrack.MinimumTime = Duration.FromSeconds(300.0); // 5 minutes racetrack.MinimumRevolutions = 1.0; racetrack.ConstrainEntryAndExitToTrackArcs = false; propagator.Segments.Add(racetrack); corner1 = waypoints[wpIndex++]; corner2 = waypoints[wpIndex++]; side = waypoints[wpIndex++]; line = new EllipsoidRhumbLine(earth.Shape, corner1, corner2); centerSide = line.InterpolateUsingFraction(0.5); heading = line.Heading; double length = line.SurfaceDistance; line2 = new EllipsoidRhumbLine(earth.Shape, corner2, side); width = line2.SurfaceDistance; heading2side = line2.Heading; if (Trig.GetSmallSpan(heading, heading2side) > 0) { heading2side = heading + Constants.HalfPi; } else { heading2side = heading - Constants.HalfPi; } Cartographic center = new EllipsoidRhumbLine(earth.Shape, centerSide, heading2side, width / 2.0).FinalPoint; ConstantHeightProfile higherCruiseHeight = new ConstantHeightProfile(cruiseSpeed.TargetSpeed, Constants.EarthSurfaceGravity, Constants.EarthSurfaceGravity, cruiseHeight + 500.0, RouteHeightReference.SurfaceShape); RasterSearchProcedure raster = new RasterSearchProcedure(); raster.SurfaceShape = earth.Shape; raster.Center = center; raster.HeadingAlongLength = heading; raster.Width = width; raster.Length = length; raster.TurningRadius = turningRadius; raster.Profile = higherCruiseHeight; propagator.Segments.Add(raster); double finalHeight = heightOnFinalApproach + terrainBaseHeight - localTerrain.GetHeightRelativeToShape(waypoints[wpIndex].Longitude, waypoints[wpIndex].Latitude);
The following example configures the LandingProcedure. The profile for the landing is included in the procedure. So no additional profile is specified. Instead, the user specifies the behavior of the landing directly on the procedure and the procedure produces the corresponding profile. Note that the angle specified for the landing will override the values for the descent velocity in the dynamics specified above but will still use the pitch accelerations.
LandingProcedure landing = new LandingProcedure(); landing.RunwayReferenceSurface = localTerrain; landing.RunwayStartPosition = runway.InitialPoint; landing.RunwayHeading = runway.Heading; landing.RollDistance = runway.SurfaceDistance * 0.75; landing.InitialHeightAboveRunway = heightOnFinalApproach; landing.SpeedOnApproach = cruiseSpeed.TargetSpeed; landing.TurningRadiusOnApproach = turningRadius * 2.0; landing.Dynamics = profileDynamics; landing.FinalHeightAboveRunway = groundHeight; landing.FinalSpeed = 1.0; landing.DescentAngle = Trig.DegreesToRadians(-10.0); landing.TurningRadiusAfterLanding = 10.0; // radius used for taxiing off the runway propagator.Segments.Add(landing);
The following example shows how it is possible to mix aircraft routes with ground vehicle routes. Here, the aircraft will taxi along the ground after landing. In order to do this, a custom connection is required to force the route to behave like a ground vehicle between the landing and the taxi procedure.
ConstantHeightProfile taxiProfile = new ConstantHeightProfile(); taxiProfile.Height = groundHeight; // Account for the center of mass above the ground taxiProfile.Speed = 10.0; // ~20 miles per hour taxiProfile.HeightReferenceSurface = localTerrain; taxiProfile.AllowVariationInHeight = false; taxiProfile.AllowVariationInSpeed = false; // Create a custom connection to override the aircraft behavior // in order to act like a ground vehicle ProfileRouteConnection taxiConnection = new ProfileRouteConnection(); taxiConnection.KindOfSurfaceConnection = KindOfSurfaceConnection.RhumbLine; taxiConnection.RouteProfile = taxiProfile; taxiConnection.SurfaceShape = earth.Shape; propagator.Segments.Add(taxiConnection); TurnBeforeWaypointProcedure finalWaypoint = new TurnBeforeWaypointProcedure(); finalWaypoint.Waypoint = new Cartographic(Trig.DegreesToRadians(69.2621550808261), Trig.DegreesToRadians(34.9428441053572), 0); finalWaypoint.TurningRadius = 10.0; finalWaypoint.Profile = taxiProfile; finalWaypoint.SurfaceShape = earth.Shape; propagator.Segments.Add(finalWaypoint);
The following example shows how to propagate the route and check that it was configured correctly. If for some reason one or more of the procedures (or profiles) is unable to be configured such that it creates valid geometry within the user specified parameters, the propagator will produce an error in the ProcedureConfigurationResults and ConnectionConfigurationResults properties on the PropagatedRoute. Such cases include not being able to transition between one profile and another because their heights are too far apart for the specified ascent or descent velocity or also because the speeds specified require accelerations that exceed the thrust acceleration. The surface geometry can also cause problems, such as when the user mistakenly positions a circular hold such that the next waypoint lies inside of its radius.
PropagatedRoute route = propagator.PropagateFromTime(start); if (route.HasConfigurationErrors) { foreach (ProcedureConfigurationResult error in route.ProcedureConfigurationResults) { RouteProcedure problemProcedure = error.Procedure; SurfaceConnectionStatus entryError = error.SurfaceEntryResult.ConnectionStatus; SurfaceConnectionStatus exitError = error.SurfaceExitResult.ConnectionStatus; HeightConfigurationStatus heightError = error.ProfileResult.HeightConfigurationResult.ConnectionStatus; SpeedConfigurationStatus speedError = error.ProfileResult.SpeedConfigurationResult.ConnectionStatus; } } Point trajectoryPoint = route.CreatePointFromRoute(); JulianDate routeStart = route.Start; JulianDate routeStop = route.Stop;
The following example demonstrates some of the geometry types available with Route Design Library.
PropagatedRoute route = propagator.PropagateFromTime(start); // Define geometry double bankRate = Trig.DegreesToRadians(5.0); // 5 deg/sec AxesFromBankAngle aircraftAxes = new AxesFromBankAngle(route, Constants.EarthSurfaceGravity, bankRate); Scalar routeHeight = new ScalarRouteHeight(route, localTerrain); Scalar routeHeading = new ScalarRouteHeading(route); Scalar routeTotalSpeed = new ScalarRouteTotalSpeed(route, localTerrain); Scalar routeSurfaceSpeed = new ScalarRouteSurfaceSpeed(route); // Create evaluators EvaluatorGroup group = new EvaluatorGroup(); AxesEvaluator axesEvaluator = GeometryTransformer.GetAxesTransformation(earth.FixedFrame.Axes, aircraftAxes, group); ScalarEvaluator heightEvaluator = routeHeight.GetEvaluator(group); ScalarEvaluator headingEvaluator = routeHeading.GetEvaluator(group); ScalarEvaluator totalSpeedEvaluator = routeTotalSpeed.GetEvaluator(group); ScalarEvaluator surfaceSpeedEvaluator = routeSurfaceSpeed.GetEvaluator(group); // Optimize for performance group.OptimizeEvaluators(); heightEvaluator = group.UpdateReference(heightEvaluator); headingEvaluator = group.UpdateReference(headingEvaluator); totalSpeedEvaluator = group.UpdateReference(totalSpeedEvaluator); surfaceSpeedEvaluator = group.UpdateReference(surfaceSpeedEvaluator); // Perform analysis here