DUNE: Uniform Navigational Environment  2.4.2
Monitors::FuelLevel::Task Struct Reference

Public Member Functions

 Task (const std::string &name, Tasks::Context &ctx)
 
void onUpdateParameters (void)
 
void onResourceRelease (void)
 
void onResourceAcquisition (void)
 
void onEntityResolution (void)
 
void consume (const IMC::Voltage *msg)
 
void consume (const IMC::Current *msg)
 
void consume (const IMC::Temperature *msg)
 
void consume (const IMC::VehicleState *msg)
 
float getDeviationFromModel (const Models model)
 
float getDeviationMergedModel (const MergedModels model)
 
float getModelEstimate (const Models model)
 
float getModelEstimate (const Models model, float voltage)
 
Models getClosestModel (float temperature)
 
float getMapEstimate (const Models model, float current)
 
float getInvertedEstimate (const Models model, float energy)
 
float getMergedEstimate (const MergedModels model, float current, float temperature)
 
float getMergedEstimate (const MergedModels model)
 
float getRemainingTime (float power_rate)
 
float computeInitialEstimate (void)
 
float computeConfidence (float energy)
 
float computeConfidence (void)
 
void task (void)
 
- Public Member Functions inherited from DUNE::Tasks::Periodic
 Periodic (const std::string &name, Context &ctx)
 
virtual ~Periodic (void)
 
void setFrequency (double freq)
 
double getFrequency (void) const
 
double getRunTime (void) const
 
unsigned getRunCount (void) const
 
- Public Member Functions inherited from DUNE::Tasks::Task
 Task (const std::string &name, Context &context)
 
virtual ~Task (void)
 
const char * getName (void) const
 
const char * getSystemName (void) const
 
unsigned int getSystemId (void) const
 
unsigned int getEntityId (void) const
 
uint16_t getActivationTime (void) const
 
uint16_t getDeactivationTime (void) const
 
unsigned int resolveSystemName (const std::string &name) const
 
const char * resolveSystemId (unsigned int id) const
 
void loadConfig (void)
 
void setPriority (unsigned int value)
 
unsigned int getPriority (void) const
 
