예제 #1
0
파일: window_map.py 프로젝트: atolab/erdos
def main():
    """Creates and runs the dataflow graph."""
    def add(msg):
        """Mapping Function passed into MapOp,
           returns a new Message that sums the data of each message in
           msg.data."""
        total = 0
        for i in msg.data:
            total += i.data
        return erdos.Message(msg.timestamp, total)

    (source_stream, ) = erdos.connect(SendOp,
                                      erdos.OperatorConfig(name="SendOp"), [],
                                      frequency=3)
    (window_stream, ) = erdos.connect(window.TumblingWindow,
                                      erdos.OperatorConfig(), [source_stream],
                                      window_size=3)
    (map_stream, ) = erdos.connect(map.Map,
                                   erdos.OperatorConfig(), [window_stream],
                                   function=add)
    extract_stream = erdos.ExtractStream(map_stream)

    erdos.run_async()

    while True:
        recv_msg = extract_stream.read()
        print("ExtractStream: received {recv_msg}".format(recv_msg=recv_msg))
예제 #2
0
def create_data_flow():
    """Creates a data-flow which process input data, and outputs commands.

    Returns:
        A tuple of streams. The first N - 1 streams are input streams on
        which the agent can send input data. The last stream is the control
        stream on which the agent receives control commands.
    """
    pose_stream = erdos.IngestStream()
    open_drive_stream = erdos.IngestStream()
    global_trajectory_stream = erdos.IngestStream()
    # Currently, we do not use the scene layout information.
    # scene_layout_stream = erdos.IngestStream()
    ground_obstacles_stream = erdos.IngestStream()
    traffic_lights_stream = erdos.IngestStream()
    lanes_stream = erdos.IngestStream()
    time_to_decision_loop_stream = erdos.LoopStream()

    # Add waypoint planner.
    waypoints_stream = pylot.component_creator.add_planning(
        None, pose_stream, ground_obstacles_stream, traffic_lights_stream,
        lanes_stream, open_drive_stream, global_trajectory_stream,
        time_to_decision_loop_stream)
    control_stream = pylot.operator_creator.add_pid_control(
        pose_stream, waypoints_stream)
    extract_control_stream = erdos.ExtractStream(control_stream)

    time_to_decision_stream = pylot.operator_creator.add_time_to_decision(
        pose_stream, ground_obstacles_stream)
    time_to_decision_loop_stream.set(time_to_decision_stream)

    return (pose_stream, global_trajectory_stream, ground_obstacles_stream,
            traffic_lights_stream, lanes_stream, open_drive_stream,
            extract_control_stream)
예제 #3
0
def create_data_flow():
    """ Create the challenge data-flow graph."""
    track = get_track()
    time_to_decision_loop_stream = erdos.LoopStream()
    camera_setups = create_camera_setups(track)
    camera_streams = {}
    for name in camera_setups:
        camera_streams[name] = erdos.IngestStream()
    pose_stream = erdos.IngestStream()
    global_trajectory_stream = erdos.IngestStream()
    open_drive_stream = erdos.IngestStream()

    if (track == Track.ALL_SENSORS
            or track == Track.ALL_SENSORS_HDMAP_WAYPOINTS):
        point_cloud_stream = erdos.IngestStream()
    else:
        point_cloud_stream = pylot.operator_creator.add_depth_estimation(
            camera_streams[LEFT_CAMERA_NAME],
            camera_streams[RIGHT_CAMERA_NAME],
            camera_setups[CENTER_CAMERA_NAME])

    obstacles_stream = pylot.operator_creator.add_obstacle_detection(
        camera_streams[CENTER_CAMERA_NAME], time_to_decision_loop_stream)[0]
    # Adds an operator that finds the world locations of the obstacles.
    obstacles_stream = pylot.operator_creator.add_obstacle_location_finder(
        obstacles_stream, point_cloud_stream, pose_stream,
        camera_streams[CENTER_CAMERA_NAME], camera_setups[CENTER_CAMERA_NAME])

    traffic_lights_stream = pylot.operator_creator.add_traffic_light_detector(
        camera_streams[TL_CAMERA_NAME])
    # Adds an operator that finds the world locations of the traffic lights.
    traffic_lights_stream = \
        pylot.operator_creator.add_obstacle_location_finder(
            traffic_lights_stream, point_cloud_stream, pose_stream,
            camera_streams[TL_CAMERA_NAME], camera_setups[TL_CAMERA_NAME])

    waypoints_stream = pylot.operator_creator.add_waypoint_planning(
        pose_stream, open_drive_stream, global_trajectory_stream,
        obstacles_stream, traffic_lights_stream, None)

    if FLAGS.visualize_rgb_camera:
        pylot.operator_creator.add_camera_visualizer(
            camera_streams[CENTER_CAMERA_NAME], CENTER_CAMERA_NAME)

    control_stream = pylot.operator_creator.add_pid_agent(
        pose_stream, waypoints_stream)
    extract_control_stream = erdos.ExtractStream(control_stream)

    time_to_decision_stream = pylot.operator_creator.add_time_to_decision(
        pose_stream, obstacles_stream)
    time_to_decision_loop_stream.set(time_to_decision_stream)

    return (camera_streams, pose_stream, global_trajectory_stream,
            open_drive_stream, point_cloud_stream, extract_control_stream)
