2 from threading
import Lock
3 from wireless_msgs.msg
import Connection
as WirelessConnection
4 from sensor_msgs.msg
import BatteryState
8 WIRELESS_CONNECTION_TOPIC_NAME =
"/onboard_systems/wireless/connection"
10 BMS_ROOT_TOPIC_NAME =
"/onboard_systems/bms"
14 """Create ROS subscribers for Platform API topics and save the results."""
16 def __init__(self, num_bms=0, msg_warn_period=10.0):
17 """Subscribes for updates to the various platform topics
21 num_bms : int, optional
22 Number of BMS in the system (default is 0)
29 WIRELESS_CONNECTION_TOPIC_NAME,
36 for i
in range(num_bms):
37 topic = BMS_ROOT_TOPIC_NAME +
"/[%d]/state" % i
49 """Updates the wireless connection state.
53 msg : wireless_msgs.msg.Connection
54 The updated wireless connection state
62 """Updates the BMS state.
66 msg : sensor_msgs.msg.BatteryState
67 The updated battery state
70 The index of the BMS for the msg (in the case of multi-BMS systems)
79 """Check to see if messages have not been received within a certain amount of time"""
81 now = rospy.get_time()
88 """Logs all status information."""
91 rospy.loginfo(
" Platform:")
92 rospy.loginfo(
" Wireless connection: Bitrate %f Mbps; Link quality: %f" % (
95 rospy.loginfo(
" BMS[%d]: %f Volts" % (i, self.
_bms_state[i].voltage))