Skip to content

Commit

Permalink
navigator_battery_monitor package migrated to ros2 (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihar3430 authored Mar 30, 2024
1 parent 9b7e703 commit c52711b
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
"""


import sys

import message_filters
import rospy
import rclpy
from roboteq_msgs.msg import Feedback, Status
from ros_alarms import AlarmListener
from ros_alarms_msgs.msg import Alarm
Expand Down Expand Up @@ -49,7 +51,7 @@ def __init__(self):
self._hw_kill_listener.wait_for_server()

# The publisher for the averaged voltage
self.pub_voltage = rospy.Publisher("/battery_monitor", Float32, queue_size=1)
self.pub_voltage = node.create_publisher(Float32, "/battery_monitor", 1)

# Subscribes to the feedback from each of the four thrusters
motor_topics = ["/FL_motor", "/FR_motor", "/BL_motor", "/BR_motor"]
Expand Down Expand Up @@ -117,7 +119,8 @@ def publish_voltage(self, _) -> None:


if __name__ == "__main__":
rospy.init_node("battery_monitor")
rclpy.init(args=sys.argv)
node = rclpy.create_node("battery_monitor")
monitor = BatteryMonitor()
rospy.Timer(rospy.Duration(1), monitor.publish_voltage, oneshot=False)
rospy.spin()
node.create_timer(1.0, monitor.publish_voltage)
rclpy.spin()

0 comments on commit c52711b

Please sign in to comment.