def __init__(self):
        self.node_name = 'average_quacks_node'
        rospy.loginfo("[%s] has started", self.node_name)

        # Setup the publisher and subscriber
        self.sub_list = rospy.Subscriber("~list", Float32MultiArray, self.listCallback)
        self.pub_quacks = rospy.Publisher("~number_of_quacks", Int32, queue_size=1)

        # Setup the quacker
        self.quacker = Quacker()
Exemple #2
0
    def __init__(self):
        self.node_name = 'duckiecall_node'

        # Setup the publisher and subscriber
        self.sub_num_of_quacks = rospy.Subscriber("~number_of_quacks", Int32,
                                                  self.quacksCallback)
        self.pub_duckiecall = rospy.Publisher("~duckiecall",
                                              String,
                                              queue_size=1)

        # Setup the quacker
        self.quacker = Quacker()

        rospy.loginfo("[%s] has started", self.node_name)
    def __init__(self):
        self.node_name = 'duckiecall_node'

        # Setup the publisher and subscriber
        self.sub_num_of_quacks = rospy.Subscriber("~number_of_quacks", Int32, self.quacksCallback)
        self.pub_duckiecall = rospy.Publisher("~duckiecall", String, queue_size=1)

        # Setup the quacker
        self.quacker = Quacker()

        rospy.loginfo("[%s] has started", self.node_name)
class AverageQuacksNode(object):
    def __init__(self):
        self.node_name = 'average_quacks_node'
        rospy.loginfo("[%s] has started", self.node_name)

        # Setup the publisher and subscriber
        self.sub_list = rospy.Subscriber("~list", Float32MultiArray, self.listCallback)
        self.pub_quacks = rospy.Publisher("~number_of_quacks", Int32, queue_size=1)

        # Setup the quacker
        self.quacker = Quacker()

    def listCallback(self, msg):
        msg_num_of_quacks = Int32()
        msg_num_of_quacks.data = self.quacker.rounded_mean(msg.data)
        self.pub_quacks.publish(msg_num_of_quacks)
class DuckiecallNode(object):
    def __init__(self):
        self.node_name = 'duckiecall_node'

        # Setup the publisher and subscriber
        self.sub_num_of_quacks = rospy.Subscriber("~number_of_quacks", Int32, self.quacksCallback)
        self.pub_duckiecall = rospy.Publisher("~duckiecall", String, queue_size=1)

        # Setup the quacker
        self.quacker = Quacker()

        rospy.loginfo("[%s] has started", self.node_name)

    def quacksCallback(self, msg_quacks):
        msg_duckiecall = String()
        msg_duckiecall.data = self.quacker.get_quack_string(msg_quacks.data)
        self.pub_duckiecall.publish(msg_duckiecall)
Exemple #6
0
class DuckiecallNode(object):
    def __init__(self):
        self.node_name = 'duckiecall_node'

        # Setup the publisher and subscriber
        self.sub_num_of_quacks = rospy.Subscriber("~number_of_quacks", Int32,
                                                  self.quacksCallback)
        self.pub_duckiecall = rospy.Publisher("~duckiecall",
                                              String,
                                              queue_size=1)

        # Setup the quacker
        self.quacker = Quacker()

        rospy.loginfo("[%s] has started", self.node_name)

    def quacksCallback(self, msg_quacks):
        msg_duckiecall = String()
        msg_duckiecall.data = self.quacker.get_quack_string(msg_quacks.data)
        self.pub_duckiecall.publish(msg_duckiecall)
 def test_get_quack_string(self):
     quacker = Quacker("Quack!")
     msg = quacker.get_quack_string(3)
     self.assertEqual(msg, "Quack! Quack! Quack!")
 def test_rounded_average(self):
     quacker = Quacker()
     x = quacker.rounded_mean([1, 1, 2, 3])  # Average is 7/4 ~ 2
     self.assertEqual(x,2)
Exemple #9
0
 def test_quacker_default_quack(self):
     quacker = Quacker()
     self.assertEqual(quacker.quack, "Quack!")
Exemple #10
0
 def test_rounded_average(self):
     quacker = Quacker()
     x = quacker.rounded_mean([1, 1, 2, 3])  # Average is 7/4 ~ 2
     self.assertEqual(x, 2)
Exemple #11
0
 def test_get_quack_string(self):
     quacker = Quacker("Quack!")
     msg = quacker.get_quack_string(3)
     self.assertEqual(msg, "Quack! Quack! Quack!")