diagnostics.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from std_msgs.msg import String, Bool
5 from nav_msgs.msg import Odometry
6 from rr_openrover_driver_msgs.msg import RawRrOpenroverDriverSlowRateData, RawRrOpenroverDriverMedRateData, SmartBatteryStatus
7 
8 
10 
11  def __init__(self):
12  self.pub = rospy.Publisher('/inorbit/custom_data/0', String, queue_size=5)
13  rospy.Subscriber("/raw_slow_rate_data", RawRrOpenroverDriverSlowRateData, self.slow_data_cb)
14  rospy.Subscriber("/rr_openrover_driver/raw_med_rate_data", RawRrOpenroverDriverMedRateData, self.med_data_cb)
15  rospy.Subscriber("/rr_openrover_driver/battery_status_a", SmartBatteryStatus, self.battery_status_a_cb)
16  rospy.Subscriber("/rr_openrover_driver/battery_status_b", SmartBatteryStatus, self.battery_status_b_cb)
17  rospy.Subscriber('/rr_openrover_driver/charging', Bool, self.openrover_charging_cb)
18 
19  def slow_data_cb(self, data):
20  warn_msg = "Battery Levels [" + str(data.reg_robot_rel_soc_a) + ", " + str(
21  data.reg_robot_rel_soc_b) + "] Motor temps [" + str(data.reg_motor_temp_left) + ", " + str(
22  data.reg_motor_temp_right) + "]"
23  # rospy.logwarn_throttle(60,warn_msg)
24 
25  self.pub.publish("Battery Cell 1 SOC=" + str(data.reg_robot_rel_soc_a))
26  self.pub.publish("Battery Cell 2 SOC=" + str(data.reg_robot_rel_soc_b))
27  self.pub.publish("Left Motor Temp=" + str(data.reg_motor_temp_left))
28  self.pub.publish("Right Motor Temp=" + str(data.reg_motor_temp_right))
29  self.pub.publish("Battery Mode A=" + str(data.battery_mode_a))
30  self.pub.publish("Battery Mode B=" + str(data.battery_mode_b))
31  self.pub.publish("Battery Temp A=" + str((data.battery_temp_a/10)-273))
32  self.pub.publish("Battery Temp B=" + str((data.battery_temp_b/10)-273))
33  self.pub.publish("Power Bat Voltage A=" + str(data.reg_power_bat_voltage_a/58.33))
34  self.pub.publish("Power Bat Voltage B=" + str(data.reg_power_bat_voltage_b/58.33))
35  self.pub.publish("Battery Voltage A=" + str(data.battery_voltage_a/1000))
36  self.pub.publish("Battery Voltage B=" + str(data.battery_voltage_b/1000))
37 
38  def med_data_cb(self, data):
39  self.pub.publish("Motor Feedback Current Left=" + str(data.reg_motor_fb_current_left))
40  self.pub.publish("Motor Feedback Current Right=" + str(data.reg_motor_fb_current_right))
41  self.pub.publish("Power A Current=" + str(data.reg_power_a_current))
42  self.pub.publish("Power B Current=" + str(data.reg_power_b_current))
43  self.pub.publish("Battery Current A=" + str(data.battery_current_a))
44  self.pub.publish("Battery Current B=" + str(data.battery_current_b))
45 
46  def battery_status_a_cb(self, msg):
47  for k in type(msg).__slots__:
48  if k != 'header':
49  self.pub.publish("Battery Status A." + k + '=' + str(int(getattr(msg, k))))
50 
51  def battery_status_b_cb(self, msg):
52  for k in type(msg).__slots__:
53  if k != 'header':
54  self.pub.publish("Battery Status B." + k + '=' + str(int(getattr(msg, k))))
55 
56 
57  def openrover_charging_cb(self, msg):
58  self.pub.publish("Open Rover Charging=" + str(msg.data))
59 
60 
61 if __name__ == '__main__':
62  rospy.loginfo("Starting node")
63  rospy.init_node('openrover_diagnostics_node')
64 
65  my_diagnostic = rover_diagnostic()
66  rospy.spin()
def battery_status_b_cb(self, msg)
Definition: diagnostics.py:51
def slow_data_cb(self, data)
Definition: diagnostics.py:19
def battery_status_a_cb(self, msg)
Definition: diagnostics.py:46
def med_data_cb(self, data)
Definition: diagnostics.py:38
def openrover_charging_cb(self, msg)
Definition: diagnostics.py:57


rr_openrover_driver
Author(s): Jack Kilian
autogenerated on Thu Sep 10 2020 03:38:38