FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
AuvUndulateMissionControl Class Reference
+ Inheritance diagram for AuvUndulateMissionControl:
+ Collaboration diagram for AuvUndulateMissionControl:

Classes

struct  Command
 
struct  Settings
 The track and the budget the mission law is evaluated against. More...
 

Public Types

enum  EPhase_t { Phase_Transit = 0 , Phase_Return , Phase_Finished }
 Where the mission has got to. More...
 

Public Member Functions

 AuvUndulateMissionControl (std::string simObjectName, ISimObjectCreator *creator)
 
 AuvUndulateMissionControl (std::string simObjectName, const Settings &settings, double updatePeriod=1.0)
 
void OdeFcn (const double dT, const double *const adX, double *const adXDot) const override
 This SimObject has no states, so it has no derivatives.
 
void AcceptedStep (const double dT, const double *const adX) override
 
void Update (double posX, double posY, double battery, double headingMeasured)
 
const CommandHeldCommand () const
 The held command.
 
double MetresPerJoule () const
 The measured distance made good per joule spent, or zero before anything is known.
 

Static Public Member Functions

static double WrapToPi (double angle)
 
static std::string WaypointListError (int numX, int numY)
 
static bool CanReachRecovery (const Settings &settings, double posX, double posY, double battery, double metresPerJoule)
 
static Command CommandOf (const Settings &settings, const Command &previous, double posX, double posY, double battery, double headingMeasured, double metresPerJoule)
 

Protected Member Functions

const double * OutSpeed (const double dT, const double *const adX)
 The commanded forward speed, m/s.
 
const double * OutHeading (const double dT, const double *const adX)
 The commanded heading, rad, unwrapped against the measurement.
 
const double * OutEndMission (const double dT, const double *const adX)
 One once the vehicle is home, zero before that.
 
const double * OutWaypointIndex (const double dT, const double *const adX)
 The index of the waypoint being flown towards.
 
const double * OutDistanceToWaypoint (const double dT, const double *const adX)
 The horizontal distance to the point being flown towards, m.
 
const double * OutPhase (const double dT, const double *const adX)
 Zero while transiting, one while returning, two once finished.
 

Member Enumeration Documentation

◆ EPhase_t

Enumerator
Phase_Transit 

Flying the waypoint list.

Phase_Return 

Flying to the recovery position.

Phase_Finished 

Home. Speed zero and EndMission latched.

Constructor & Destructor Documentation

◆ AuvUndulateMissionControl() [1/2]

AuvUndulateMissionControl::AuvUndulateMissionControl ( std::string  simObjectName,
ISimObjectCreator *  creator 
)

Constructs the controller from the simulation input file.

Parameters
simObjectNameThe name of this object in the simulation.
creatorThe creator of this object.

◆ AuvUndulateMissionControl() [2/2]

AuvUndulateMissionControl::AuvUndulateMissionControl ( std::string  simObjectName,
const Settings settings,
double  updatePeriod = 1.0 
)

Constructs the controller with its parameters given directly.

No ports are registered, so AcceptedStep does nothing and Update must be called with the measurements instead. This constructor exists so that the mission law can be unit tested without a host simulation.

Parameters
simObjectNameThe name of this object.
settingsThe track and the budget.
updatePeriodThe time between evaluations, s.

Member Function Documentation

◆ AcceptedStep()

void AuvUndulateMissionControl::AcceptedStep ( const double  dT,
const double *const  adX 
)
override

Evaluates the law when the update period has elapsed.

Parameters
dTThe current simulation time, s.
adXThe state vector.

◆ CanReachRecovery()

static bool AuvUndulateMissionControl::CanReachRecovery ( const Settings settings,
double  posX,
double  posY,
double  battery,
double  metresPerJoule 
)
static

Reports whether the vehicle can still reach the recovery position with its reserve.

Parameters
settingsThe track and the budget.
posXThe vehicle north coordinate, m.
posYThe vehicle east coordinate, m.
batteryThe energy left in the battery, J.
metresPerJouleThe measured distance made good per joule spent, or zero when nothing has been measured yet.
Returns
True while the mission may continue.

◆ CommandOf()

static Command AuvUndulateMissionControl::CommandOf ( const Settings settings,
const Command previous,
double  posX,
double  posY,
double  battery,
double  headingMeasured,
double  metresPerJoule 
)
static

Evaluates the mission law.

A pure function of the measurements and the previous command, so the whole waypoint, unwrap and battery behaviour can be tested without a simulation.

Parameters
settingsThe track and the budget.
previousThe command held since the previous evaluation.
posXThe vehicle north coordinate, m.
posYThe vehicle east coordinate, m.
batteryThe energy left in the battery, J.
headingMeasuredThe measured vehicle heading, rad.
metresPerJouleThe measured distance made good per joule spent, or zero when nothing has been measured yet.
Returns
The command to hold until the next evaluation.

◆ Update()

void AuvUndulateMissionControl::Update ( double  posX,
double  posY,
double  battery,
double  headingMeasured 
)

Applies the law to one set of measurements and holds the result.

Parameters
posXThe vehicle north coordinate, m.
posYThe vehicle east coordinate, m.
batteryThe energy left in the battery, J.
headingMeasuredThe measured vehicle heading, rad.

◆ WaypointListError()

static std::string AuvUndulateMissionControl::WaypointListError ( int  numX,
int  numY 
)
static

Returns the error message for a waypoint list of the given sizes.

Factored out of the constructor because ISimObjectCreator has no mock in FhSim, so a constructor-only check could not be tested at all.

Parameters
numXThe number of entries in WaypointsX.
numYThe number of entries in WaypointsY.
Returns
The message to report, or an empty string when the list is usable.

◆ WrapToPi()

static double AuvUndulateMissionControl::WrapToPi ( double  angle)
static

Wraps an angle into the half-open interval \((-\pi, \pi]\).

Parameters
angleThe angle, rad.
Returns
The congruent angle in \((-\pi, \pi]\).

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