예제 #4
0
def main():
    # Create the first dataflow.
    ingest_stream = erdos.IngestStream()
    (map_stream, ) = erdos.connect(map.Map,
                                   erdos.OperatorConfig(name="Double"),
                                   [ingest_stream],
                                   function=double)
    extract_stream = erdos.ExtractStream(map_stream)
    node_handle = erdos.run_async()

    for t in range(5):
        send_msg = erdos.Message(erdos.Timestamp(coordinates=[t]), t)
        ingest_stream.send(send_msg)
        print("IngestStream: sent {send_msg}".format(send_msg=send_msg))
        recv_msg = extract_stream.read()
        print("ExtractStream: received {recv_msg}".format(recv_msg=recv_msg))

        time.sleep(1)

    node_handle.shutdown()
    erdos.reset()

    # Create a new dataflow.
    ingest_stream = erdos.IngestStream()
    (map_stream, ) = erdos.connect(map.Map,
                                   erdos.OperatorConfig(name="Square"),
                                   [ingest_stream],
                                   function=square)
    extract_stream = erdos.ExtractStream(map_stream)
    node_handle = erdos.run_async()

    for t in range(5):
        send_msg = erdos.Message(erdos.Timestamp(coordinates=[t]), t)
        ingest_stream.send(send_msg)
        print("IngestStream: sent {send_msg}".format(send_msg=send_msg))
        recv_msg = extract_stream.read()
        print("ExtractStream: received {recv_msg}".format(recv_msg=recv_msg))

        time.sleep(1)

    node_handle.shutdown()
예제 #5
0
파일: thr_send.py 프로젝트: atolab/erdos
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--payload', default=8, type=int)
    parser.add_argument('-s', '--scenario', default="dataflow")
    parser.add_argument('-n', '--name', default="test")
    parser.add_argument('-t', '--transport', default="tcp")
    parser.add_argument('-o', '--operators', action='store_true')
    parser.add_argument('-g', '--graph-file')
    args = parser.parse_args()

    zenoh.init_logger()

    # creating Zenoh.net session
    #session = zenoh.net.open({})
    """Creates and runs the dataflow graph."""
    (count_stream, ) = erdos.connect(SendOp,
                                     erdos.OperatorConfig(), [],
                                     size=args.payload)

    if args.operators:
        erdos.connect(ZenohSendOp,
                      erdos.OperatorConfig(), [count_stream],
                      size=args.payload)
        if args.graph_file is not None:
            erdos.run(args.graph_file)
        else:
            erdos.run()
    else:
        extract_stream = erdos.ExtractStream(count_stream)
        # creating zenoh session
        session = zenoh.net.open({})

        # Declaring zenoh sender
        rid = session.declare_resource(f'/thr/test/{args.payload}')
        publisher = session.declare_publisher(rid)

        if args.graph_file is not None:
            erdos.run_async(args.graph_file)
        else:
            erdos.run_async()

        counter = Counter(size=args.payload,
                          scenario=args.scenario,
                          name=args.name,
                          transport=args.transport)
        while True:
            msg = extract_stream.read()
            counter.inc()
