WSF
P6DofRoute.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef P6DofRoute_H
13#define P6DofRoute_H
14
15#include "p6dof_export.h"
16
17#include <map>
18#include <memory>
19#include <vector>
20
22#include "P6DofWaypoint.hpp"
23#include "UtLLAPos.hpp"
24#include "UtVec2.hpp"
25
26class P6DOF_EXPORT P6DofRoute
27{
28public:
29 // Default constructor
30 P6DofRoute();
31
32 // Return a deep copy of this route
33 P6DofRoute* Clone() const;
34
35 // Destructor
37
38 // Geometric data computed once based on a route from one waypoint to another
40 {
41 double trackDistance_m; // Distance from prev wpt to curr wpt
42 double trackEndHdg_rad; // Heading when current wpt is reached
43 double trackStartHdg_rad; // Heading initially taken from prev wpt to curr wpt
44 double slantRange_m; // 3D distance from prev to curr meters
45 double slope_rad; // Angle from prev wpt to curr wpt
46 double rangeTrack_m; // distance from current position to curr wpt
47 double earthNED[3][3]; // Transform matrix for earth NED coordinates
48 UtVec3d currWptVector; // LLA Position of the current waypoint vector
49 UtVec3d prevWptVector; // LLA Position of the previous waypoint vector
50 UtVec3d trackVector; // Vector from previous to current waypoint
51 };
52
53 // Calculate heading and bank angle for roll-only waypoint navigation
54 static void CalcAimHeadingAndBankAngle(const P6DofWaypoint* aPrevWpt, // Pointer to prev wpt
55 const P6DofWaypoint* aCurrWpt, // Pointer to curr wpt
56 const P6DofWaypoint* aNextWpt, // Pointer to next wpt
57 const sRouteSegment* aCurrSegment, // Pointer to curr route segment
58 const sRouteSegment* aNextSegment, // Pointer to next route segment
59 const UtLLAPos& aCurrentPos_lla, // Current position
60 const UtVec2d& aCurrentVel_mps, // Current velocity
61 P6DofCommonController::WaypointNavData& aNavData, // Output of nav data for autopilot
62 double aTurnRollInMultiplier, // Roll-in multiplier for autopilot
63 double aRouteAllowableAngleError_rad, // Allowable angular error for route heading
64 double aHeading_rad, // Current heading
65 double aSpeed_mps, // Current speed
66 double aMaxBankAngle_rad, // Max allowed bank angle
67 double aMaxBankRate_rad_s, // Max allowed bank rate
68 double aMaxG_g, // Max allowed turn g
69 double aDeltaT_sec,
70 bool& aAchievedWaypoint);
71
72 // Calculate heading angle for yaw-only navigation waypoint
73 static void CalcYawAimHeadingAngle(const P6DofWaypoint* aPrevWpt, // Pointer to prev wpt
74 const P6DofWaypoint* aCurrWpt, // Pointer to curr wpt
75 const P6DofWaypoint* aNextWpt, // Pointer to next wpt
76 const sRouteSegment* aCurrSegment, // Pointer to curr route segment
77 const sRouteSegment* aNextSegment, // Pointer to next route segment
78 const UtLLAPos& aCurrentPos_lla, // Current position
79 const UtVec2d& aCurrentVel_mps, // Current velocity
80 P6DofCommonController::WaypointNavData& aNavData, // Output of nav data for autopilot
81 double aRouteAllowableAngleError_rad, // Allowable angular error for route heading
82 double aHeading_rad, // Current heading
83 double aSpeed_mps, // Current speed
84 double aMaxG_g, // Max allowed turn g
85 double aDeltaT_sec,
86 bool& aAchievedWaypoint);
87
88 // Calculate heading angle for taxi navigation waypoint
89 static void CalcTaxiAimHeadingAngle(const P6DofWaypoint* aPrevWpt, // Pointer to prev wpt
90 const P6DofWaypoint* aCurrWpt, // Pointer to curr wpt
91 const P6DofWaypoint* aNextWpt, // Pointer to next wpt
92 const sRouteSegment* aCurrSegment, // Pointer to curr route segment
93 const sRouteSegment* aNextSegment, // Pointer to next route segment
94 const UtLLAPos& aCurrentPos_lla, // Current position
95 const UtVec2d& aCurrentVel_mps, // Current velocity
96 P6DofCommonController::WaypointNavData& aNavData, // Output of nav data for autopilot
97 float aHeading_rad, // Current heading
98 double aTurnRadius_ft, // Desired turn radius
99 double aDeltaT_sec,
100 bool& aAchievedWaypoint);
101
102 // Calculate vertical rate data for waypoint navigation
104
105 // Get the start heading from one waypoint to another
106 static double GetInitialHeading_rad(const UtLLAPos& aLLAStart, const UtLLAPos& aLLAEnd);
107 // Get the radius of a turn
108 static double GetTurnRadius_m(double aSpeed_mps, double aBankAngle_rad);
109
110 // Get the radius of a turn from the lateral G
111 static double GetTurnRadiusFromLateralG_m(double aSpeed_mps, double aLateralG_g);
112
113 // Get the distance at which point the vehicle needs to start turning based on turn geometry
114 static double GetTurnLeadDistance_m(double aTurnAngle_rad, double aTurnRadius_m);
115
116 // Get the start heading, end heading, and distance between two LLA positions
117 static double GetDistanceBetweenWaypoints_m(const UtLLAPos& aStartLLA,
118 const UtLLAPos& aEndLLA,
119 double& aStartHdg_rad,
120 double& aEndHdg_rad);
121
122 // Perform one time computations for the geometry of a curve between 3 waypoints
123 static sRouteSegment* CalcSegmentGeometry(const P6DofWaypoint* aPrevWpt, const P6DofWaypoint* aCurrWpt);
124
125 // Return the first element in the mRoute vector. Using this and GetNextWaypoint, the entire
126 // route can be iterated across
127 const P6DofWaypoint* GetFirstElement() const;
128
129 // Given a waypoint, return the next waypoint in the route or 0 if it is the last waypoint.
130 const P6DofWaypoint* GetNextWaypoint(const P6DofWaypoint* aWaypoint) const;
131
132 // Return the waypoint at the specified index
133 const P6DofWaypoint* GetWaypointAtIndex(size_t aIndex) const;
134
135 // Return the index of the given waypoint in the route
136 size_t GetWaypointIndex(const P6DofWaypoint* aWaypoint) const;
137
138 // Determine whether the waypoint was passed
139 static bool PassedWaypoint(float aDT, const P6DofCommonController::WaypointNavData& aNavData);
140
141 // Determine whether the waypoint was achieved, either by passing or approaching
142 static bool AchievedWaypoint(float aDT,
144 const P6DofWaypoint* aWaypoint,
145 const P6DofWaypoint* aNextWaypoint);
146
147 // Add a waypoint to the route if the waypoint is valid and not present in the route.
148 // Note: Traveling to the same waypoint multiple times can be accomplished using the
149 // "GoTo"
150 void AddWaypointToRouteEnd(P6DofWaypoint* aWaypoint);
151
152 // Add a waypoint to the start of the route
153 void AddWaypointToRouteStart(P6DofWaypoint* aWaypoint);
154
155 // Return the size of the mRoute vector
156 size_t GetNumberOfWaypoints() const;
157
158 // Return an iterator to the beginning of the route
159 std::vector<P6DofWaypoint*>::const_iterator Begin() const;
160
161 // Return an iterator to the end of the route
162 std::vector<P6DofWaypoint*>::const_iterator End() const;
163
164 // Populate the segment map
165 void ComputeSegmentMap();
166
167 // Add a segment to the segment map.
168 void AddSegment(P6DofWaypoint* aWaypoint, sRouteSegment* aSegment);
169
170 // Return a route segment corresponding to a waypoint.
171 // Note: Given a segment from point A to point B, the segment is mapped using
172 // point A as the key.
173 sRouteSegment* GetRouteSegment(const P6DofWaypoint* aWaypoint) const;
174
175private:
176 P6DofRoute& operator=(const P6DofRoute& aSrc) = delete;
177
178 // Copy constructor
179 P6DofRoute(const P6DofRoute& aSrc);
180
181 // Vector of waypoint pointers that defines a navigation route
182 std::vector<P6DofWaypoint*> mRoute;
183
184 // Map of route segments
185 // Note: Given a segment from point A to point B, the segment is mapped using
186 // point A as the key.
187 std::map<P6DofWaypoint*, sRouteSegment*> mSegments;
188};
189
190#endif // P6DofRoute_H
void AddWaypointToRouteEnd(P6DofWaypoint *aWaypoint)
Definition P6DofRoute.cpp:974
static bool PassedWaypoint(float aDT, const P6DofCommonController::WaypointNavData &aNavData)
Definition P6DofRoute.cpp:821
void AddWaypointToRouteStart(P6DofWaypoint *aWaypoint)
Definition P6DofRoute.cpp:982
void AddSegment(P6DofWaypoint *aWaypoint, sRouteSegment *aSegment)
Definition P6DofRoute.cpp:990
static double GetDistanceBetweenWaypoints_m(const UtLLAPos &aStartLLA, const UtLLAPos &aEndLLA, double &aStartHdg_rad, double &aEndHdg_rad)
Definition P6DofRoute.cpp:898
static bool AchievedWaypoint(float aDT, const P6DofCommonController::WaypointNavData &aNavData, const P6DofWaypoint *aWaypoint, const P6DofWaypoint *aNextWaypoint)
Definition P6DofRoute.cpp:837
static double GetInitialHeading_rad(const UtLLAPos &aLLAStart, const UtLLAPos &aLLAEnd)
Definition P6DofRoute.cpp:861
P6DofRoute()
Definition P6DofRoute.cpp:27
sRouteSegment * GetRouteSegment(const P6DofWaypoint *aWaypoint) const
Definition P6DofRoute.cpp:959
std::vector< P6DofWaypoint * >::const_iterator Begin() const
Definition P6DofRoute.cpp:937
std::vector< P6DofWaypoint * >::const_iterator End() const
Definition P6DofRoute.cpp:932
const P6DofWaypoint * GetWaypointAtIndex(size_t aIndex) const
Definition P6DofRoute.cpp:106
const P6DofWaypoint * GetNextWaypoint(const P6DofWaypoint *aWaypoint) const
Definition P6DofRoute.cpp:62
static void CalcVerticalSpeed(P6DofCommonController::WaypointNavData &aNavData)
Definition P6DofRoute.cpp:805
void ComputeSegmentMap()
Definition P6DofRoute.cpp:942
size_t GetWaypointIndex(const P6DofWaypoint *aWaypoint) const
Definition P6DofRoute.cpp:118
const P6DofWaypoint * GetFirstElement() const
Definition P6DofRoute.cpp:920
static double GetTurnRadius_m(double aSpeed_mps, double aBankAngle_rad)
Definition P6DofRoute.cpp:884
static void CalcAimHeadingAndBankAngle(const P6DofWaypoint *aPrevWpt, const P6DofWaypoint *aCurrWpt, const P6DofWaypoint *aNextWpt, const sRouteSegment *aCurrSegment, const sRouteSegment *aNextSegment, const UtLLAPos &aCurrentPos_lla, const UtVec2d &aCurrentVel_mps, P6DofCommonController::WaypointNavData &aNavData, double aTurnRollInMultiplier, double aRouteAllowableAngleError_rad, double aHeading_rad, double aSpeed_mps, double aMaxBankAngle_rad, double aMaxBankRate_rad_s, double aMaxG_g, double aDeltaT_sec, bool &aAchievedWaypoint)
Definition P6DofRoute.cpp:181
static double GetTurnLeadDistance_m(double aTurnAngle_rad, double aTurnRadius_m)
Definition P6DofRoute.cpp:893
static double GetTurnRadiusFromLateralG_m(double aSpeed_mps, double aLateralG_g)
Definition P6DofRoute.cpp:889
static sRouteSegment * CalcSegmentGeometry(const P6DofWaypoint *aPrevWpt, const P6DofWaypoint *aCurrWpt)
Definition P6DofRoute.cpp:135
P6DofRoute * Clone() const
Definition P6DofRoute.cpp:57
size_t GetNumberOfWaypoints() const
Definition P6DofRoute.cpp:915
static void CalcYawAimHeadingAngle(const P6DofWaypoint *aPrevWpt, const P6DofWaypoint *aCurrWpt, const P6DofWaypoint *aNextWpt, const sRouteSegment *aCurrSegment, const sRouteSegment *aNextSegment, const UtLLAPos &aCurrentPos_lla, const UtVec2d &aCurrentVel_mps, P6DofCommonController::WaypointNavData &aNavData, double aRouteAllowableAngleError_rad, double aHeading_rad, double aSpeed_mps, double aMaxG_g, double aDeltaT_sec, bool &aAchievedWaypoint)
Definition P6DofRoute.cpp:407
static void CalcTaxiAimHeadingAngle(const P6DofWaypoint *aPrevWpt, const P6DofWaypoint *aCurrWpt, const P6DofWaypoint *aNextWpt, const sRouteSegment *aCurrSegment, const sRouteSegment *aNextSegment, const UtLLAPos &aCurrentPos_lla, const UtVec2d &aCurrentVel_mps, P6DofCommonController::WaypointNavData &aNavData, float aHeading_rad, double aTurnRadius_ft, double aDeltaT_sec, bool &aAchievedWaypoint)
Definition P6DofRoute.cpp:612
Definition P6DofWaypoint.hpp:23
Definition P6DofCommonController.hpp:62
Definition P6DofRoute.hpp:40
double rangeTrack_m
Definition P6DofRoute.hpp:46
double trackDistance_m
Definition P6DofRoute.hpp:41
UtVec3d prevWptVector
Definition P6DofRoute.hpp:49
double slantRange_m
Definition P6DofRoute.hpp:44
double slope_rad
Definition P6DofRoute.hpp:45
double trackStartHdg_rad
Definition P6DofRoute.hpp:43
UtVec3d trackVector
Definition P6DofRoute.hpp:50
double trackEndHdg_rad
Definition P6DofRoute.hpp:42
double earthNED[3][3]
Definition P6DofRoute.hpp:47
UtVec3d currWptVector
Definition P6DofRoute.hpp:48
Copyrights Multiple, All Rights Reserved