Public Types | Public Member Functions | Protected Member Functions | List of all members
gazebo::common::Battery Class Reference

A battery abstraction. More...

#include <Battery.hh>

Inheritance diagram for gazebo::common::Battery:
Inheritance graph
[legend]

Public Types

typedef std::map< uint32_t,
double > 
PowerLoad_M
 Typedef the powerload map. More...
 

Public Member Functions

 Battery ()
 Constructor. More...
 
virtual ~Battery ()
 Destructor. More...
 
uint32_t AddConsumer ()
 Create a unique consumer. More...
 
virtual void Init ()
 Initialize. More...
 
virtual void Load (sdf::ElementPtr _sdf)
 Load the battery. More...
 
std::string Name () const
 Return the name of the battery. More...
 
bool PowerLoad (const uint32_t _consumerId, double &_powerLoad) const
 Get consumer power load in watts. More...
 
const PowerLoad_MPowerLoads () const
 Get list of power loads in watts. More...
 
bool RemoveConsumer (const uint32_t _consumerId)
 Remove a consumer. More...
 
bool SetPowerLoad (const uint32_t _consumerId, const double _powerLoad)
 Set consumer power load in watts. More...
 
void SetUpdateFunc (std::function< double(const BatteryPtr &)> _updateFunc)
 Setup function to update voltage. More...
 
void Update ()
 Update the battery. More...
 
virtual void UpdateParameters (const sdf::ElementPtr _sdf)
 Update the parameters using new sdf values. More...
 
double Voltage () const
 Get the real voltage in volts. More...
 

Protected Member Functions

void InitConsumers ()
 Initialize the list of consumers. More...
 

Detailed Description

A battery abstraction.

The default battery model is ideal: It just takes the initial voltage value as its constant voltage value. This behavior can be changed by specifying a custom update function.

The battery handles a list of consumers. It updates itself after each simulation iteration. The update function takes the power loads for each consumer and current voltage value as inputs and returns a new voltage value.

Member Typedef Documentation

typedef std::map<uint32_t, double> gazebo::common::Battery::PowerLoad_M

Typedef the powerload map.

See Also
SetUpdateFunc

Constructor & Destructor Documentation

gazebo::common::Battery::Battery ( )
explicit

Constructor.

virtual gazebo::common::Battery::~Battery ( )
virtual

Destructor.

Member Function Documentation

uint32_t gazebo::common::Battery::AddConsumer ( )

Create a unique consumer.

Returns
Unique consumer identifier.
virtual void gazebo::common::Battery::Init ( )
virtual

Initialize.

void gazebo::common::Battery::InitConsumers ( )
protected

Initialize the list of consumers.

virtual void gazebo::common::Battery::Load ( sdf::ElementPtr  _sdf)
virtual

Load the battery.

Parameters
[in]_sdfShared point to an sdf element.
std::string gazebo::common::Battery::Name ( ) const

Return the name of the battery.

Returns
The name of the battery.
bool gazebo::common::Battery::PowerLoad ( const uint32_t  _consumerId,
double &  _powerLoad 
) const

Get consumer power load in watts.

Parameters
[in]_consumerIdUnique consumer identifier.
[out]_powerLoadPower load consumption in watts.
Returns
True if getting the power load consumption was successful.
const PowerLoad_M& gazebo::common::Battery::PowerLoads ( ) const

Get list of power loads in watts.

Returns
List of power loads in watts.
bool gazebo::common::Battery::RemoveConsumer ( const uint32_t  _consumerId)

Remove a consumer.

Parameters
[in]_consumerIdUnique consumer identifier.
Returns
True if the consumer was removed. False if the consumer id was not found.
bool gazebo::common::Battery::SetPowerLoad ( const uint32_t  _consumerId,
const double  _powerLoad 
)

Set consumer power load in watts.

Parameters
[in]_consumerIdUnique consumer identifier.
[in]_powerLoadPower load in watts.
Returns
True if setting the power load consumption was successful.
void gazebo::common::Battery::SetUpdateFunc ( std::function< double(const BatteryPtr &)>  _updateFunc)

Setup function to update voltage.

Parameters
[in]_updateFuncThe update function callback that is used to modify the battery's voltage. The parameter to the update function callback is a reference to an instance of Battery::UpdateData. The update function must return the new battery voltage as a double.
See Also
UpdateData
void gazebo::common::Battery::Update ( )

Update the battery.

This will in turn trigger the function set using the SetUpdateFunc function.

See Also
SetUpdateFunc.
virtual void gazebo::common::Battery::UpdateParameters ( const sdf::ElementPtr  _sdf)
virtual

Update the parameters using new sdf values.

Parameters
[in]_sdfSDF values to update from.
double gazebo::common::Battery::Voltage ( ) const

Get the real voltage in volts.

Returns
Voltage.

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