ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes | List of all members
larcfm::TrajGen Class Reference

#include <TrajGen.h>

Static Public Member Functions

static Triple< double, double, double > getStoredParameters (const Plan &p)
 
static void addParams (Plan &p, double bankAngle, double gsAccel, double vsAccel)
 
static bool turnCanBeInscribed (const Plan &lpc, int i, const Position &BOT, const Position &EOT)
 
static Plan markVsChanges (const Plan &lpc)
 
static Plan generateTurnTCPs (const Plan &kpc, double bankAngle)
 
static Plan generateTurnTCPs (const Plan &lpc, double default_bank_angle, bool continueGen)
 
static void generateTurnTcpAt (Plan &traj, int ixNp2, double default_bankAngle, bool continueGen)
 
static void generateTurnTcp (Plan &traj, int ixNp2, double R, bool bankUsed, bool continueGen)
 
static double neededTurnLegDistance (const Plan &p, int ix, double radius)
 
static double neededLegLengthBankAngle (const Plan &p, int ix, double bankAngle)
 
static std::pair< int, double > movePointsWithinTurn (Plan &traj, int ixBOT, int ixNp2, int ixEOT, double gsIn)
 
static Plan generateTurnTCPsRadius (const Plan &lpc)
 
static Plan generateTurnTCPsRadius (const Plan &lpc, bool continueGen)
 
static void generateGsTCPsAt (Plan &traj, int i, double gsAccel, bool repairGs)
 
static bool adjustGsInsideAccel (Plan &traj, int ixBGS, double aBGS, double distToEGS)
 
static int generateGsToZero (Plan &traj, int i, double a, double targetGs)
 
static void adjustGsInsideAccelToEGS (Plan &traj, int ixBGS, double aBGS, int ixEGS)
 
static bool attemptRepair2 (Plan &kpc, int ixBGS, int ixEGS, double maxGsAccel)
 
static TcpData makeBGS (const TcpData &tcp1, double a, bool isAltPreserve)
 
static TcpData makeEGS ()
 
static Plan generateGsTCPs (const Plan &fp, double maxGsAccel, bool repairGs)
 
static void generateGsTCP (Plan &traj, int i, double maxGsAccel, bool repairGs)
 
static Plan generateVsTCPs (const Plan &kpc, double maxVsAccel, bool continueGen, bool repairVs_zeroGs)
 
static Plan generateVsTCPs (const Plan &kpc, double maxVsAccel)
 
static int generateVsTCP (Plan &traj, int i, double vsAccel, bool continueGen, bool repairVs_zeroGs)
 
static bool fixAlts (Plan &traj, int bindex, int eindex, double vs1, double accel)
 
static double calcRadius (const Plan &p, int ix, double bank)
 
static Plan linearRepairShortTurnLegs (const Plan &fp, double bank, bool addMiddle)
 
static Plan makeMarkedVsConstant (const Plan &kpc)
 
static Plan repairPlan (const Plan &lpc, bool repairTurn, bool repairVs, double bankAngle, double vsAccel)
 
static Plan makeKinematicPlan (const Plan &fp, double bankAngle, double gsAccel, double vsAccel, bool repairTurn, bool repairVs, bool repairGs)
 
static Plan makeKinematicPlan (const Plan &fp, double bankAngle, double gsAccel, double vsAccel)
 
static Plan makeVsKinematicPlan (const Plan &p, double vsAccel)
 
static Plan genDirect2 (const Plan &lpc, const Position &so, const Velocity &vo, double to, double bankAngle)
 
static Plan genDirectToLinear (const Plan &fp, const Position &so, const Velocity &vo, double to, double bankAngle, double timeBeforeTurn)
 
static Plan buildDirectTo (const NavPoint &s, const Velocity &v, const Plan &base, double bankAngle)
 
static Plan makeLinearPlan (const Plan &fp)
 
static void setVerbose (bool b)
 
static void printError (const std::string &s)
 

Static Public Attributes

