LRAUV  revA
HorizontalControl Class Reference

This is the primary "control" for the vehicle's heading. More...

#include <HorizontalControl.h>

Inheritance diagram for HorizontalControl:
Collaboration diagram for HorizontalControl:

Public Member Functions

 HorizontalControl (const Module *module)
 
virtual ~HorizontalControl ()
 
void initialize (void)
 Initialize function. More...
 
void run ()
 The actual "payload" of the component. More...
 
void uninitialize (void)
 Uninit function. More...
 
- Public Member Functions inherited from SyncComponent
CycleOrder getCycleOrder (void)
 Getter function for controlThreadOrderPreference. More...
 
void setRepeating (bool repeating)
 
int getDivisor () const
 
int getModulo () const
 
bool isRepeater ()
 
bool isRepeating ()
 
- Public Member Functions inherited from Component
virtual ~Component ()
 Destructor cleans up readers_ and writers_. More...
 
void registerReader (DataReader *reader)
 
void unregisterReader (DataReader *reader)
 
void registerWriter (DataWriter *writer)
 
void unregisterWriter (DataWriter *writer)
 
void disableMetering (void)
 
FlexArray< DataReader * > & getReaderList (void)
 
FlexArray< DataWriter * > & getWriterList (void)
 
const ModulegetModule ()
 
virtual void configure ()
 Read (or re-read!) configuration settings. More...
 
virtual void execute (void)
 
bool isActive () const
 Indicates if the component is active. More...
 
const CodedStrgetName (void) const
 Returns the name. More...
 
const TimestampgetTimeOfLastRun (void) const
 
ComponentState getState (void)
 Return the component's current state. More...
 
void setState (ComponentState state)
 
RunState getRunState (void)
 Return the component's run state. More...
 
bool isUsingRunState ()
 Return true if using runState. More...
 
void requestData (bool requestingData)
 Tell the component to start (or stop) sending data. More...
 
void requestStart ()
 Tell the component to start runnning. More...
 
void requestPause (const Timespan expectedPauseTime)
 Tell the component to pause runnning. More...
 
void requestResume ()
 Tell the component resume from pause. More...
 
void requestStop ()
 Tell the component to stop runnning. More...
 
virtual RunState start ()
 Do what needs to be done to run Similar to initialize, in old init/run/uninit sequence. More...
 
virtual RunState starting ()
 Might follow a STOP...START sequence Subseqent. More...
 
virtual RunState runnable ()
 Should eventually follow a START request or RESETTING. More...
 
virtual RunState satisfied ()
 Possible return value of a Behavior. More...
 
virtual RunState pause ()
 Pause for a short period (indicated by pauseTime) More...
 
virtual RunState pausing ()
 Might follow a PAUSE request. More...
 
virtual RunState paused ()
 Should eventually follow a PAUSE request: should set continueTime. More...
 
virtual RunState resume ()
 Resume from PAUSE. More...
 
virtual RunState resuming ()
 Might follow a PAUSE...RESUME sequence. More...
 
virtual RunState resetting ()
 Might occur in case of Error. More...
 
virtual RunState stop ()
 Initial state – can be later followed by START. More...
 
virtual RunState stopping ()
 Might follow a STOP request. More...
 
virtual RunState stopped ()
 Should eventually follow a STOP request. More...
 
void setCriticalFailureReported (bool boolVal)
 
void setRecoveringFromCritical (bool boolVal)
 
void setFailureReported (bool boolVal)
 
bool isFailureUninitialized ()
 
void setFailureUninitialized (bool boolVal)
 
void setRetryTimeout (const Timespan &timeout)
 
virtual bool isCompleted (void)
 Query if this component is completed. More...
 
void setPeriod (const Timespan &period)
 Set the period of this component... used if it is periodic. More...
 
const TimespangetPeriod (void)
 Returns the component's period (regardless of whether it is periodic) More...
 
ComponentType getComponentType ()
 Getter function for ComponentType. More...
 
virtual bool isFailed (void) const
 
virtual FailureMode::FailType getFailureType (void) const
 
virtual bool getCriticalFailureReported (void) const
 
virtual bool getFailureReported (void) const
 
virtual Timespan getRetryTimeout (void) const
 
virtual FailureMode::FailType setFailure (FailureMode::FailType failureType)
 
virtual int getFailCount (void) const
 
virtual bool isFailureMissionCritical ()
 
virtual int getAllowableFailures (void) const
 
virtual void setAllowableFailures (int fails)
 
LoggergetLogger (void)
 
virtual int incrementFailCount (void)
 
virtual void resetFailCount (void)
 