예제 #6
0
def main():
    ingest_stream = erdos.IngestStream()
    (s, ) = erdos.connect(NoopOp, erdos.OperatorConfig(), [ingest_stream])
    extract_stream = erdos.ExtractStream(s)

    erdos.run_async()

    timestamp = erdos.Timestamp(is_top=True)
    send_msg = erdos.WatermarkMessage(timestamp)
    print("IngestStream: sending {send_msg}".format(send_msg=send_msg))
    ingest_stream.send(send_msg)
    assert ingest_stream.is_closed()

    recv_msg = extract_stream.read()
    print("ExtractStream: received {recv_msg}".format(recv_msg=recv_msg))
    assert recv_msg.is_top
    assert extract_stream.is_closed()
예제 #7
0
def create_data_flow():
    """ Create the challenge data-flow graph."""
    track = get_track()
    camera_setups = create_camera_setups(track)
    camera_streams = {}
    for name in camera_setups:
        camera_streams[name] = erdos.IngestStream()
    can_bus_stream = erdos.IngestStream()
    global_trajectory_stream = erdos.IngestStream()
    open_drive_stream = erdos.IngestStream()
    if track != Track.ALL_SENSORS_HDMAP_WAYPOINTS:
        # We do not have access to the open drive map. Send top watermark.
        open_drive_stream.send(
            erdos.WatermarkMessage(erdos.Timestamp(coordinates=[sys.maxsize])))

    if (track == Track.ALL_SENSORS
            or track == Track.ALL_SENSORS_HDMAP_WAYPOINTS):
        point_cloud_stream = erdos.IngestStream()
    else:
        point_cloud_stream = pylot.operator_creator.add_depth_estimation(
            camera_streams[LEFT_CAMERA_NAME],
            camera_streams[RIGHT_CAMERA_NAME],
            camera_setups[CENTER_CAMERA_NAME])

    obstacles_stream = pylot.operator_creator.add_obstacle_detection(
        camera_streams[CENTER_CAMERA_NAME])[0]
    traffic_lights_stream = pylot.operator_creator.add_traffic_light_detector(
        camera_streams[TL_CAMERA_NAME])

    waypoints_stream = pylot.operator_creator.add_waypoint_planning(
        can_bus_stream, open_drive_stream, global_trajectory_stream, None)

    if FLAGS.visualize_rgb_camera:
        pylot.operator_creator.add_camera_visualizer(
            camera_streams[CENTER_CAMERA_NAME], CENTER_CAMERA_NAME)

    control_stream = pylot.operator_creator.add_pylot_agent(
        can_bus_stream, waypoints_stream, traffic_lights_stream,
        obstacles_stream, point_cloud_stream, open_drive_stream,
        camera_setups[CENTER_CAMERA_NAME])
    extract_control_stream = erdos.ExtractStream(control_stream)
    return (camera_streams, can_bus_stream, global_trajectory_stream,
            open_drive_stream, point_cloud_stream, extract_control_stream)
예제 #8
0
def main():
    ingest_stream = erdos.IngestStream()
    (square_stream, ) = erdos.connect(Map,
                                      erdos.OperatorConfig(), [ingest_stream],
                                      function=square_msg)
    extract_stream = erdos.ExtractStream(square_stream)

    erdos.run_async()

    count = 0
    while True:
        timestamp = erdos.Timestamp(coordinates=[count])
        send_msg = erdos.Message(timestamp, count)
        print("IngestStream: sending {send_msg}".format(send_msg=send_msg))
        ingest_stream.send(send_msg)
        recv_msg = extract_stream.read()
        print("ExtractStream: received {recv_msg}".format(recv_msg=recv_msg))

        count += 1
        time.sleep(1)