static const double MIN_MARK_LEG_TIME = Units::from("s",60)
 
static const double minorVfactor = 0.01
 
static const double maxVs = Units::from("fpm",10000)
 
static const double maxAlt = Units::from("ft",60000)
 
static const std::string turnFail = "<TrajGen.turnGenError>"
 
static const std::string gsFail = "<TrajGen.gsGenError>"
 
static const std::string vsFail = "<TrajGen.vsGenError>"
 

Static Private Member Functions

static double directToContinueTime (const Plan &lpc, const Position &so, const Velocity &vo, double to, double bankAngle)
 

Static Private Attributes

static bool verbose = false
 

Detailed Description

Trajectory generation functionality. This class translates Linear plans into Kinematic plans. The translation back to a Linear plan from a Kinematic plan is accomplished using reversion methods defined in PlanUtil (See PlanUtil.revertAllTCPS).

Note: It is very easy to create a linear plan that is infeasible, that is, it contains a segment where there is insufficient time or distance to achieve the acceleration implicit in it. If TrajGen.makeKinematicPlan fails to generate a Kinematic plan, an error message is added to the plan. There are "repair" methods available that modify the linear plan that often turn it into a feasible plan (See PlanUtil.repairShortVsLegs, PlanUtil.fixBadTurns)

Member Function Documentation

◆ addParams()

void larcfm::TrajGen::addParams ( Plan p,
double  bankAngle,
double  gsAccel,
double  vsAccel 
)
static

Store accel magnitude values used to generate this kinematic plan in a plan's note field. Negative values will be ignored.

Parameters
pplan to modify
bankAnglebank angle in radians, negative for none
gsAccelgs accel in m/s, negative for none
vsAccelvs accel in m/s, negative for none

Store accel values in a plan's note field

Parameters
pplan to modify
bankAnglebank angle in radians, negative for none
gsAccelgs accel in m/s, negative for none
vsAccelvs accel in m/s, negative for none

◆ adjustGsInsideAccel()

bool larcfm::TrajGen::adjustGsInsideAccel ( Plan traj,
int  ixBGS,
double  aBGS,
double  distToEGS 
)
static

Adjust ground speed of all points that will fall within distance to new EGS (distToEGS) This is necessary because points between a newly added BGS – EGS region will have time based on the previous non-accelerated section.

Parameters
trajthe plan file of interest
ixBGSindex of BGS (that has just been added, but EGS has not yet been added!)
aBGSsigned acceleration value
distToEGSdistance from BGS to new EGS point

Note: It is necessary to adjust by distance and not time. The times will change, so the EGS should added after this function is called.

remove all points that will fall within distance to new EGS (distToEGS)

Parameters
trajthe plan file of interest
ixBGSindex of BGS
aBGSacceleration value
distToEGSdistance from BGS to new EGS point

◆ adjustGsInsideAccelToEGS()

void larcfm::TrajGen::adjustGsInsideAccelToEGS ( Plan traj,
int  ixBGS,
double  gsAccel,
int  ixEGS 
)
static

Adjust ground speed of all points that will fall within distance to new EGS (distToEGS)

Parameters
trajthe plan file of interest
ixBGSindex of BGS
aBGSsigned acceleration value
distToEGSdistance from BGS to new EGS point

Note: this function used where EGS has already been added.

◆ buildDirectTo()

Plan larcfm::TrajGen::buildDirectTo ( const NavPoint s,
const Velocity v,
const Plan base,
double  bankAngle 
)
static

Construct a (hopefully) feasible linear plan that describes a path from s to the goal point. If this fails, it reurns a simple direct plan.

◆ calcRadius()

double larcfm::TrajGen::calcRadius ( const Plan p,
int  ix,
double  bank 
)
static

calculate radius at vertex ix, If a radius has been set use it, otherwise use bank angle and GS to calculate value

Parameters
pPlan
ixindex of vertex point
bankbank angle
Returns

◆ directToContinueTime()

