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
class CommandPanel:
    def __init__(self):
        self.resistance = None
        self.mapped_letters = None

    def set_coordinates(self, coordinates):
        self.coordinates = coordinates

    def set_resistance(self, resistance):
        self.resistance = Resistance(
            resistance
        )  #TODO: s'assurer que Resistance(resistance) a le bon comportement (le truc de e12(?) de denis)

    def set_mapped_letters(self, mapped_letters):
        self.mapped_letters = mapped_letters

    def find_first_corner_letter(self):
        first_digit = self.resistance.get_first_digit()
        index = first_digit - 1
        return Letter[self.mapped_letters[index]]
Esempio n. 3
0
    def handle(self, handled_data=None):
        self.initialize()
        command_panel = CommandPanel()
        command_panel.set_resistance(handled_data['resistance'])
        # handled_data["calculate_pucks_pub"].publish(True)
        self.handled_data = handled_data
        handled_data["read_letters_pub"].publish(True)

        while not self.is_finished:
            pass

        rounded_resistance, _ = Resistance(handled_data["resistance"]).get_resistance_and_colors()
        handled_data["letters"] = self.letters
        command_panel.set_mapped_letters(self.letters)
        command_panel.set_resistance(rounded_resistance)

        first_corner = command_panel.find_first_corner_letter()
        second_corner = first_corner.get_next_letter()
        third_corner = second_corner.get_next_letter()

        handled_data["corners"] = [first_corner.value, second_corner.value, third_corner.value]

        return handled_data
Esempio n. 4
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
Esempio n. 5
0
 def test_when_find_exponent_then_exponent_is_as_expected_5(self):
     resistance = Resistance(1000000)
     exponent = resistance.get_exponent()
     assert exponent == self.EXPECTED_EXPONENT_5
 def set_resistance(self, resistance):
     self.resistance = Resistance(
         resistance
     )  #TODO: s'assurer que Resistance(resistance) a le bon comportement (le truc de e12(?) de denis)