Skip to content

Commit

Permalink
fixed some stuff and added launch file
Browse files Browse the repository at this point in the history
  • Loading branch information
PizzaAllTheWay committed Oct 22, 2023
1 parent 3884342 commit f1446ec
Show file tree
Hide file tree
Showing 76 changed files with 3,071 additions and 12 deletions.
10 changes: 5 additions & 5 deletions sensors/bms/bms/freya_bms.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, usb_port: str = None) -> None:
self._usb_port = usb_port
self._command = ["jbdtool", "-t", f"serial:/dev/{self._usb_port}"]
else:
print("Querying for USB devices...")
print("Looking for USB devices...")
devices = subprocess.check_output(["ls", "/dev"], text=True).split("\n")
usb_devices = [device for device in devices if device[:6] == "ttyUSB"]

Expand All @@ -70,7 +70,7 @@ def __init__(self, usb_port: str = None) -> None:

if i == len(usb_devices) - 1:
raise Exception("No USB device was found. Ensure that battery pack is connected to Raspberry Pi")

self._voltage = 0
self._current = 0
self._design_capacity = 0
Expand Down Expand Up @@ -198,7 +198,7 @@ def voltage(self):
def current(self):
return self._current

@property
@property
def design_capacity(self):
return self._design_capacity

Expand All @@ -219,11 +219,11 @@ def probes(self):
return self._probes

@property
def strings(self):
def strings(self):
return self._strings

@property
def temps(self):
def temps(self):
return self._temps

@property
Expand Down
29 changes: 24 additions & 5 deletions sensors/bms/bms/freya_bms_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,26 @@
from sensor_msgs.msg import BatteryState
from bms.freya_bms import BMS

# TODO: also publish ros2 Diagnostics message with BMS data