double larcfm::TrajGen::directToContinueTime ( const Plan lpc,
const Position so,
const Velocity vo,
double  to,
double  bankAngle 
)
staticprivate

Attempts to compute (heuristic) the amount of time to continue current velocity before starting direct to turn. (in 2-D)

Parameters
lpcPlan trying to connect to at point zero.
socurrent position
vocurrent velocity
tocurrent time
bankAnglemax bank angle
Returns

◆ fixAlts()

bool larcfm::TrajGen::fixAlts ( Plan traj,
int  bindex,
int  eindex,
double  vs1,
double  accel 
)
static

This method makes all of the vertical speed out of bindex to be vs1. It also smoothes the velocity profile according to the "accel" parameter.

Note: this is essential to making the BVS-EVS pair consistent

Parameters
trajtrajectory of interest
bindexstart of smoothing region
eindexend of smoothing region
vs1velocity to use for smoothing
accelacceleration in this BGS EGS region
Returns
true, if successful

◆ genDirect2()

Plan larcfm::TrajGen::genDirect2 ( const Plan pc,
const Position so,
const Velocity vo,
double  to,
double  bankAngle 
)
static

*** UNUSED ***

Parameters
lpca linear plan that needs to be connected to, preferable at point 0
socurrent position
vocurrent velocity
tocurrent time
bankAngleturn bank angle
Returns
new plan with (so,vo,to) added as a first point and a leadIn point added
Parameters
lpca linear plan that needs to be connected to, preferable at point 0
socurrent position
vocurrent velocity
tocurrent time
bankAngleturn bank angle
Returns
new plan with (so,vo,to) added as a first point and a leadIn point added

◆ genDirectToLinear()

Plan larcfm::TrajGen::genDirectToLinear ( const Plan fp,
const Position so,
const Velocity vo,
double  to,
double  bankAngle,
double  timeBeforeTurn 
)
static

Constructs a new linear plan that connects current state to existing linear plan lpc (in 2-D).

Parameters
fpa linear plan that needs to be connected to at point 0
socurrent position
vocurrent velocity
tocurrent time
bankAngleturn bank angle
timeBeforeTurndelay time before continuing turn. (can call directToContinueTime for an estimate)
Returns
new linear plan with (so,vo,to) added as a first point and a leadIn point added If we cannot connect to point zero of lpc this returns a plan with its error status set. The resulting plan may be infeasible from a kinematic view.
Parameters
lpca linear plan that needs to be connected to, preferable at point 0
socurrent position
vocurrent velocity
tocurrent time
bankAngleturn bank angle
Returns
new plan with (so,vo,to) added as a first point and a leadIn point added

◆ generateGsTCPs()

Plan larcfm::TrajGen::generateGsTCPs ( const Plan fp,
double  maxGsAccel,
bool  repairGs 
)
static

Generates ground speed TCPs (in forward direction)

Parameters
fpplan to be processed
maxGsAccelground speed acceleration (non-negative)
repairGsif segment is too short, repair by skipping over it (i.e. achieve max possible accel)
Returns
plan with BGS-EGS pairs added

◆ generateGsTCPsAt()

void larcfm::TrajGen::generateGsTCPsAt ( Plan traj,
int  i,
double  gsAccel,
bool  repairGs 
)
static

Create a BGS-EGS pair starting at index "i". The speed into and out of EGS will be "targetGs" Note: targetGS is often chosen to be gsOut(i+1) so that there is continuity at "i+1" after this method is called at "i"

Parameters
trajtrajectory
iindex where BGS is created
gsAccelunsigned acceleration value
targetGstarget ground speed (usually gsOut(i+1) – calculated earlier)
timeOffsetcreate BGS this much time after time(i), it can be zero

Note: This method will skip over points until the targetGs is obtained.

◆ generateGsToZero()

int larcfm::TrajGen::generateGsToZero ( Plan traj,
int  i,
double  gsAccel,
double  targetGs 
)
static

generate an BGS-EGS pair with the EGS at point i

