Skip to content

Commit

Permalink
Merge pull request #8 from HarvestX/feat/ampere-check
Browse files Browse the repository at this point in the history
check if current is negative
  • Loading branch information
m12watanabe1a authored Oct 31, 2023
2 parents aa64515 + 8092a23 commit 386dee4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions battery_state_broadcaster/src/battery_state_broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ controller_interface::return_type BatteryStateBroadcaster::update(
if (this->realtime_publisher_ && this->realtime_publisher_->trylock()) {
this->realtime_publisher_->msg_.header.set__stamp(time);
this->battery_state_->get_value_as_message(this->realtime_publisher_->msg_);

this->realtime_publisher_->msg_.power_supply_status =
this->realtime_publisher_->msg_.current < 0.0 ?
sensor_msgs::msg::BatteryState::POWER_SUPPLY_STATUS_DISCHARGING :
sensor_msgs::msg::BatteryState::POWER_SUPPLY_STATUS_CHARGING;

this->realtime_publisher_->unlockAndPublish();
}

Expand Down

0 comments on commit 386dee4

Please sign in to comment.