Add battery_state_broadcaster - #2086
Conversation
Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
…et_dependencies Replace ament_target_dependencies with target_link_libraries
Don't make a temporary copy of semantic component
Recent commit in realtime_tools [1] causes the following compilation
failure:
battery_state_broadcaster/src/BatteryStateBroadcaster.cpp:28:24:
error: ‘sensor_msgs::msg::BatteryState_<std::allocator<void> >
realtime_tools::RealtimePublisher<sensor_msgs::msg::BatteryState_<std::allocator<void>
> >::msg_’ is private within this context
This commit fixes that.
[1]: ros-controls/realtime_tools@9e26e41
Fix compile error with latest realtime_tools
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2086 +/- ##
==========================================
- Coverage 86.85% 86.82% -0.03%
==========================================
Files 148 152 +4
Lines 16267 16656 +389
Branches 1367 1411 +44
==========================================
+ Hits 14128 14462 +334
- Misses 1632 1656 +24
- Partials 507 538 +31
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@christophfroehlich are there any further plans for this? |
|
Please have a look in #1888 and leave your review there. |
|
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
and rename member variables
| for (size_t i = 0; i < params_.batteries.size(); ++i) | ||
| { | ||
| const auto & interfaces = params_.interfaces.batteries_map.at(params_.batteries.at(i)); | ||
|
|
||
| raw_battery_states_msg_.battery_states[i].header.stamp = time; | ||
|
|
||
| raw_battery_states_msg_.battery_states[i].voltage = static_cast<float>( | ||
| state_interfaces_[interface_cnt].get_optional<double>().value_or(kUninitializedValue)); | ||
| sums_.voltage_sum += raw_battery_states_msg_.battery_states[i].voltage; | ||
| interface_cnt++; | ||
|
|
||
| if (interfaces.battery_temperature) | ||
| { | ||
| raw_battery_states_msg_.battery_states[i].temperature = static_cast<float>( | ||
| state_interfaces_[interface_cnt].get_optional<double>().value_or(kUninitializedValue)); |
There was a problem hiding this comment.
In the math here, I've a question, what if one of the battery doesn't have the interface, then we are summing NaN and resulting in the bad mean right?
There was a problem hiding this comment.
But interfaces.battery_temperature only is true if the interface exists?
There was a problem hiding this comment.
What I mean is, what if it might be true for some of the batteries but not each of them?
There was a problem hiding this comment.
interfaces is a map with an entry for every battery?
There was a problem hiding this comment.
that's what I mean: If it is not available for certain batteries and configured properly, than it won't accumulate NaN here?
Co-authored-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>
Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com> Co-authored-by: Jonas Otto <jonas.otto@ipa.fraunhofer.de> Co-authored-by: Alejandro Hernandez Cordero <ahcorde@gmail.com> Co-authored-by: Jonas Otto <jonas@jonasotto.com> Co-authored-by: Michal Sojka <michal.sojka@cvut.cz> Co-authored-by: Yara Shahin <58101871+YaraShahin@users.noreply.github.com> Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com> Co-authored-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>
Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com> Co-authored-by: Jonas Otto <jonas.otto@ipa.fraunhofer.de> Co-authored-by: Alejandro Hernandez Cordero <ahcorde@gmail.com> Co-authored-by: Jonas Otto <jonas@jonasotto.com> Co-authored-by: Michal Sojka <michal.sojka@cvut.cz> Co-authored-by: Yara Shahin <58101871+YaraShahin@users.noreply.github.com> Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com> Co-authored-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>

This moves https://github.com/ipa320/ros_battery_monitoring/tree/main/battery_state_broadcaster to our repository.
For discsussion about this, see #1888 and especially #1888 (comment)