Parameters
trajtrajectory
ipoint with GSOut = 0
aabsolute acceleration
targetGsshould be zero are almost zero
Returns
index where BGS is located

◆ generateTurnTcp()

void larcfm::TrajGen::generateTurnTcp ( Plan traj,
int  ixNp2,
double  R,
bool  bankUsed,
bool  continueGen 
)
static

Generate turn at vertex "ixNP2" with radius R

Parameters
trajtrajectory under construction
ixNp2index of np2 in plan
Runsigned radius
bankUsedtrue if default bank angle was used to compute R
continueGencontinue generation, even with problems

◆ generateTurnTcpAt()

void larcfm::TrajGen::generateTurnTcpAt ( Plan traj,
int  ixNp2,
double  default_bankAngle,
bool  continueGen 
)
static

Generate turn at vertex "ixNP2". If there is a stored radius use that value, otherwise compute radius from default_bankAngle and speed

Parameters
trajtraj
ixNp2turn vertex – should not be in a turn already
dafault_bankAngledefault banks angle used to compute radius
continueGenif true continue turn generation in the presence of errors

◆ generateTurnTCPs()

Plan larcfm::TrajGen::generateTurnTCPs ( const Plan lpc,
double  default_bank_angle,
bool  continueGen 
)
static

Kinematic generator that adds turn TCPs. This defers ground speed changes until after the turn. It assumes legs are long enough to support the turns. bank angle must be nonnegative!!!!!

Parameters
lpclinear plan
default_bank_anglethe default bank angle, if a radius is not present in the plan.
continueGenif true, do not terminate generation if an error message is produced
Returns
a turn plan with BOTs and EOTs

◆ generateTurnTCPsRadius() [1/2]

Plan larcfm::TrajGen::generateTurnTCPsRadius ( const Plan lpc)
static

Kinematic generator that adds turn TCPs. This defers ground speed changes until after the turn. It assumes legs are long enough to support the turns.

Parameters
lpclinear plan
Returns
a plan with BOTs and EOTs

◆ generateTurnTCPsRadius() [2/2]

Plan larcfm::TrajGen::generateTurnTCPsRadius ( const Plan lpc,
bool  continueGen 
)
static

Kinematic generator that adds turn TCPs. This defers ground speed changes until after the turn. It assumes legs are long enough to support the turns.

Parameters
lpclinear plan
continueGencontinue generation, even with problems
Returns
a plan with BOTs and EOTs

◆ generateVsTCP()

int larcfm::TrajGen::generateVsTCP ( Plan traj,
int  i,
double  vsAccel,
bool  continueGen,
bool  repairVs_zeroGs 
)
static

Generate a BVS EVS pair at index i if deltaVs is large enough

Parameters
trajtrajectory
iindex
vsAccelvertical acceleration
continueGenif true continue generation even if errors are encountered, results in a partial kinematic plan
Returns
the index of the EVS if successful, otherwise just i

t1 = previous point's time (previous EVS) t2 = np2.time() = end time of the linear segment where the vertical speed change occurred nextVsChangeTm = time of the next vertical change (i.e. where the next TCP will appear) vs1 vertical speed into point at time t2 vs2 vertical speed out of point at time t2

                        vs1                              vs2
        t1  -------------------------------- t2 ------------------------------ nextVsChangeTm
                                       ^     "i"   ^
                                       |           |
                                     tbegin       tend

◆ generateVsTCPs()

Plan larcfm::TrajGen::generateVsTCPs ( const Plan kpc,
double  maxVsAccel,
bool  continueGen,
bool  repairVs_zeroGs 
)
static

Generate Vertical acceleration TCPs It assumes that all horizontal passes have been completed.

Parameters
kpckinematic plan with final horizontal path
maxVsAccelvertical speed acceleration (positive)
continueGentrue means continue generation even with problems
Returns
plan

Generate Vertical acceleration TCPs It assumes that all horizontal passes have been completed.

