5 import roslib; roslib.load_manifest(
'rospatlite')
8 from std_msgs.msg
import Int8
10 from patlite
import Patlite
11 from patlite
import PatliteState
16 self.pstate.set_from_int(target, state)
20 self.
set_state(self.pstate.Target.LIGHT_RED, msg.data)
23 self.
set_state(self.pstate.Target.LIGHT_YELLOW, msg.data)
26 self.
set_state(self.pstate.Target.LIGHT_GREEN, msg.data)
29 self.
set_state(self.pstate.Target.LIGHT_BLUE, msg.data)
32 self.
set_state(self.pstate.Target.LIGHT_WHITE, msg.data)
35 self.
set_state(self.pstate.Target.BUZZER, msg.data)
38 rospy.init_node(
'patlite_node')
39 patlite_host = rospy.get_param(
'~host',
"10.68.0.10")
40 patlite_port = rospy.get_param(
'~port', 10000)
41 timeout = rospy.get_param(
'~timeout', 0.5)
42 self.
p =
Patlite(patlite_host, port=patlite_port, timeout=timeout)
46 rospy.Subscriber(
"~set/red", Int8, self.
callback_r)
47 rospy.Subscriber(
"~set/yellow", Int8, self.
callback_y)
48 rospy.Subscriber(
"~set/green", Int8, self.
callback_g)
49 rospy.Subscriber(
"~set/blue", Int8, self.
callback_b)
50 rospy.Subscriber(
"~set/white", Int8, self.
callback_w)
52 rospy.loginfo(
"[patlite_node] started")
54 while not rospy.is_shutdown():
61 except socket.timeout:
62 rospy.logerr(
"[patlite_node] Error: socket timeout (%s:%d)",
63 patlite_host, patlite_port)
64 except socket.error
as e:
65 rospy.logerr(
"[patlite_node] Error: %s (%s:%d)",
66 e, patlite_host, patlite_port)
68 rospy.loginfo(
"[patlite_node] shutdown")
71 if __name__ ==
'__main__':
75 except rospy.ROSInterruptException:
def callback_g(self, msg)
def set_state(self, target, state)
def callback_w(self, msg)
def callback_r(self, msg)
def callback_y(self, msg)
def callback_buzz(self, msg)
def callback_b(self, msg)