virtual int getSkippedRunsSinceFail (void) const
 
virtual int incrementSkippedRunsSinceFail (void)
 
virtual void logVoltage (float voltage, float averageVoltage)
 
virtual void logCurrent (float current, float averageCurrent)
 
const TimestampgetWriteTimestamp (void)
 
void setWriteTimestamp (const Timestamp &writeTimestamp)
 
BlobReadernewBlobReader (const BlobURI &blobURI)
 
BlobReadernewBlobReaderFromUniversal (const Str &componentName, const UniversalBlobURI &blobURI)
 
BlobWriternewBlobWriter (const BlobURI &blobURI, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
ConfigReadernewConfigReader (const ConfigURI &configURI)
 
DataReadernewDataReader (const DataURI &dataURI)
 
DataReadernewDataReaderFromUniversal (const Str &componentName, const UniversalURI &universalURI)
 
DataWriternewDataWriter (const DataURI &dataURI, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
UniversalBlobReadernewUniversalBlobReader (const UniversalBlobURI &universalURI)
 
UniversalBlobWriternewUniversalBlobWriter (const UniversalBlobURI &universalURI, const Unit &accuracyUnit=Units::NONE, const float accuracy=DataElement::NO_ACCURACY, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
UniversalDataReadernewUniversalReader (const UniversalURI &universalURI)
 
UniversalDataWriternewUniversalWriter (const UniversalURI &universalURI, const Unit &accuracyUnit=Units::NONE, const float accuracy=DataElement::NO_ACCURACY, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 

Protected Attributes

float headingIntegral_
 
float xteIntegral_
 
- Protected Attributes inherited from Component
Logger logger_
 
Syslog::Severity debugLevel_
 
ComponentState state_
 Keep track of whether the component has "completed" or should be run again. More...
 
Timespan desiredPeriod_
 
CodedStrname_
 Store the component's name (used for logging purposes) More...
 
Timestamp timeOfRun_
 
Timestamp timeOfLastRun_
 
Timespan durationOfLastRun_
 
Timespan dt_
 
Timespan retryTimeout_
 
bool enabled_
 
bool failureReported_
 Indicates if the failure has been reported – cuts down on syslog. More...
 
bool criticalFailureReported_
 Indicates if a "Critical" failure has been reported – cuts down on syslog. More...
 
bool recoveringFromCritical_
 Indicates that a component had a previous critical failure that has been cleared temporarily awaiting final word from the component itself. More...
 
bool failureUninitialized_
 Indicates if the failure has resulted in an uninitialize call. More...
 
int failCount_
 Number of failures logged by PCaller. More...
 
bool failureMissionCritical_
 If true (default), complete failure ends mission. More...
 
int allowableFailures_
 Number of failures allowed to occur. More...
 
int skippedRunsSinceFail_
 Number of skipped runs since failureMode_ set by failCount_. More...
 
FailureMode::FailType failureType_
 Failed status. If failCount_ > 0, then this may be reset. More...
 
Timestamp timeOfFailure_
 Time of last failure. Relevant only if failed=true. More...
 
Timestamp writeTimestamp_
 Time of last write. More...
 
FlexArray< DataReader * > readers_
 
FlexArray< DataWriter * > writers_
 
const Modulemodule_
 
Timespan pauseTime_
 
bool meteringEnabled_
 If true, metering is enabled. More...
 
DataWriterdurationOfLastRunWriter_
 Writer for durationOfLastRun. More...
 
DataWritervoltageWriter_
 
DataWriteravgVoltageWriter_
 
DataWritercurrentWriter_
 
DataWriteravgCurrentWriter_
 
bool persistentPause_
 True if data is persistent while component is paused. More...
 

Private Member Functions

 HorizontalControl (const HorizontalControl &old)
 
bool readConfig (void)
 read vehicle config variables More...
 
void controlHeading ()
 control heading More...
 
void setHeading (float desiredHeading, bool useInt=true)
 attempts to achieve the desired heading More...
 
void setHeadingRate (float desiredheadingRate)
 attempts to achieve the desired heading rate More...
 
void setRudderAngle (float desiredRudderAngle)
 attempts to achieve the desired rudder angle More...
 
float headingControl (float heading, float headingCmd, float yawRate, bool useInt=true)
 returns rudder angle More...
 

Private Attributes

Trajectory headingTrajectory_
 
bool ok_
 indicates whether things are ok to run More...
 
float kdHeading_
 *----------------— vehicle parameters -----------------------—*/ More...
 
float kiHeading_
 
float kpHeading_
 
float kwpHeading_
 
float kiwpHeading_
 
float maxKxte_
 
float maxHeadingInt_
 
float rudderLimit_
 
float headingRate_
 
float maxHeadingRateCfg_
 
float maxHdgAccel_
 
float xte_
 
float rudDeadband_
 
DataReaderhorizontalModeReader_
 Desired heading mode (none, waypoint, specified). More...
 
DataReaderlatitudeCmdReader_
 Desired waypoint latitude to head towards. More...
 
DataReaderlongitudeCmdReader_
 Desired waypoint longitude to head towards. More...
 
DataReaderbearingCmdReader_
 Bearing to the Desired waypoint. More...
 
DataReaderheadingCmdReader_
 Desired heading (radian) of the vehicle. More...
 
DataReaderheadingRateCmdReader_
 Desired yaw / heading change rate (radian/second). More...
 
DataReaderrudderAngleCmdReader_
 Desired rudder angle (radian). More...
 
ConfigReaderkdHeadingCfgReader_
 
ConfigReaderkiHeadingCfgReader_
 
ConfigReaderkpHeadingCfgReader_
 
ConfigReaderkwpHeadingCfgReader_
 
ConfigReaderkiwpHeadingCfgReader_
 
ConfigReadermaxHdgAccelCfgReader_
 
ConfigReadermaxHdgIntCfgReader_
 
ConfigReadermaxHdgRateCfgReader_
 
ConfigReadermaxKxteCfgReader_
 
ConfigReaderrudDeadbandCfgReader_
 
ConfigReaderrudLimitCfgReader_
 
UniversalDataReaderheadingReader_
 Current heading (radian) of the vehicle. More...
 
DataWriterheadingInternalWriter_
 Commanded heading angle in radians. More...
 
DataWritersmoothHeadingInternalWriter_
 Smoothed commanded heading angle in radians. More...
 
DataWriterheadingIntegralInternalWriter_
 Heading integral in radians. More...
 
DataWriterxteIntegralInternalWriter_
 
DataWriterxteInternalWriter_
 Cross-track error, meter. More...
 
DataWriterkxteInternalWriter_
 Cross-track error correction, radian. More...
 
DataWriterbearingInternalWriter_
 Commanded bearing, radians. In UTM coordinates, this should be a constant. More...
 
UniversalDataReaderheadingRateReader_
 Current yaw / heading change rate (radian/second). More...
 
UniversalDataReaderlatitudeReader_
 Current latitude. More...
 
UniversalDataReaderlongitudeReader_
 Current latitude. More...
 
UniversalDataReaderrudderAngleReader_
 
DataWriterrudderAngleActionWriter_
 Angle (in radian) of Elevator. More...
 
DataReaderrudderAngleActionReader_
 Used to read last action, even if from another source. More...
 

Additional Inherited Members

- Public Types inherited from Component
enum  ComponentState {
  BLOCK_CONTINUOUS, BLOCK_PERIODIC, BLOCK_NORMAL, BLOCK_COMPLETED,
  BLOCK_UNKNOWN
}
 In this model, the component has basically two states: wanting to run, and completed (no longer needing to run). More...
 
enum  ComponentType { COMPONENT_ASYNC, COMPONENT_CONFIG, COMPONENT_BEHAVIOR, COMPONENT_SYNC }
 Components can indicate how they want to be handled by their type. More...
 
enum  RunState {
  NO_RUN_STATE = 0, START, STARTING, RUNNABLE,
  SATISFIED, PAUSE, PAUSING, PAUSED,
  RESUME, RESUMING, RESETTING, STOP,
  STOPPING, STOPPED
}
 
- Static Public Attributes inherited from SyncComponent
static const int CYCLE_INCREMENT
 
static const int CYCLE_REPEAT_OFFSET
 
static const CycleOrder CYCLE_STARTER
 
static const CycleOrder CYCLE_SIMULATOR
 
static const CycleOrder CYCLE_SENSOR
 
static const CycleOrder CYCLE_DERIVATION
 
static const CycleOrder CYCLE_ESTIMATION
 
static const CycleOrder CYCLE_NAVIGATION
 
static const CycleOrder CYCLE_MISSION_MANAGER
 
static const CycleOrder CYCLE_MISSION
 
static const CycleOrder CYCLE_CONTROL
 
static const CycleOrder CYCLE_SERVO
 
static const CycleOrder CYCLE_TEST
 
static const CycleOrder CYCLE_REPORTER
 
static const CycleOrder CYCLE_LOGGER
 
- Protected Types inherited from Component
enum  ConfigOption { CONFIG_SIMULATE_HARDWARE, CONFIG_POWER, CONFIG_FREQUENCY, CONFIG_LATENCY }
 
- Protected Member Functions inherited from SyncControlComponent
 SyncControlComponent (const Str &name, const Module *module, int divisor=1, int modulo=0)
 
- Protected Member Functions inherited from SyncComponent
void setRepeater (bool repeater)
 
- Protected Member Functions inherited from Component
virtual ConfigURI getConfigURI (ConfigOption configOption) const
 Should return [myNamespace]::SIMULATE_HARDWARE, or [myNamespace]::POWER, etc. More...
 
virtual ConfigURI getConfigURI (ConfigOption configOption, ElementURI forElement) const
 Should return [myNamespace]::POWER_[forElement], [myNamespace]::LATENCY_[forElement], etc. More...
 
virtual void setDurationOfLastRun (const Timespan &span)
 
virtual void setTimeOfRun (const Timestamp &time)
 
virtual void setTimeOfLastRun (const Timestamp &time)
 
virtual void setDt (const Timespan &dt)
 
virtual bool setEnabled (bool enabled=true)
 
void setRunState (const RunState runState)
 
const Timespan getPauseTime () const
 
virtual void setFailureMissionCritical (bool failureMissionCritical)
 
bool simulateHardware ()
 

Detailed Description

This is the primary "control" for the vehicle's heading.

It accepts a number of inputs that specify the desired heading or waypoint for the vehicle, and combined with heading and rudder sensor inputs, converts the settings to commands that are ultimately relayed to devices via RudderServo.

HorizontalControl.h should only be included by HorizontalControl.cpp Other classes should include HorizontalControlIF.h

Constructor & Destructor Documentation

HorizontalControl::~HorizontalControl ( )
virtual
HorizontalControl::HorizontalControl ( const HorizontalControl old)
private

Member Function Documentation

void HorizontalControl::initialize ( void  )
virtual
void HorizontalControl::run ( void  )
virtual
void HorizontalControl::setHeading ( float  desiredHeading,
bool  useInt = true 
)
private
void HorizontalControl::setHeadingRate ( float  desiredheadingRate)
private

attempts to achieve the desired heading rate

References Timespan::asDouble(), dt, Component::dt_, headingReader_, AuvMath::NanZero(), Units::RADIAN, DataReader::read(), and setHeading().

Referenced by controlHeading().

void HorizontalControl::setRudderAngle ( float  desiredRudderAngle)
private

attempts to achieve the desired rudder angle

References Units::RADIAN, rudderAngleActionWriter_, and DataWriter::write().

Referenced by controlHeading(), and run().

void HorizontalControl::uninitialize ( void  )
virtual

Uninit function.

Reimplemented from Component.

References Component::logger_, and Logger::syslog().

Member Data Documentation

DataReader* HorizontalControl::bearingCmdReader_
private

Bearing to the Desired waypoint.

Only applies if horizontalModeReader_'s value is WAYPOINT Default is current location (no change).

Referenced by controlHeading(), and HorizontalControl().

DataWriter* HorizontalControl::bearingInternalWriter_
private

Commanded bearing, radians. In UTM coordinates, this should be a constant.

Referenced by controlHeading(), and HorizontalControl().

DataReader* HorizontalControl::headingCmdReader_
private

Desired heading (radian) of the vehicle.

Zero corresponds to true North, and PI/2 true East. (-PI <= Range < PI). Only applies if HorizontalMode value is HEADING Default is zero.

Referenced by controlHeading(), and HorizontalControl().

float HorizontalControl::headingIntegral_
protected

Referenced by headingControl().

DataWriter* HorizontalControl::headingIntegralInternalWriter_
private

Heading integral in radians.

Referenced by headingControl(), and HorizontalControl().

DataWriter* HorizontalControl::headingInternalWriter_
private

Commanded heading angle in radians.

Referenced by HorizontalControl(), and setHeading().

float HorizontalControl::headingRate_
private

Referenced by controlHeading(), and headingControl().

DataReader* HorizontalControl::headingRateCmdReader_
private

Desired yaw / heading change rate (radian/second).

Positive values correspond to positive changes in heading Applies to both waypoint and specified heading modes Default is 0.2 (to allow a ~15 second about-face)

Referenced by controlHeading(), and HorizontalControl().

UniversalDataReader* HorizontalControl::headingRateReader_
private

Current yaw / heading change rate (radian/second).

Positive values correspond to positive changes in heading

Referenced by HorizontalControl(), and setHeading().

UniversalDataReader* HorizontalControl::headingReader_
private

Current heading (radian) of the vehicle.

Zero corresponds to true North, and PI/2 true East. (-PI <= Range < PI).

Referenced by HorizontalControl(), setHeading(), and setHeadingRate().

Trajectory HorizontalControl::headingTrajectory_
private

Referenced by headingControl().

DataReader* HorizontalControl::horizontalModeReader_
private

Desired heading mode (none, waypoint, specified).

Default is NONE.

Referenced by controlHeading(), HorizontalControl(), and run().

float HorizontalControl::kdHeading_
private

*----------------— vehicle parameters -----------------------—*/

Referenced by headingControl(), and readConfig().

ConfigReader* HorizontalControl::kdHeadingCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

float HorizontalControl::kiHeading_
private

Referenced by headingControl(), and readConfig().

ConfigReader* HorizontalControl::kiHeadingCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

float HorizontalControl::kiwpHeading_
private

Referenced by controlHeading(), and readConfig().

ConfigReader* HorizontalControl::kiwpHeadingCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

float HorizontalControl::kpHeading_
private

Referenced by headingControl(), and readConfig().

ConfigReader* HorizontalControl::kpHeadingCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

float HorizontalControl::kwpHeading_
private

Referenced by controlHeading(), and readConfig().

ConfigReader* HorizontalControl::kwpHeadingCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

DataWriter* HorizontalControl::kxteInternalWriter_
private

Cross-track error correction, radian.

Referenced by controlHeading(), and HorizontalControl().

DataReader* HorizontalControl::latitudeCmdReader_
private

Desired waypoint latitude to head towards.

Only applies if horizontalModeReader_'s value is WAYPOINT Default is current location (no change).

Referenced by controlHeading(), HorizontalControl(), and initialize().

UniversalDataReader* HorizontalControl::latitudeReader_
private

Current latitude.

Referenced by controlHeading(), HorizontalControl(), and initialize().

DataReader* HorizontalControl::longitudeCmdReader_
private

Desired waypoint longitude to head towards.

Only applies if horizontalModeReader_'s value is WAYPOINT Default is current location (no change).

Referenced by controlHeading(), HorizontalControl(), and initialize().

UniversalDataReader* HorizontalControl::longitudeReader_
private

Current latitude.

Referenced by controlHeading(), HorizontalControl(), and initialize().

float HorizontalControl::maxHdgAccel_
private

Referenced by headingControl(), and readConfig().

ConfigReader* HorizontalControl::maxHdgAccelCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

ConfigReader* HorizontalControl::maxHdgIntCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

ConfigReader* HorizontalControl::maxHdgRateCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

float HorizontalControl::maxHeadingInt_
private

Referenced by headingControl(), and readConfig().

float HorizontalControl::maxHeadingRateCfg_
private

Referenced by controlHeading(), and readConfig().

float HorizontalControl::maxKxte_
private

Referenced by controlHeading(), and readConfig().

ConfigReader* HorizontalControl::maxKxteCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

bool HorizontalControl::ok_
private

indicates whether things are ok to run

Referenced by initialize(), and run().

float HorizontalControl::rudDeadband_
private

Referenced by readConfig(), and setHeading().

ConfigReader* HorizontalControl::rudDeadbandCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

DataReader* HorizontalControl::rudderAngleActionReader_
private

Used to read last action, even if from another source.

Referenced by HorizontalControl(), and setHeading().

DataWriter* HorizontalControl::rudderAngleActionWriter_
private

Angle (in radian) of Elevator.

Zero corresponds to aligned with major axis of vehicle. Nominal range is -PI/4 to PI/4.

Referenced by HorizontalControl(), setHeading(), and setRudderAngle().

DataReader* HorizontalControl::rudderAngleCmdReader_
private

Desired rudder angle (radian).

Positive values correspond to negative changes in heading Applies only to rudder angle heading mode

Referenced by controlHeading(), and HorizontalControl().

UniversalDataReader* HorizontalControl::rudderAngleReader_
private
float HorizontalControl::rudderLimit_
private
ConfigReader* HorizontalControl::rudLimitCfgReader_
private

Referenced by HorizontalControl(), and readConfig().

DataWriter* HorizontalControl::smoothHeadingInternalWriter_
private

Smoothed commanded heading angle in radians.

Referenced by headingControl(), and HorizontalControl().

float HorizontalControl::xte_
private

Referenced by controlHeading().

float HorizontalControl::xteIntegral_
protected

Referenced by controlHeading().

DataWriter* HorizontalControl::xteIntegralInternalWriter_
private
DataWriter* HorizontalControl::xteInternalWriter_
private

Cross-track error, meter.

Referenced by controlHeading(), and HorizontalControl().


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