def handle(self, handled_data=None):
        self.initialize()

        while not self.is_finished:
            handled_data["movement_vectors_string_pub"].publish(
                json.dumps((0, 0, 6)))
            self.rate.sleep()

        handled_data['resistance'] = self.resistance
        resistance_object = Resistance(self.resistance)
        rounded_resistance, colors = resistance_object.get_resistance_and_colors(
        )
        colors = colors + [
            ResistanceMapper().find_exponent_color(resistance_object)
        ]
        rospy.logerr([rounded_resistance, colors])
        handled_data["puck_colors"] = colors
        handled_data["puck_colors_pub"].publish(json.dumps(colors))

        self.rate.sleep()
        handled_data["movement_vectors_string_pub"].publish(
            json.dumps((handled_data["resistance_y_dist"], 0, 3)))
        self.rate.sleep()
        handled_data["movement_vectors_string_pub"].publish(
            json.dumps((handled_data["resistance_x_dist"], 0, 0)))
        self.rate.sleep()

        return handled_data
Beispiel #2
0
 def test_when_round_then_resistance_is_as_expected_7(self):
     resistance = Resistance(self.A_RESISTANCE_7)
     rounded_resistance, _ = resistance.get_resistance_and_colors()
     assert rounded_resistance == self.EXPECTED_RESISTANCE_7