예제 #9
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--payload', default=8, type=int)
    parser.add_argument('-s', '--scenario', default="dataflow")
    parser.add_argument('-n', '--name', default="test")
    parser.add_argument('-i', '--interveal', default=1, type=int)
    parser.add_argument('-t', '--transport', default="tcp")
    parser.add_argument('-g', '--graph-file')

    args = parser.parse_args()
    """Creates and runs the dataflow graph."""
    ingest_stream = erdos.IngestStream()
    (pong_stream, ) = erdos.connect(PongOp, erdos.OperatorConfig(),
                                    [ingest_stream])
    extract_stream = erdos.ExtractStream(pong_stream)

    if args.graph_file is not None:
        erdos.run_async(args.graph_file)
    else:
        erdos.run_async()

    count = 0
    payload = '0' * args.payload

    while True:
        msg = erdos.Message(erdos.Timestamp(coordinates=[count]), payload)
        t0 = datetime.datetime.now()
        ingest_stream.send(msg)
        #print("PingOp: sending {msg}".format(msg=msg))
        count += 1
        data = extract_stream.read()
        t1 = datetime.datetime.now()
        #print("PingOp: received {msg}".format(msg=data))
        t = t1 - t0
        print(
            f"erdos-{args.transport},{args.scenario},latency,{args.name},{args.payload},{data.timestamp.coordinates[0]},{t.microseconds}"
        )
        time.sleep(args.interveal)