Parameters
kpckinematic plan with final horizontal path
maxVsAccelvertical speed acceleration (positive)
Returns

◆ linearRepairShortTurnLegs()

Plan larcfm::TrajGen::linearRepairShortTurnLegs ( const Plan fp,
double  bank,
bool  addMiddle 
)
static

Repair function for a linear plan This can eliminate short legs. This function look for two sequential turns with a very short leg segment between them. It collapses the two turns into one or no turns

Parameters
fplinear plan to be repaired
bankbank angle
addMiddleif true, it adds a middle point when it deletes two points (one turn left)
Returns
repaired Plan

Note: if addMiddle is false, point info and named waypoint may be lost

◆ makeBGS()

TcpData larcfm::TrajGen::makeBGS ( const TcpData tcp1,
double  a,
bool  isAltPreserve 
)
static

Create a BGS point from a previous point (that is using its TCP info in tcp1)

Parameters
tcp1
a
timeOffset
isAltPreserve
Returns

◆ makeKinematicPlan() [1/2]

Plan larcfm::TrajGen::makeKinematicPlan ( const Plan fp,
double  bankAngle,
double  gsAccel,
double  vsAccel 
)
static

The resulting PlanCore will be "clean" in that it will have all original points, with no history of deleted points. Also all TCPs should reference points in a feasible plan. If the trajectory is modified, it will have added, modified, or deleted points. If the conversion fails, the resulting plan will have one or more error messages (and may have a point labeled as "TCP_generation_failure_point").

Parameters
fpinput plan (is linearized if not already so)
bankAnglemaximum allowed (and default) bank angle for turns
gsAccelmaximum allowed (and default) ground speed acceleration (m/s^2)
vsAccelmaximum allowed (and default) vertical speed acceleration (m/s^2)
Returns
plan

◆ makeKinematicPlan() [2/2]

Plan larcfm::TrajGen::makeKinematicPlan ( const Plan fp,
double  bankAngleIn,
double  gsAccelIn,
double  vsAccelIn,
bool  repairTurn,
bool  repairGs,
bool  repairVs 
)
static

TODO (helps me find this method)

The resulting Plan will be "clean" in that it will have all original points, with no history of deleted points. Also all TCPs should reference points in a feasible plan. If the trajectory is modified, it will have added, modified, or deleted points. If the conversion fails, the resulting plan will have one or more error messages (and may have a point labeled as "TCP_generation_failure_point"). Note: This method seeks to preserve ground speeds of legs. The time at a waypoint is assumed to be not important compared to the original ground speed. Note. If a turn vertex NavPoint has a non-zero "radius", then that value is used rather than "bankAngle"

Parameters
fpinput plan (is linearized if not already so)
bankAnglemaximum allowed (and default) bank angle for turns
gsAccelmaximum allowed (and default) ground speed acceleration (m/s^2)
vsAccelmaximum allowed (and default) vertical speed acceleration (m/s^2)
repairTurnattempt to repair infeasible turns as a preprocessing step
repairGsattempt to repair infeasible ground speed accelerations
repairVsattempt to repair infeasible vertical speed accelerations as a preprocessing step
Returns
the resulting kinematic plan

TODO

  • The resulting PlanCore will be "clean" in that it will have all original points, with no history of deleted points. Also all TCPs should reference points in a feasible plan. If the trajectory is modified, it will have added, modified, or deleted points. If the conversion fails, the resulting plan will have one or more error messages (and may have a point labeled as "TCP_generation_failure_point").
    Parameters
    fpinput plan (is linearized if not already so)
    bankAnglemaximum allowed (and default) bank angle for turns
    gsAccelmaximum allowed (and default) ground speed acceleration (m/s^2)
    vsAccelmaximum allowed (and default) vertical speed acceleration (m/s^2)
    minVsChangeRecognizedminimum vs change that will register as "non-constant" (m/s)
    repairTurnattempt to repair infeasible turns as a preprocessing step
    repairGsattempt to repair infeasible gs accelerations as a preprocessing step
    repairVsattempt to repair infeasible vs accelerations as a preprocessing step
    constantGSif true, produces a constant ground speed kinematic plan with gs being average of linear plan

