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
评论列表
文章目录