예제 #10
0
def create_data_flow():
    """ Create the challenge data-flow graph."""
    streams_to_send_top_on = []
    time_to_decision_loop_stream = erdos.LoopStream()
    camera_setups = create_camera_setups()
    camera_streams = {}
    for name in camera_setups:
        camera_streams[name] = erdos.IngestStream()
    global_trajectory_stream = erdos.IngestStream()
    open_drive_stream = erdos.IngestStream()
    point_cloud_stream = erdos.IngestStream()
    imu_stream = erdos.IngestStream()
    gnss_stream = erdos.IngestStream()
    route_stream = erdos.IngestStream()

    if FLAGS.localization:
        pose_stream = pylot.operator_creator.add_localization(
            imu_stream, gnss_stream, route_stream)
    else:
        pose_stream = erdos.IngestStream()

    ground_obstacles_stream = erdos.IngestStream()
    ground_traffic_lights_stream = erdos.IngestStream()
    vehicle_id_stream = erdos.IngestStream()
    if not (FLAGS.perfect_obstacle_tracking or FLAGS.carla_localization):
        streams_to_send_top_on.append(vehicle_id_stream)

    if FLAGS.carla_obstacle_detection:
        obstacles_stream = ground_obstacles_stream
    elif any('efficientdet' in model
             for model in FLAGS.obstacle_detection_model_names):
        obstacles_stream = pylot.operator_creator.\
            add_efficientdet_obstacle_detection(
                camera_streams[CENTER_CAMERA_NAME],
                time_to_decision_loop_stream)[0]
        streams_to_send_top_on.append(ground_obstacles_stream)
    else:
        obstacles_stream = pylot.operator_creator.add_obstacle_detection(
            camera_streams[CENTER_CAMERA_NAME],
            time_to_decision_loop_stream)[0]
        streams_to_send_top_on.append(ground_obstacles_stream)

    if FLAGS.carla_traffic_light_detection:
        traffic_lights_stream = ground_traffic_lights_stream
        camera_streams[TL_CAMERA_NAME] = erdos.IngestStream()
        streams_to_send_top_on.append(camera_streams[TL_CAMERA_NAME])
    else:
        traffic_lights_stream = \
            pylot.operator_creator.add_traffic_light_detector(
                camera_streams[TL_CAMERA_NAME])
        # Adds an operator that finds the world location of the traffic lights.
        traffic_lights_stream = \
            pylot.operator_creator.add_obstacle_location_finder(
                traffic_lights_stream, point_cloud_stream, pose_stream,
                camera_setups[TL_CAMERA_NAME])
        streams_to_send_top_on.append(ground_traffic_lights_stream)

    obstacles_tracking_stream = pylot.component_creator.add_obstacle_tracking(
        camera_streams[CENTER_CAMERA_NAME],
        camera_setups[CENTER_CAMERA_NAME],
        obstacles_stream,
        depth_stream=point_cloud_stream,
        vehicle_id_stream=vehicle_id_stream,
        pose_stream=pose_stream,
        ground_obstacles_stream=ground_obstacles_stream,
        time_to_decision_stream=time_to_decision_loop_stream)

    if FLAGS.execution_mode == 'challenge-sensors':
        lanes_stream = pylot.operator_creator.add_lanenet_detection(
            camera_streams[LANE_CAMERA_NAME])
    else:
        lanes_stream = erdos.IngestStream()
        streams_to_send_top_on.append(lanes_stream)

    prediction_stream = pylot.operator_creator.add_linear_prediction(
        obstacles_tracking_stream)

    waypoints_stream = pylot.component_creator.add_planning(
        None, pose_stream, prediction_stream, traffic_lights_stream,
        lanes_stream, open_drive_stream, global_trajectory_stream,
        time_to_decision_loop_stream)

    if pylot.flags.must_visualize():
        control_display_stream, ingest_streams = \
            pylot.operator_creator.add_visualizer(
                pose_stream=pose_stream,
                camera_stream=camera_streams[CENTER_CAMERA_NAME],
                tl_camera_stream=camera_streams[TL_CAMERA_NAME],
                point_cloud_stream=point_cloud_stream,
                obstacles_stream=obstacles_stream,
                traffic_lights_stream=traffic_lights_stream,
                tracked_obstacles_stream=obstacles_tracking_stream,
                waypoints_stream=waypoints_stream,
                lane_detection_stream=lanes_stream,
                prediction_stream=prediction_stream)
        streams_to_send_top_on += ingest_streams
    else:
        control_display_stream = None

    control_stream = pylot.operator_creator.add_pid_control(
        pose_stream, waypoints_stream)
    extract_control_stream = erdos.ExtractStream(control_stream)

    time_to_decision_stream = pylot.operator_creator.add_time_to_decision(
        pose_stream, obstacles_stream)
    time_to_decision_loop_stream.set(time_to_decision_stream)

    return (camera_streams, pose_stream, route_stream,
            global_trajectory_stream, open_drive_stream, point_cloud_stream,
            imu_stream, gnss_stream, extract_control_stream,
            control_display_stream, ground_obstacles_stream,
            ground_traffic_lights_stream, vehicle_id_stream,
            streams_to_send_top_on)