◆ makeLinearPlan()

Plan larcfm::TrajGen::makeLinearPlan ( const Plan fp)
static

Returns a PlanCore version of the given plan. If it was a kinematic plan, this will attempt to regress the TCPs to their original source points (if the proper metadata is available). If this is already a PlanCore, return a copy.

Parameters
fpplan
Returns
plan

Returns a PlanCore version of the given plan. If it was a kinematic plan, this will attempt to regress the TCPs to their original source points (if the proper metadata is available). If this is already a PlanCore, return a copy.

◆ makeMarkedVsConstant()

Plan larcfm::TrajGen::makeMarkedVsConstant ( const Plan kpc)
static

Penultimate Kinematic generation pass. Repairs altitudes so that only VSC points have vertical speed changes. Averages vertical speeds between alt preserved points by modifying altitudes on points between them.

Parameters
kpckinematic plan
Returns
plan

◆ makeVsKinematicPlan()

Plan larcfm::TrajGen::makeVsKinematicPlan ( const Plan p,
double  vsAccel 
)
static

This assumes a plan that has altitude preserve points marked. Generate the vertical profile (only) for VsTCPs in this plan.

Parameters
pinput plan (need not be linear)
vsAccelvertical acceleration
Returns
plan with vertical TCPs generated

◆ markVsChanges()

Plan larcfm::TrajGen::markVsChanges ( const Plan lpc)
static

This takes a Plan lpc and returns a plan that has all points with vertical changes as "AltPreserve" points, with all other points being "Original" points. Beginning and end points are always marked.

Parameters
lpcsource plan
vsAccelvertical acceleration
Returns
kinematic plan with marked points

This takes a plancore lpc and returns a kinematic plan core that has all points with vertical changes as "AltPreserve" points, with all other points being "Original" points. Beginning and end points are always marked.

Parameters
lpcsource plan
Returns
kinematic plan with marked points

◆ movePointsWithinTurn()

std::pair< int, double > larcfm::TrajGen::movePointsWithinTurn ( Plan traj,
int  ixBOT,
int  ixNp2,
int  ixEOT,
double  gsIn 
)
static

Re-aligns points that are within a newly generated turn at j

◆ neededTurnLegDistance()

double larcfm::TrajGen::neededTurnLegDistance ( const Plan p,
int  ix,
double  radius 
)
static

Calculates the minimum leg distance that can handle a specified radius

Parameters
pthe Plan (i.e. trajectory)
ixvertex index
radiusradius of turn
Returns
minimum leg distance, return 0 if no turn would be generated here
Parameters
pthe Plan (i.e. trajectory)
ixvertex index
radiusradius of turn
Returns
minimum leg distance, return 0 if no turn would be generated here

◆ repairPlan()

Plan larcfm::TrajGen::repairPlan ( const Plan lpc,
bool  repairTurn,
bool  repairVs,
double  bankAngle,
double  vsAccel 
)
static

Method to repair an infeasible linear plan where there are segments that are too short to achieve specified acceleration.

Parameters
lpclinear plan
repairTurntrue, to attempt repair of infeasible turns
repairVstrue, to attempt repair of infeasible vertical speed segments
bankAnglebank angle
vsAccelvertical speed acceleration
Returns
repaired plan

◆ turnCanBeInscribed()

bool larcfm::TrajGen::turnCanBeInscribed ( const Plan lpc,
int  i,
const Position BOT,
const Position EOT 
)
static

Returns true if turn at i can be inscribed in the available leg space. Note that it will check for collinear points using prevTrackChange and nextTrackChange

Parameters
lpcsource plan
ivertex to be tested
BOTBeginning of turn
EOTEnd of turn
Returns
true iff the BOT - EOT pair can be placed within vertex

The documentation for this class was generated from the following files: