Beispiel #1
0
    def road_config_controller(
            self, mqtt_address: Tuple[str,
                                      int]) -> Iterator[RoadConfigController]:
        host = mqtt_address[0]
        port = mqtt_address[1]
        wait_port_open(host=host, port=port)

        road_config = RoadConfigController(
            mqtt_enable=True,
            enable=True,
            horizon_hough_max_line_gap=10,
            horizon_hough_min_line_length=1,
            horizon_hough_threshold=100,
            kernel_size=4,
            morpho_iterations=3,
            canny_threshold1=120,
            canny_threshold2=250,
            approx_poly_epsilon_factor=0.01,
            mqtt_topic='test/car/config/road/#',
            mqtt_hostname=host,
            mqtt_port=port,
            mqtt_client_id='donkey-config-road-',
            mqtt_qos=1)

        wait_all_mqtt_messages_consumed(
            f'mqtt-subscription-{road_config._mqtt_client_id}'
            f'qos{road_config.qos}')
        yield road_config
        road_config.shutdown()
Beispiel #2
0
 def fixture_road_part(self) -> RoadPart:
     road_config = RoadConfigController(enable=True,
                                        canny_threshold1=180,
                                        canny_threshold2=200,
                                        kernel_size=4,
                                        mqtt_enable=False)
     return RoadPart(config=road_config)
Beispiel #3
0
def fixture_road_config() -> RoadConfigController:
    return RoadConfigController(enable=True,
                                canny_threshold1=180,
                                canny_threshold2=200,
                                kernel_size=4,
                                mqtt_enable=False)
Beispiel #4
0
    def test_values(self, config: RoadConfigController, mqtt_config: Client):
        enable, horizon_hough_min_line_length, horizon_hough_max_line_gap, horizon_hough_threshold, kernel_size, \
        morpho_iterations, canny_threshold1, canny_threshold2, approx_poly_epsilon_factor = config.run()

        assert enable == True
        assert horizon_hough_min_line_length == 1
        assert horizon_hough_max_line_gap == 10
        assert horizon_hough_threshold == 100
        assert kernel_size == 4
        assert morpho_iterations == 3
        assert canny_threshold1 == 120
        assert canny_threshold2 == 250
        assert approx_poly_epsilon_factor == 0.01

        mqtt_config.publish(
            topic=f'test/car/config/{CFG_ROAD_ENABLE.replace("cfg/", "")}',
            payload="false",
            qos=1).wait_for_publish()
        mqtt_config.publish(
            topic=
            f'test/car/config/{CFG_ROAD_HORIZON_HOUGH_MIN_LINE_LENGTH.replace("cfg/", "")}',
            payload="10",
            qos=1).wait_for_publish()
        mqtt_config.publish(
            topic=
            f'test/car/config/{CFG_ROAD_HORIZON_HOUGH_MAX_LINE_GAP.replace("cfg/", "")}',
            payload="5",
            qos=1).wait_for_publish()
        mqtt_config.publish(
            topic=
            f'test/car/config/{CFG_ROAD_HORIZON_HOUGH_THRESHOLD.replace("cfg/", "")}',
            payload="20",
            qos=1).wait_for_publish()
        mqtt_config.publish(
            topic=
            f'test/car/config/{CFG_ROAD_CONTOUR_KERNEL_SIZE.replace("cfg/", "")}',
            payload="30",
            qos=1).wait_for_publish()
        mqtt_config.publish(
            topic=
            f'test/car/config/{CFG_ROAD_CONTOUR_MORPHO_ITERATIONS.replace("cfg/", "")}',
            payload="40",
            qos=1).wait_for_publish()
        mqtt_config.publish(
            topic=
            f'test/car/config/{CFG_ROAD_CONTOUR_CANNY_THRESHOLD1.replace("cfg/", "")}',
            payload="50",
            qos=1).wait_for_publish()
        mqtt_config.publish(
            topic=
            f'test/car/config/{CFG_ROAD_CONTOUR_CANNY_THRESHOLD2.replace("cfg/", "")}',
            payload="60",
            qos=1).wait_for_publish()
        mqtt_config.publish(
            topic=
            f'test/car/config/{CFG_ROAD_CONTOUR_APPROX_POLY_EPSILON_FACTOR.replace("cfg/", "")}',
            payload="70.5",
            qos=1).wait_for_publish()

        wait_all_mqtt_messages_consumed(
            f'mqtt-subscription-{config._mqtt_client_id}'
            f'qos{config.qos}')

        enable, horizon_hough_min_line_length, horizon_hough_max_line_gap, horizon_hough_threshold, kernel_size, \
        morpho_iterations, canny_threshold1, canny_threshold2, approx_poly_epsilon_factor = config.run()

        assert enable == False
        assert horizon_hough_min_line_length == 10
        assert horizon_hough_max_line_gap == 5
        assert horizon_hough_threshold == 20
        assert kernel_size == 30
        assert morpho_iterations == 40
        assert canny_threshold1 == 50
        assert canny_threshold2 == 60
        assert approx_poly_epsilon_factor == 70.5