예제 #1
0
 def publish(self):
     if self.voltage != None and self.current != None and self.remaining_capacity != None and self.full_charge_capacity != None and self.temperature != None and (rospy.Time.now() - self.last_update) < rospy.Duration(1):
         ps = PowerState()
         ps.header.stamp = self.last_update
         ps.voltage = self.voltage
         ps.current = self.current
         ps.power_consumption = self.calculate_power_consumption()
         ps.remaining_capacity = self.remaining_capacity
         ps.relative_remaining_capacity = self.calculate_relative_remaining_capacity()
         ps.charging = self.charging
         ps.time_remaining = self.calculate_time_remaining()
         ps.temperature = self.temperature
         self.pub_power_state.publish(ps)
         return ps
예제 #2
0
 def publish(self):
     self.calculate_voltage()
     if self.voltage != None and self.current != None and (rospy.Time.now() - self.last_update) < rospy.Duration(1):
         ps = PowerState()
         ps.header.stamp = self.last_update
         ps.voltage = self.voltage
         ps.current = self.current
         ps.power_consumption = self.calculate_power_consumption()
         ps.relative_remaining_capacity = self.calculate_relative_remaining_capacity()
         ps.charging = self.charging
         self.pub_power_state.publish(ps)
예제 #3
0
    def __init__(self):
        self.volts = 0.
        self.wsize = 61
        self.filter_order = 3
        self.theta = rospy.get_param("~theta")
        self.off_y = rospy.get_param("~off_y")
        self.abcd = rospy.get_param("~abcd")
        self.maximum_time = rospy.get_param("~maximum_time")
        self.sg = savitzky.savitzky_golay(window_size=self.wsize,
                                          order=self.filter_order)
        size = 2 * self.wsize + 1
        self.volt_filt = 48000 * np.ones(size)

        rospy.Subscriber("/power_board/voltage", Float64, self.callback)

        self.pub_power = rospy.Publisher('/power_state',
                                         PowerState,
                                         queue_size=1)
        self.msg_power = PowerState()
    def __init__(self):
        self.power_state = PowerState()
        self.relative_remaining_capacity = 0.0
        self.temperature = 0.0
        self.is_charging = False
        self.topic_name = 'power_state'
        self.mode = LightMode()

        self.threshold_warning = rospy.get_param("~threshold_warning", 20.0) # % of battery level
        self.threshold_error = rospy.get_param("~threshold_error", 10.0)     # % of battery level
        self.threshold_critical = rospy.get_param("~threshold_critical", 5.0)# % of battery level

        self.enable_light = rospy.get_param("~enable_light", True)
        self.num_leds = rospy.get_param("~num_leds", 1)
        self.track_id_light = {}
        if self.enable_light:
            if not rospy.has_param("~light_components"):
                rospy.logwarn("parameter light_components does not exist on ROS Parameter Server")
                return
            self.light_components = rospy.get_param("~light_components")
            for component in self.light_components:
                self.track_id_light[component] = None
            self.mode = LightMode()
            self.mode.priority = 8

        self.enable_sound = rospy.get_param("~enable_sound", True)
        self.sound_components = {}
        if self.enable_sound:
            if not rospy.has_param("~sound_components"):
                rospy.logwarn("parameter sound_components does not exist on ROS Parameter Server")
                return
            self.sound_components = rospy.get_param("~sound_components")

        self.sound_critical = rospy.get_param("~sound_critical", "My battery is empty, please recharge now.")
        self.sound_warning = rospy.get_param("~sound_warning", "My battery is nearly empty, please consider recharging.")

        self.last_time_warned = rospy.get_time()
        self.last_time_power_received = rospy.get_time()
        rospy.Subscriber(self.topic_name, PowerState, self.power_callback)

        rospy.Timer(rospy.Duration(1), self.timer_callback)
예제 #5
0
 def charging_callback(self, msg):
     power_state = PowerState()
     power_state.header.stamp = rospy.Time.now()
     power_state.charging = msg.data
     self.pub_power_state_.publish(power_state)