예제 #11
0
파일: ERDOSAgent.py 프로젝트: wnklmx/pylot
def create_data_flow():
    """Creates a dataflow graph of operators.

    This is the place to add other operators (e.g., other detectors,
    behavior planning).
    """
    streams_to_send_top_on = []
    camera_setups = create_camera_setups()
    # Creates a dataflow stream for each camera.
    camera_streams = {}
    for name in camera_setups:
        camera_streams[name] = erdos.IngestStream()
    # Creates a stream on which the agent sends the high-level route the
    # agent must follow in the challenge.
    global_trajectory_stream = erdos.IngestStream()
    # Creates a stream on which the agent sends the open drive stream it
    # receives when it executes in the MAP track.
    open_drive_stream = erdos.IngestStream()
    # Creates a stream on which the agent sends point cloud messages it
    # receives from the LiDAR sensor.
    point_cloud_stream = erdos.IngestStream()
    imu_stream = erdos.IngestStream()
    gnss_stream = erdos.IngestStream()
    route_stream = erdos.IngestStream()
    time_to_decision_loop_stream = erdos.LoopStream()

    if FLAGS.localization:
        # Pylot localization is enabled. Add the localization operator to
        # the dataflow. The operator receives GNSS and IMU messages, and
        # uses an Extended Kalman Filter to compute poses.
        pose_stream = pylot.operator_creator.add_localization(
            imu_stream, gnss_stream, route_stream)
    else:
        # The agent either directly forwards the poses it receives from
        # the challenge, which are noisy, or the perfect poses if the
        # --perfect_localization flag is set.
        pose_stream = erdos.IngestStream()

    # Stream on which the obstacles are sent when the agent is using perfect
    # detection.
    perfect_obstacles_stream = erdos.IngestStream()
    if FLAGS.simulator_obstacle_detection:
        # Execute with perfect perception. In this configuration, the agent
        # directly gets the location of the other agents from the simulator.
        # This configuration is meant for testing and debugging.
        obstacles_stream = perfect_obstacles_stream
    elif any('efficientdet' in model
             for model in FLAGS.obstacle_detection_model_names):
        # Add an operator that runs EfficientDet to detect obstacles.
        obstacles_stream = pylot.operator_creator.\
            add_efficientdet_obstacle_detection(
                camera_streams[CENTER_CAMERA_NAME],
                time_to_decision_loop_stream)[0]
        if not (FLAGS.evaluate_obstacle_detection
                or FLAGS.evaluate_obstacle_tracking):
            streams_to_send_top_on.append(perfect_obstacles_stream)
    else:
        # Add an operator that uses one of the Tensorflow model zoo
        # detection models. By default, we use FasterRCNN.
        obstacles_stream = pylot.operator_creator.add_obstacle_detection(
            camera_streams[CENTER_CAMERA_NAME],
            time_to_decision_loop_stream)[0]
        if not (FLAGS.evaluate_obstacle_detection
                or FLAGS.evaluate_obstacle_tracking):
            streams_to_send_top_on.append(perfect_obstacles_stream)

    # Stream on which the traffic lights are sent when the agent is
    # using perfect traffic light detection.
    perfect_traffic_lights_stream = erdos.IngestStream()
    if FLAGS.simulator_traffic_light_detection:
        # In this debug configuration, the agent is using perfectly located
        # traffic lights it receives directly from the simulator. Therefore,
        # there's no need to a traffic light detector.
        traffic_lights_stream = perfect_traffic_lights_stream
        camera_streams[TL_CAMERA_NAME] = erdos.IngestStream()
        streams_to_send_top_on.append(camera_streams[TL_CAMERA_NAME])
    else:
        # Adds a traffic light detector operator, which uses the camera with
        # the small fov.
        traffic_lights_stream = \
            pylot.operator_creator.add_traffic_light_detector(
                camera_streams[TL_CAMERA_NAME], time_to_decision_loop_stream)
        # Adds an operator that finds the world location of the traffic lights.
        # The operator synchronizes LiDAR point cloud readings with camera
        # frames, and uses them to compute the depth to traffic light bounding
        # boxes.
        traffic_lights_stream = \
            pylot.operator_creator.add_obstacle_location_finder(
                traffic_lights_stream, point_cloud_stream, pose_stream,
                camera_setups[TL_CAMERA_NAME])
        # We do not send perfectly located traffic lights in this
        # configuration. Therefore, ensure that the stream is "closed"
        # (i.e., send a top watermark)
        streams_to_send_top_on.append(perfect_traffic_lights_stream)

    vehicle_id_stream = erdos.IngestStream()
    if not (FLAGS.perfect_obstacle_tracking or FLAGS.perfect_localization):
        # The vehicle_id_stream is only used when perfect localization
        # or perfect obstacle tracking are enabled.
        streams_to_send_top_on.append(vehicle_id_stream)

    # Adds an operator for tracking detected agents. The operator uses the
    # frames from the center camera, and the bounding boxes found by the
    # obstacle detector operator.
    obstacles_tracking_stream = pylot.component_creator.add_obstacle_tracking(
        camera_streams[CENTER_CAMERA_NAME],
        camera_setups[CENTER_CAMERA_NAME],
        obstacles_stream,
        depth_stream=point_cloud_stream,
        vehicle_id_stream=vehicle_id_stream,
        pose_stream=pose_stream,
        ground_obstacles_stream=perfect_obstacles_stream,
        time_to_decision_stream=time_to_decision_loop_stream)

    if FLAGS.execution_mode == 'challenge-sensors':
        # The agent is running is sensors-only track. Therefore, we need
        # to add a lane detector because the agent does not have access to
        # the OpenDrive map.
        lanes_stream = pylot.operator_creator.add_lanenet_detection(
            camera_streams[LANE_CAMERA_NAME])
    else:
        # The lanes stream is not used when running in the Map track.
        # We add the stream to the list of streams that are not used, and
        # must be manually "closed" (i.e., send a top watermark).
        lanes_stream = erdos.IngestStream()
        streams_to_send_top_on.append(lanes_stream)

    # The agent uses a linear predictor to compute future trajectories
    # of the other agents.
    prediction_stream, _, _ = pylot.component_creator.add_prediction(
        obstacles_tracking_stream,
        vehicle_id_stream,
        time_to_decision_loop_stream,
        pose_stream=pose_stream)

    # Adds a planner to the agent. The planner receives the pose of
    # the ego-vehicle, detected traffic lights, predictions for other
    # agents, the route the agent must follow, and the open drive data if
    # the agent is executing in the Map track, or detected lanes if it is
    # executing in the Sensors-only track.
    waypoints_stream = pylot.component_creator.add_planning(
        None, pose_stream, prediction_stream, traffic_lights_stream,
        lanes_stream, open_drive_stream, global_trajectory_stream,
        time_to_decision_loop_stream)

    if pylot.flags.must_visualize():
        # Adds a visualization dataflow operator if any of the
        # --visualize_* is enabled. The operator creates a pygame window
        # in which the different sensors, detections can be visualized.
        control_display_stream, ingest_streams = \
            pylot.operator_creator.add_visualizer(
                pose_stream=pose_stream,
                camera_stream=camera_streams[CENTER_CAMERA_NAME],
                tl_camera_stream=camera_streams[TL_CAMERA_NAME],
                point_cloud_stream=point_cloud_stream,
                obstacles_stream=obstacles_stream,
                traffic_lights_stream=traffic_lights_stream,
                tracked_obstacles_stream=obstacles_tracking_stream,
                waypoints_stream=waypoints_stream,
                lane_detection_stream=lanes_stream,
                prediction_stream=prediction_stream)
        streams_to_send_top_on += ingest_streams
    else:
        control_display_stream = None

    # Adds a controller which tries to follow the waypoints computed
    # by the planner.
    control_stream = pylot.component_creator.add_control(
        pose_stream, waypoints_stream)
    # The controller returns a stream of commands (i.e., throttle, steer)
    # from which the agent can read the command it must return to the
    # challenge.
    extract_control_stream = erdos.ExtractStream(control_stream)

    pylot.component_creator.add_evaluation(vehicle_id_stream, pose_stream,
                                           imu_stream)

    # Operator that computes how much time each component gets to execute.
    # This is needed in Pylot, but can be ignored when running in challenge
    # mode.
    time_to_decision_stream = pylot.operator_creator.add_time_to_decision(
        pose_stream, obstacles_stream)
    time_to_decision_loop_stream.set(time_to_decision_stream)

    return (camera_streams, pose_stream, route_stream,
            global_trajectory_stream, open_drive_stream, point_cloud_stream,
            imu_stream, gnss_stream, extract_control_stream,
            control_display_stream, perfect_obstacles_stream,
            perfect_traffic_lights_stream, vehicle_id_stream,
            streams_to_send_top_on)
예제 #12
0
def driver():
    ingest_stream = erdos.IngestStream()
    (square_stream, ) = erdos.connect(SquareOp, [ingest_stream])
    extract_stream = erdos.ExtractStream(square_stream)

    return ingest_stream, extract_stream