-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished BMS module, and added BMS node
- Loading branch information
1 parent
37594ec
commit 3884342
Showing
84 changed files
with
3,646 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
from sensor_msgs.msg import BatteryState | ||
from bms.freya_bms import BMS | ||
|
||
class FreyaBMSNode(Node): | ||
def __init__(self, usb_port=None) -> None: | ||
super().__init__('freya_bms') | ||
self._publisher = self.create_publisher(BatteryState, '/internal/status/bms', 10) | ||
self._timer = self.create_timer(2, self.publish_bms_data) | ||
|
||
if usb_port: | ||
self._bms_system = BMS(usb_port=usb_port) | ||
else: | ||
self._bms_system = BMS() | ||
|
||
def publish_bms_data(self): | ||
# print("mjau") | ||
battery_msg = BatteryState() | ||
|
||
self._bms_system.parse_bms_data(self._bms_system.get_bms_data()) | ||
|
||
battery_msg.voltage = self._bms_system.voltage | ||
battery_msg.current = self._bms_system.current | ||
battery_msg.cell_temperature = self._bms_system.temps | ||
battery_msg.percentage = self._bms_system.percent_capacity | ||
|
||
self._publisher.publish(battery_msg) | ||
# self.get_logger().info(f"Publishing voltage: {battery_msg.voltage}, current: {battery_msg.current}, cell_temperature: {battery_msg.cell_temperature}, percentage: {battery_msg.percentage}") | ||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
|
||
freya_bms_node = FreyaBMSNode() | ||
rclpy.spin(freya_bms_node) | ||
|
||
freya_bms_node.destroy_node() | ||
rclpy.shutdown() | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
isolated |
Empty file.
Oops, something went wrong.