class FreyaBMSNode(Node):
def __init__(self, usb_port=None) -> None:
"""
Publishes Freya's BMS data to ROS.
Methods:
---------
publish_bms_data() -> None
publises BMS data from BMS system to ros2 node.
"""
def __init__(self, usb_port: str=None) -> None:
"""
Parameters:
usb_port(str): The USB port to look for BMS data from. If no port is
passed, the system automatically chooses the first port that gives
an output
Returns:
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)
Expand All @@ -14,8 +32,10 @@ def __init__(self, usb_port=None) -> None:
else:
self._bms_system = BMS()

def publish_bms_data(self):
# print("mjau")
def publish_bms_data(self) -> None:
"""
Publishes BMS data to ros2 node.
"""
battery_msg = BatteryState()

self._bms_system.parse_bms_data(self._bms_system.get_bms_data())
Expand All @@ -24,9 +44,8 @@ def publish_bms_data(self):
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)
Expand Down
18 changes: 18 additions & 0 deletions sensors/bms/install/bms/share/bms/launch/bms_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
return LaunchDescription([
Node(
package="bms",
namespace="/internal/status",
executable="talker",
name="bms1"
)
# Node(
# package="bms",
# namespace="/internal/status",
# executable="freya_bms_node",
# name="bms2"
# ),
])
18 changes: 18 additions & 0 deletions sensors/bms/launch/bms_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
return LaunchDescription([
Node(
package="bms",
namespace="/internal/status",
executable="talker",
name="bms1"
)
# Node(
# package="bms",
# namespace="/internal/status",
# executable="freya_bms_node",
# name="bms2"
# ),
])
2 changes: 2 additions & 0 deletions sensors/bms/log/build_2023-10-22_14-41-19/bms/command.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Invoking command in '/home/vortex/david_test_ws/vortex-asv/sensors/bms': PS1=${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[35m\]$(parse_git_branch)\[\033[00m\]\$ PYTHONPATH=/home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/prefix_override:/home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages:${PYTHONPATH} /usr/bin/python3 setup.py egg_info --egg-base build/bms build --build-base /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build install --record /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/install.log --single-version-externally-managed
Invoked command in '/home/vortex/david_test_ws/vortex-asv/sensors/bms' returned '0': PS1=${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[35m\]$(parse_git_branch)\[\033[00m\]\$ PYTHONPATH=/home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/prefix_override:/home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages:${PYTHONPATH} /usr/bin/python3 setup.py egg_info --egg-base build/bms build --build-base /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build install --record /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/install.log --single-version-externally-managed
2 changes: 2 additions & 0 deletions sensors/bms/log/build_2023-10-22_14-41-19/bms/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
30 changes: 30 additions & 0 deletions sensors/bms/log/build_2023-10-22_14-41-19/bms/stdout.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
running egg_info
writing build/bms/bms.egg-info/PKG-INFO
writing dependency_links to build/bms/bms.egg-info/dependency_links.txt
writing entry points to build/bms/bms.egg-info/entry_points.txt
writing requirements to build/bms/bms.egg-info/requires.txt
writing top-level names to build/bms/bms.egg-info/top_level.txt
reading manifest file 'build/bms/bms.egg-info/SOURCES.txt'
writing manifest file 'build/bms/bms.egg-info/SOURCES.txt'
running build
running build_py
copying bms/freya_bms_node.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
copying bms/freya_bms.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
copying bms/testfile.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
running install
running install_lib
copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/freya_bms_node.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/freya_bms.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/testfile.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/freya_bms_node.py to freya_bms_node.cpython-310.pyc
byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/freya_bms.py to freya_bms.cpython-310.pyc
byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/testfile.py to testfile.cpython-310.pyc
running install_data
creating /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/share/bms/launch
copying launch/bms_launch.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/share/bms/launch
running install_egg_info
removing '/home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms-0.0.0-py3.10.egg-info' (and everything under it)
Copying build/bms/bms.egg-info to /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms-0.0.0-py3.10.egg-info
running install_scripts
Installing talker script to /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/bms
writing list of installed files to '/home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/install.log'
32 changes: 32 additions & 0 deletions sensors/bms/log/build_2023-10-22_14-41-19/bms/stdout_stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
running egg_info
writing build/bms/bms.egg-info/PKG-INFO
writing dependency_links to build/bms/bms.egg-info/dependency_links.txt
writing entry points to build/bms/bms.egg-info/entry_points.txt
writing requirements to build/bms/bms.egg-info/requires.txt
writing top-level names to build/bms/bms.egg-info/top_level.txt
reading manifest file 'build/bms/bms.egg-info/SOURCES.txt'
writing manifest file 'build/bms/bms.egg-info/SOURCES.txt'
running build
running build_py
copying bms/freya_bms_node.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
copying bms/freya_bms.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
copying bms/testfile.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
running install
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running install_lib
copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/freya_bms_node.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/freya_bms.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/testfile.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/freya_bms_node.py to freya_bms_node.cpython-310.pyc
byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/freya_bms.py to freya_bms.cpython-310.pyc
byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/testfile.py to testfile.cpython-310.pyc
running install_data
creating /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/share/bms/launch
copying launch/bms_launch.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/share/bms/launch
running install_egg_info
removing '/home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms-0.0.0-py3.10.egg-info' (and everything under it)
Copying build/bms/bms.egg-info to /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms-0.0.0-py3.10.egg-info
running install_scripts
Installing talker script to /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/bms
writing list of installed files to '/home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/install.log'
34 changes: 34 additions & 0 deletions sensors/bms/log/build_2023-10-22_14-41-19/bms/streams.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[6.665s] Invoking command in '/home/vortex/david_test_ws/vortex-asv/sensors/bms': PS1=${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[35m\]$(parse_git_branch)\[\033[00m\]\$ PYTHONPATH=/home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/prefix_override:/home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages:${PYTHONPATH} /usr/bin/python3 setup.py egg_info --egg-base build/bms build --build-base /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build install --record /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/install.log --single-version-externally-managed
[9.039s] running egg_info
[9.061s] writing build/bms/bms.egg-info/PKG-INFO
[9.063s] writing dependency_links to build/bms/bms.egg-info/dependency_links.txt
[9.065s] writing entry points to build/bms/bms.egg-info/entry_points.txt
[9.066s] writing requirements to build/bms/bms.egg-info/requires.txt
[9.067s] writing top-level names to build/bms/bms.egg-info/top_level.txt
[9.071s] reading manifest file 'build/bms/bms.egg-info/SOURCES.txt'
[9.095s] writing manifest file 'build/bms/bms.egg-info/SOURCES.txt'
[9.097s] running build
[9.098s] running build_py
[9.100s] copying bms/freya_bms_node.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
[9.102s] copying bms/freya_bms.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
[9.106s] copying bms/testfile.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms
[9.110s] running install
[9.114s] /usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
[9.115s] warnings.warn(
[9.122s] running install_lib
[9.133s] copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/freya_bms_node.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
[9.136s] copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/freya_bms.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
[9.140s] copying /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build/lib/bms/testfile.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms
[9.147s] byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/freya_bms_node.py to freya_bms_node.cpython-310.pyc
[9.154s] byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/freya_bms.py to freya_bms.cpython-310.pyc
[9.170s] byte-compiling /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms/testfile.py to testfile.cpython-310.pyc
[9.175s] running install_data
[9.181s] creating /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/share/bms/launch
[9.182s] copying launch/bms_launch.py -> /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/share/bms/launch
[9.184s] running install_egg_info
[9.199s] removing '/home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms-0.0.0-py3.10.egg-info' (and everything under it)
[9.204s] Copying build/bms/bms.egg-info to /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages/bms-0.0.0-py3.10.egg-info
[9.233s] running install_scripts
[9.445s] Installing talker script to /home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/bms
[9.460s] writing list of installed files to '/home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/install.log'
[9.680s] Invoked command in '/home/vortex/david_test_ws/vortex-asv/sensors/bms' returned '0': PS1=${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[35m\]$(parse_git_branch)\[\033[00m\]\$ PYTHONPATH=/home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/prefix_override:/home/vortex/david_test_ws/vortex-asv/sensors/bms/install/bms/lib/python3.10/site-packages:${PYTHONPATH} /usr/bin/python3 setup.py egg_info --egg-base build/bms build --build-base /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/build install --record /home/vortex/david_test_ws/vortex-asv/sensors/bms/build/bms/install.log --single-version-externally-managed
Loading

0 comments on commit f1446ec

Please sign in to comment.