18 #include <gazebo/plugins/LinearBatteryPlugin.hh> 19 #include <gazebo/physics/Model.hh> 20 #include <gazebo/common/Plugin.hh> 42 LinearBatteryPlugin::Load(_parent, _sdf);
44 catch(common::Exception &_e)
46 gzerr <<
"Error loading plugin." 47 <<
"Please ensure that your model is correct." 54 gzerr <<
"Not loading plugin since ROS has not been " 55 <<
"properly initialized. Try starting gazebo with ros plugin:\n" 56 <<
" gazebo -s libgazebo_ros_api_plugin.so\n";
60 if (_sdf->HasElement(
"namespace"))
63 double updateRate = 2;
64 if (_sdf->HasElement(
"update_rate"))
65 updateRate = _sdf->Get<
double>(
"update_rate");
67 if (updateRate <= 0.0)
69 gzmsg <<
"Invalid update rate, setting it to 2 Hz, rate=" << updateRate
82 gzmsg <<
"ROS Battery Plugin for link <" << this->link->GetName()
84 <<
"\t- Initial charge [Ah]=" << this->q0 <<
'\n' 85 <<
"\t- Update rate [Hz]=" << updateRate
101 sensor_msgs::BatteryState::POWER_SUPPLY_STATUS_DISCHARGING;
103 sensor_msgs::BatteryState::POWER_SUPPLY_HEALTH_GOOD;
105 sensor_msgs::BatteryState::POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
115 LinearBatteryPlugin::Init();
121 LinearBatteryPlugin::Reset();
LinearBatteryROSPlugin()
Constructor.
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL bool isInitialized()
GZ_REGISTER_MODEL_PLUGIN(UmbilicalPlugin)
ros::Publisher batteryStatePub
Publisher for the dynamic state efficiency.
void PublishBatteryState()
Publish battery states.
virtual void Reset()
Reset Module.
sensor_msgs::BatteryState batteryStateMsg
Battery state ROS message.
virtual void Init()
Initialize Module.
void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
Load module and read parameters from SDF.
std::string robotNamespace
Namespace for this ROS node.
virtual ~LinearBatteryROSPlugin()
Destructor.
boost::scoped_ptr< ros::NodeHandle > rosNode
Pointer to this ROS node's handle.
ros::Timer updateTimer
Connection for callbacks on update world.