led.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:baxter_gui 作者: HumaRobotics 项目源码 文件源码
def blink(self,name, timeout=0.0, frequency=2.0): #timeout <= 0 blinks endlessly
        """
            Blinks a led for a specific time and frequency (blocking)

            :param name: Name of the led
            :type name: str
            :param timeout: Duration to let the led blinking. A value <= 0.0 means infinite time
            :type timeout: float
            :param frequency: Rate, how often a led blinks in one second
            :type frequency: float   
        """
        end = rospy.Time.now()+ rospy.Duration(timeout)
        self.led_state[name] = 1
        try:
            while not rospy.is_shutdown():
                start = rospy.Time.now()
                if (start > end and timeout > 0) or self.led_state[name] == 0:
                    self.led_handle[name].set_output(False)
                    break
                self.led_handle[name].set_output(True)
                rospy.Rate(frequency*2).sleep()
                self.led_handle[name].set_output(False)
                rospy.Rate(frequency*2).sleep()
        except:
            pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号