void inf (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void war (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void err (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void cri (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void void debug (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void void void trace (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void void void void spew (const char *format,...) DUNE_PRINTF_FORMAT(2
 
void void void void void void
void void 
dispatch (IMC::Message *msg, unsigned int flags=0)
 
void dispatch (IMC::Message &msg, unsigned int flags=0)
 
void dispatchReply (const IMC::Message &original, IMC::Message &msg, unsigned int flags=0)
 
void receive (const IMC::Message *msg)
 
void reserveEntities (void)
 
void resolveEntities (void)
 
void acquireResources (void)
 
void releaseResources (void)
 
void initializeResources (void)
 
void updateParameters (bool act_deact=true)
 
void writeParamsXML (std::ostream &os) const
 
- Public Member Functions inherited from DUNE::Tasks::AbstractTask
 AbstractTask (void)
 
virtual ~AbstractTask (void)
 
- Public Member Functions inherited from DUNE::Concurrency::Thread
 Thread (void)
 
virtual ~Thread (void)
 
int getProcessorUsage (void)
 
- Public Member Functions inherited from DUNE::Concurrency::Runnable
 Runnable (void)
 
virtual ~Runnable (void)
 
void start (void)
 
void stop (void)
 
void join (void)
 
void stopAndJoin (void)
 
void setPriority (Scheduler::Policy policy, unsigned priority)
 
State getState (void)
 
bool isCreated (void)
 
bool isStopping (void)
 
bool isRunning (void)
 
bool isStarting (void)
 
bool isDead (void)
 

Public Attributes

BatteryDatam_bdata
 
IMC::FuelLevel m_fuel
 
float m_energy_consumed
 
bool m_has_initial_estimate
 
float m_initial_estimate
 
double m_last_time
 
unsigned m_total_samples
 
bool m_cold_estimate
 
bool m_redid_estimate
 
unsigned m_eids [BatteryData::BM_TOTAL]
 
Time::Counter< float > m_sane_timer
 
bool m_is_maneuvering
 
Arguments m_args
 

Additional Inherited Members

- Public Types inherited from DUNE::Concurrency::Runnable
enum  State {
  StateStarting, StateRunning, StateStopping, StateDead,
  StateUnknown
}
 
- Protected Member Functions inherited from DUNE::Tasks::Task
const char * getEntityLabel (void) const
 
void setEntityLabel (const std::string &label)
 
void setEntityState (IMC::EntityState::StateEnum state, Status::Code code)
 
void setEntityState (IMC::EntityState::StateEnum state, const std::string &description)
 
IMC::EntityState::StateEnum getEntityState (void) const
 
unsigned int reserveEntity (const std::string &label)
 
unsigned int resolveEntity (const std::string &label) const
 
std::string resolveEntity (unsigned int id) const
 
bool stopping (void)
 
bool isActive (void) const
 
void waitForMessages (double timeout)
 
void consumeMessages (void)
 
template<typename T >
Parameterparam (const std::string &name, T &var)
 
template<typename Y , typename T >
Parameterparam (const std::string &name, T &var)
 
template<typename T >
bool paramChanged (T &var)
 
void paramActive (Parameter::Scope def_scope, Parameter::Visibility def_visibility, bool def_value=false)
 
void setParamSectionEditor (const std::string &name)
 
template<typename M , typename T >
void bind (T *task_obj, void(T::*consumer)(const M *)=&T::consume)
 
template<typename T >
void bind (T *task_obj, const std::vector< uint32_t > &list)
 
template<typename T >
void bind (T *task_obj, const std::vector< std::string > &list)
 
void requestActivation (void)
 
void requestDeactivation (void)
 
void activate (void)
 
void activationFailed (const std::string &reason)
 
void deactivate (void)
 
void deactivationFailed (const std::string &reason)
 
virtual void onEntityReservation (void)
 
virtual void onReportEntityState (void)
 
virtual void onResourceInitialization (void)
 
virtual void onRequestActivation (void)
 
virtual void onRequestDeactivation (void)
 
virtual void onActivation (void)
 
virtual void onDeactivation (void)
 
- Protected Member Functions inherited from DUNE::Concurrency::Thread
void startImpl (void)
 
void stopImpl (void)
 
void joinImpl (void)
 
void setPriorityImpl (Scheduler::Policy policy, unsigned priority)
 
- Protected Attributes inherited from DUNE::Tasks::Task
Contextm_ctx
 

Constructor & Destructor Documentation

Member Function Documentation

float Monitors::FuelLevel::Task::computeConfidence ( float  energy)
inline

Compute a rough estimate of the confidence on the measure of energy (in %)

Parameters
[in]energyto use
Returns
value of confidence computed

References Monitors::FuelLevel::Arguments::full_capacity, getMergedEstimate(), getModelEstimate(), m_args, Monitors::FuelLevel::MDL_OPT, Monitors::FuelLevel::MDL_PES, Monitors::FuelLevel::MGD_RATED, and DUNE::Math::piecewiseLI().

float Monitors::FuelLevel::Task::computeConfidence ( void  )
inline

Compute a rough estimate of the confidence on the measure of energy (in %)

Returns
value of confidence computed

References m_energy_consumed, and m_initial_estimate.

Referenced by task().

void Monitors::FuelLevel::Task::consume ( const IMC::Current *  msg)
inline
void Monitors::FuelLevel::Task::consume ( const IMC::Temperature *  msg)
inline
void Monitors::FuelLevel::Task::consume ( const IMC::VehicleState *  msg)
inline

References m_is_maneuvering, and m_sane_timer.

Models Monitors::FuelLevel::Task::getClosestModel ( float  temperature)
inline

Find closest model to a certain temperature.

Parameters
[in]temperaturetemperature value to use
Returns
closest model to the given temperature

References m_args, Monitors::FuelLevel::MDL_TOTAL, Monitors::FuelLevel::Arguments::models, and Monitors::FuelLevel::BatteryModel::temp.

Referenced by getMergedEstimate().

float Monitors::FuelLevel::Task::getDeviationFromModel ( const Models  model)
inline

Compute deviation from model.

Parameters
[in]modelmodel to be used to compute deviation
Returns
deviation from given model

References getModelEstimate(), m_energy_consumed, and m_initial_estimate.

Referenced by task().

float Monitors::FuelLevel::Task::getDeviationMergedModel ( const MergedModels  model)
inline

Compute deviation from a merged model.

Parameters
[in]modelmerged model to be used to compute deviation
Returns
deviation from given merged model

References getMergedEstimate(), m_energy_consumed, and m_initial_estimate.

Referenced by task().

float Monitors::FuelLevel::Task::getInvertedEstimate ( const Models  model,
float  energy 
)
inline

Compute voltage using energy value.

This works as an inverted getModelEstimate().

Parameters
[in]modelmodel to be used in compute the estimate
[in]energyenergy value to interpolate with to find voltage.
Returns
computed voltage value by interpolation

References Monitors::FuelLevel::BatteryModel::energy, m_args, Monitors::FuelLevel::Arguments::models, DUNE::Math::piecewiseLI(), and Monitors::FuelLevel::BatteryModel::voltage.

Referenced by getMapEstimate().

float Monitors::FuelLevel::Task::getMapEstimate ( const Models  model,
float  current 
)
inline

Compute estimate for temperature map merged model.

Parameters
[in]modeltemperature model to use
[in]currentelectric current value to use in estimate
Returns
estimate for the cold map merged model

References Monitors::FuelLevel::BatteryModel::current, getInvertedEstimate(), getModelEstimate(), Monitors::FuelLevel::BatteryData::getVoltage(), m_args, m_bdata, Monitors::FuelLevel::MDL_OPT, Monitors::FuelLevel::MDL_PES, and Monitors::FuelLevel::Arguments::models.

Referenced by getMergedEstimate().

float Monitors::FuelLevel::Task::getMergedEstimate ( const MergedModels  model,
float  current,
float  temperature 
)
inline
float Monitors::FuelLevel::Task::getMergedEstimate ( const MergedModels  model)
inline

Compute a merged estimate using an electric current value (overload)

Parameters
[in]modelmerged model to use
Returns
merged estimate value

References Monitors::FuelLevel::BatteryData::getCurrent(), getMergedEstimate(), Monitors::FuelLevel::BatteryData::getTemperature(), and m_bdata.

float Monitors::FuelLevel::Task::getModelEstimate ( const Models  model)
inline

Compute an estimate based on a current discharge model.

Parameters
[in]modelmodel to be used in computing the estimate
Returns
estimate computed

References Monitors::FuelLevel::BatteryData::getVoltage(), and m_bdata.

Referenced by computeConfidence(), computeInitialEstimate(), getDeviationFromModel(), getMapEstimate(), getMergedEstimate(), and task().

float Monitors::FuelLevel::Task::getModelEstimate ( const Models  model,
float  voltage 
)
inline

Compute an estimate based on a current discharge model.

Parameters
[in]modelmodel to be used in computing the estimate
[in]voltagevoltage to be used in optimistic and pessimistic model
Returns
estimate computed

References Monitors::FuelLevel::BatteryModel::energy, m_args, Monitors::FuelLevel::Arguments::models, DUNE::Math::piecewiseLI(), and Monitors::FuelLevel::BatteryModel::voltage.

float Monitors::FuelLevel::Task::getRemainingTime ( float  power_rate)
inline

Estimate likely time left for operation in a certain power regime for available energy left in batteries.

Parameters
[in]power_raterate of power consumption
Returns
remaining time at consumption rate

References m_energy_consumed, and m_initial_estimate.

void Monitors::FuelLevel::Task::onEntityResolution ( void  )
inlinevirtual

Called when the task is instructed to resolve all the entity identifiers it needs for normal execution.

See resolveEntity(). Derived classes that need to resolve entity identifiers should override this function.

Reimplemented from DUNE::Tasks::Task.

References Monitors::FuelLevel::BatteryData::BM_TOTAL, Monitors::FuelLevel::Arguments::elb, m_args, m_eids, and DUNE::Tasks::Task::resolveEntity().

void Monitors::FuelLevel::Task::onResourceAcquisition ( void  )
inlinevirtual

Called when the task is instructed to acquire resources whose configuration is defined by run-time parameters.

Reimplemented from DUNE::Tasks::Task.

References Monitors::FuelLevel::Arguments::avg_win, m_args, m_bdata, m_eids, and Monitors::FuelLevel::BatteryData::setEntities().

void Monitors::FuelLevel::Task::onResourceRelease ( void  )
inlinevirtual

Called when the task is instructed to release resources.

Derived classes that override this function must not assume that any resource was previously acquired. This function must be implemented in such a way that it can be called at any time.

Reimplemented from DUNE::Tasks::Task.

References m_bdata.

void Monitors::FuelLevel::Task::onUpdateParameters ( void  )
inlinevirtual

Called when the task is instructed to update its run-time parameters.

Derived classes that need to compute auxiliary values based on run-time parameters should override this function.

Reimplemented from DUNE::Tasks::Task.

References Monitors::FuelLevel::Arguments::decay_factor, Monitors::FuelLevel::BatteryModel::energy, DUNE::Tasks::Task::err(), m_args, Monitors::FuelLevel::MDL_TOTAL, Monitors::FuelLevel::Arguments::models, Monitors::FuelLevel::Arguments::op_labels, Monitors::FuelLevel::Arguments::op_values, DUNE::Tasks::Task::paramChanged(), and Monitors::FuelLevel::BatteryModel::voltage.

Member Data Documentation

BatteryData* Monitors::FuelLevel::Task::m_bdata
bool Monitors::FuelLevel::Task::m_cold_estimate

Present estimate was performed in cold temperatures.

Referenced by computeInitialEstimate(), and task().

unsigned Monitors::FuelLevel::Task::m_eids[BatteryData::BM_TOTAL]

Array of entities.

Referenced by onEntityResolution(), and onResourceAcquisition().

float Monitors::FuelLevel::Task::m_energy_consumed

Estimated amount of energy consumed in Wh since the task started.

Referenced by computeConfidence(), consume(), getDeviationFromModel(), getDeviationMergedModel(), getRemainingTime(), and task().

IMC::FuelLevel Monitors::FuelLevel::Task::m_fuel

Fuel level message.

Referenced by task().

bool Monitors::FuelLevel::Task::m_has_initial_estimate

Do we have an initial estimate.

Referenced by task().

float Monitors::FuelLevel::Task::m_initial_estimate

Initial estimate of energy left in the batteries.

Referenced by computeConfidence(), getDeviationFromModel(), getDeviationMergedModel(), getRemainingTime(), and task().

bool Monitors::FuelLevel::Task::m_is_maneuvering

True if maneuvering. Start as true.

Referenced by consume(), and task().

double Monitors::FuelLevel::Task::m_last_time

Last energy computation time.

Referenced by consume().

bool Monitors::FuelLevel::Task::m_redid_estimate

Redo estimate only once.

Referenced by task().

Time::Counter<float> Monitors::FuelLevel::Task::m_sane_timer

Timer Counter for stabilization time after maneuvering.

Referenced by consume(), and task().

unsigned Monitors::FuelLevel::Task::m_total_samples

Total number of measurement samples got so far.

Referenced by consume(), and task().

Collaboration diagram for Monitors::FuelLevel::Task:
Collaboration graph