Skip to content

Commit

Permalink
Added new topic for charge state in mwh
Browse files Browse the repository at this point in the history
  • Loading branch information
pooyanjamshidi committed Apr 24, 2018
1 parent c67ebb4 commit 70199d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/battery_discharge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void BatteryPlugin::Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
// Publish a topic for motor power and charge level
this->motor_power = this->rosNode->advertise<kobuki_msgs::MotorPower>("/mobile_base/commands/motor_power", 1);
this->charge_state = this->rosNode->advertise<std_msgs::Float64>("/mobile_base/commands/charge_level", 1);
this->charge_state_mwh = this->rosNode->advertise<std_msgs::Float64>("/mobile_base/commands/charge_level_mwh", 1);

this->set_charging = this->rosNode->advertiseService(this->model->GetName() + "/set_charging", &BatteryPlugin::SetCharging, this);
this->set_charging_rate = this->rosNode->advertiseService(this->model->GetName() + "/set_charge_rate", &BatteryPlugin::SetChargingRate, this);
Expand Down Expand Up @@ -195,10 +196,13 @@ double BatteryPlugin::OnUpdateVoltage(const common::BatteryPtr &_battery)
this->q = this->c;
}

std_msgs::Float64 charge_msg;
std_msgs::Float64 charge_msg, charge_msg_mwh;
charge_msg.data = this->q;
charge_msg_mwh.data = this->q * 1000 * this-> et;

lock.lock();
this->charge_state.publish(charge_msg);
this->charge_state_mwh.publish(charge_msg_mwh);
lock.unlock();

return et;
Expand Down
1 change: 1 addition & 0 deletions src/battery_discharge.hh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace gazebo
protected: std::unique_ptr<ros::NodeHandle> rosNode;

protected: ros::Publisher charge_state;
protected: ros::Publisher charge_state_mwh;
protected: ros::Publisher motor_power;

protected: ros::ServiceServer set_charging;
Expand Down

0 comments on commit 70199d2

Please sign in to comment.