##

Battery.hh
Go to the documentation of this file.
/*
* Copyright (C) 2015 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_BATTERY_HH_
#define _GAZEBO_BATTERY_HH_
#include <map>
#include <string>
#include <functional>
#include <memory>
#include "sdf/sdf.hh"
#include "gazebo/common/CommonTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace common
{
// Forward declare private data class.
class BatteryPrivate;
class GZ_COMMON_VISIBLE Battery :
public std::enable_shared_from_this<Battery>
{
public: typedef std::map<uint32_t, double> PowerLoad_M;
public: explicit Battery();
public: virtual ~Battery();
public: virtual void Load(sdf::ElementPtr _sdf);
public: virtual void Init();
public: virtual void ResetVoltage();
public: virtual void UpdateParameters(const sdf::ElementPtr _sdf);
public: std::string Name() const;
public: uint32_t AddConsumer();
public: bool RemoveConsumer(const uint32_t _consumerId);
public: bool SetPowerLoad(const uint32_t _consumerId,
const double _powerLoad);
public: bool PowerLoad(const uint32_t _consumerId,
double &_powerLoad) const;
public: const PowerLoad_M &PowerLoads() const;
public: double Voltage() const;
public: void SetUpdateFunc(
std::function<double (const BatteryPtr &)> _updateFunc);
public: void Update();
protected: void InitConsumers();
private: double UpdateDefault(const BatteryPtr &_battery);
private: BatteryPrivate *dataPtr;
};
}
}
#endif
gazebo::common::Battery::Name
std::string Name() const
Return the name of the battery.
gazebo::common::Battery::ResetVoltage
virtual void ResetVoltage()
Reset the battery voltage to the initial value.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Battery::Load
virtual void Load(sdf::ElementPtr _sdf)
Load the battery.
gazebo::common::Battery::RemoveConsumer
bool RemoveConsumer(const uint32_t _consumerId)
Remove a consumer.
gazebo::common::Battery::~Battery
virtual ~Battery()
Destructor.
gazebo::common::Battery::SetUpdateFunc
void SetUpdateFunc(std::function< double(const BatteryPtr &)> _updateFunc)
Setup function to update voltage.
common
common
Definition: FuelModelDatabase.hh:37
system.hh
gazebo::common::Battery::PowerLoads
const PowerLoad_M & PowerLoads() const
Get list of power loads in watts.
CommonTypes.hh
gazebo::common::Battery::Init
virtual void Init()
Initialize.
gazebo::common::Battery::SetPowerLoad
bool SetPowerLoad(const uint32_t _consumerId, const double _powerLoad)
Set consumer power load in watts.
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::common::Battery
A battery abstraction.
Definition: Battery.hh:49
gazebo::common::Battery::UpdateParameters
virtual void UpdateParameters(const sdf::ElementPtr _sdf)
Update the parameters using new sdf values.
gazebo::common::BatteryPtr
std::shared_ptr< Battery > BatteryPtr
Definition: CommonTypes.hh:125
gazebo::common::Battery::PowerLoad_M
std::map< uint32_t, double > PowerLoad_M
Typedef the powerload map.
Definition: Battery.hh:54
gazebo::common::Battery::Battery
Battery()
Constructor.
gazebo::common::Battery::AddConsumer
uint32_t AddConsumer()
Create a unique consumer.
gazebo::common::Battery::InitConsumers
void InitConsumers()
Initialize the list of consumers.
gazebo::common::Battery::Voltage
double Voltage() const
Get the real voltage in volts.
gazebo::common::Battery::PowerLoad
bool PowerLoad(const uint32_t _consumerId, double &_powerLoad) const
Get consumer power load in watts.
gazebo::common::Battery::Update
void Update()
Update the battery.