예제 #1
0
파일: lincoln.py 프로젝트: fangedward/pylot
def main(argv):
    (obstacles_stream, traffic_lights_stream, obstacles_tracking_stream,
     open_drive_stream, global_trajectory_stream) = create_data_flow()
    # Run the data-flow.
    erdos.run_async()

    top_timestamp = erdos.Timestamp(coordinates=[sys.maxsize])
    open_drive_stream.send(erdos.WatermarkMessage(top_timestamp))

    waypoints = [[waypoint] for waypoint in read_waypoints()]
    global_trajectory_stream.send(
        erdos.Message(erdos.Timestamp(coordinates=[0]), waypoints))
    global_trajectory_stream.send(erdos.WatermarkMessage(top_timestamp))

    time_to_sleep = 1.0 / FLAGS.sensor_frequency
    count = 0
    while True:
        timestamp = erdos.Timestamp(coordinates=[count])
        if not FLAGS.obstacle_detection:
            obstacles_stream.send(ObstaclesMessage(timestamp, []))
            obstacles_stream.send(erdos.WatermarkMessage(timestamp))
        if not FLAGS.traffic_light_detection:
            traffic_lights_stream.send(TrafficLightsMessage(timestamp, []))
            traffic_lights_stream.send(erdos.WatermarkMessage(timestamp))
        if not FLAGS.obstacle_tracking:
            obstacles_tracking_stream.send(
                ObstacleTrajectoriesMessage(timestamp, []))
            obstacles_tracking_stream.send(erdos.WatermarkMessage(timestamp))
        count += 1
        # NOTE: We should offset sleep time by the time it takes to send the
        # messages.
        time.sleep(time_to_sleep)
예제 #2
0
 def setup(self, path_to_conf_file):
     """Setup phase. Invoked by the scenario runner."""
     flags.FLAGS([__file__, '--flagfile={}'.format(path_to_conf_file)])
     self._logger = erdos.utils.setup_logging('erdos_agent',
                                              FLAGS.log_file_name)
     enable_logging()
     self.track = get_track()
     self._camera_setups = create_camera_setups(self.track)
     # Set the lidar in the same position as the center camera.
     self._lidar_transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                                   pylot.utils.Rotation())
     self._lidar_setup = LidarSetup('lidar', 'sensor.lidar.ray_cast',
                                    self._lidar_transform)
     # Stores the waypoints we get from the challenge planner.
     self._waypoints = None
     # Stores the open drive string we get when we run in track 3.
     self._open_drive_data = None
     (camera_streams, pose_stream, global_trajectory_stream,
      open_drive_stream, point_cloud_stream,
      control_stream) = create_data_flow()
     self._camera_streams = camera_streams
     self._pose_stream = pose_stream
     self._global_trajectory_stream = global_trajectory_stream
     self._open_drive_stream = open_drive_stream
     self._sent_open_drive = False
     self._point_cloud_stream = point_cloud_stream
     self._control_stream = control_stream
     # Execute the data-flow.
     erdos.run_async()
예제 #3
0
    def setup(self, path_to_conf_file):
        """Setup phase code.

        Invoked by the scenario runner.
        """
        # Disable Tensorflow logging.
        pylot.utils.set_tf_loglevel(logging.ERROR)
        flags.FLAGS([__file__, '--flagfile={}'.format(path_to_conf_file)])
        self._logger = erdos.utils.setup_logging('erdos_agent',
                                                 FLAGS.log_file_name)
        enable_logging()
        self.track = Track.SCENE_LAYOUT
        # Stores the waypoints we get from the challenge planner.
        self._waypoints = None
        (pose_stream, global_trajectory_stream, ground_obstacles_stream,
         traffic_lights_stream, lanes_stream, open_drive_stream,
         control_stream) = create_data_flow()
        self._pose_stream = pose_stream
        self._global_trajectory_stream = global_trajectory_stream
        self._ground_obstacles_stream = ground_obstacles_stream
        self._traffic_lights_stream = traffic_lights_stream
        self._open_drive_stream = open_drive_stream
        self._sent_open_drive = False
        self._control_stream = control_stream

        # These are used for the timestamp hack.
        self._past_timestamp = None
        self._past_control_message = None
        # Execute the data-flow.
        erdos.run_async()
예제 #4
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))
예제 #5
0
파일: thr_recv.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('-g', '--graph-file')
    parser.add_argument('-o', '--operators', action='store_true')
    args = parser.parse_args()

    # creating Zenoh.net session
    #session = zenoh.net.open({})
    """Creates and runs the dataflow graph."""

    if args.operators:
        (count_stream, ) = erdos.connect(ZenohRecvOp,
                                         erdos.OperatorConfig(), [],
                                         size=args.payload)
        erdos.connect(CallbackOp,
                      erdos.OperatorConfig(), [count_stream],
                      size=args.payload,
                      scenario=args.scenario,
                      name=args.name,
                      transport=args.transport)
        if args.graph_file is not None:
            erdos.run(args.graph_file)
        else:
            erdos.run()
    else:
        #creating Zenoh.net session
        session = zenoh.net.open({})

        ingest_stream = erdos.IngestStream()

        erdos.connect(CallbackOp,
                      erdos.OperatorConfig(), [ingest_stream],
                      size=args.payload,
                      scenario=args.scenario,
                      name=args.name,
                      transport=args.transport)

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

        def listener(sample):
            msg = pickle.loads(sample.payload)
            ingest_stream.send(msg)

        # Creating subscriber info
        sub_info = SubInfo(Reliability.Reliable, SubMode.Push)
        # declaring subscriber
        sub = session.declare_subscriber(f'/thr/test/{args.payload}', sub_info,
                                         listener)

        while True:
            time.sleep(60)
예제 #6
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()
예제 #7
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()
예제 #8
0
 def setup(self, path_to_conf_file):
     """Setup phase. Invoked by the scenario runner."""
     # Disable Tensorflow logging.
     pylot.utils.set_tf_loglevel(logging.ERROR)
     # Parse the flag file.
     flags.FLAGS([__file__, '--flagfile={}'.format(path_to_conf_file)])
     self._logger = erdos.utils.setup_logging('erdos_agent',
                                              FLAGS.log_file_name)
     enable_logging()
     self.track = get_track()
     self._town_name = None
     self._camera_setups = create_camera_setups()
     # Set the lidar in the same position as the center camera.
     self._lidar_transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                                   pylot.utils.Rotation())
     self._lidar_setup = LidarSetup('lidar',
                                    'sensor.lidar.ray_cast',
                                    self._lidar_transform,
                                    range=8500,
                                    legacy=False)
     self._last_point_cloud = None
     self._last_yaw = 0
     # Stores the waypoints we get from the challenge planner.
     self._waypoints = None
     # Stores the open drive string we get when we run in track 3.
     self._open_drive_data = None
     (camera_streams, pose_stream, route_stream, global_trajectory_stream,
      open_drive_stream, point_cloud_stream, imu_stream, gnss_stream,
      control_stream, control_display_stream, ground_obstacles_stream,
      ground_traffic_lights_stream, vehicle_id_stream,
      streams_to_send_top_on) = create_data_flow()
     self._camera_streams = camera_streams
     self._pose_stream = pose_stream
     self._route_stream = route_stream
     self._sent_initial_pose = False
     self._global_trajectory_stream = global_trajectory_stream
     self._open_drive_stream = open_drive_stream
     self._sent_open_drive = False
     self._point_cloud_stream = point_cloud_stream
     self._imu_stream = imu_stream
     self._gnss_stream = gnss_stream
     self._control_stream = control_stream
     self._control_display_stream = control_display_stream
     self._ground_obstacles_stream = ground_obstacles_stream
     self._ground_traffic_lights_stream = ground_traffic_lights_stream
     self._vehicle_id_stream = vehicle_id_stream
     self._ego_vehicle = None
     self._sent_vehicle_id = False
     # Execute the dataflow.
     self._node_handle = erdos.run_async()
     for stream in streams_to_send_top_on:
         stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
     if using_perfect_component():
         # The agent is using a perfect component. It must directly connect
         # to the simulator to send perfect data to the data-flow.
         _, self._world = pylot.simulation.utils.get_world(
             FLAGS.carla_host, FLAGS.carla_port, FLAGS.carla_timeout)
예제 #9
0
def main():
    ingest_stream = erdos.streams.IngestStream()
    square_stream = ingest_stream.map(lambda x: x * x)

    extract_stream = erdos.streams.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)
예제 #10
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)
예제 #11
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()
예제 #12
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)
예제 #13
0
파일: ERDOSAgent.py 프로젝트: wnklmx/pylot
    def setup(self, path_to_conf_file):
        super(ERDOSAgent, self).setup(path_to_conf_file)
        self._camera_setups = create_camera_setups()
        self._lidar_setup = create_lidar_setup()

        self._sent_open_drive = False

        # Create the dataflow of AV components. Change the method
        # to add your operators.
        (self._camera_streams, self._pose_stream, self._route_stream,
         self._global_trajectory_stream, self._open_drive_stream,
         self._point_cloud_stream, self._imu_stream, self._gnss_stream,
         self._control_stream, self._control_display_stream,
         self._perfect_obstacles_stream, self._perfect_traffic_lights_stream,
         self._vehicle_id_stream, streams_to_send_top_on) = create_data_flow()
        # Execute the dataflow.
        self._node_handle = erdos.run_async()
        # Close the streams that are not used (i.e., send top watermark).
        for stream in streams_to_send_top_on:
            stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
예제 #14
0
def main():
    ingest_stream = erdos.streams.IngestStream()
    s = erdos.connect_one_in_one_out(
        NoopOp, erdos.operator.OperatorConfig(), ingest_stream
    )
    extract_stream = erdos.streams.ExtractStream(s)

    handle = 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()

    handle.shutdown()
예제 #15
0
 def __init_attributes(self, path_to_conf_file):
     flags.FLAGS([__file__, '--flagfile={}'.format(path_to_conf_file)])
     self._logger = erdos.utils.setup_logging('erdos_agent',
                                              FLAGS.log_file_name)
     self.track = get_track()
     self._camera_setups = create_camera_setups(self.track)
     # Set the lidar in the same position as the center camera.
     self._lidar_transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                                   pylot.utils.Rotation())
     # Stores the waypoints we get from the challenge planner.
     self._waypoints = None
     # Stores the open drive string we get when we run in track 3.
     self._open_drive_data = None
     (camera_streams, can_bus_stream, global_trajectory_stream,
      open_drive_stream, point_cloud_stream,
      control_stream) = erdos.run_async(create_data_flow, start_port=19000)
     self._camera_streams = camera_streams
     self._can_bus_stream = can_bus_stream
     self._global_trajectory_stream = global_trajectory_stream
     self._open_drive_stream = open_drive_stream
     self._point_cloud_stream = point_cloud_stream
     self._control_stream = control_stream
예제 #16
0
파일: pylot.py 프로젝트: seikurou/pylot
def driver():
    transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                      pylot.utils.Rotation(pitch=-15))
    streams_to_send_top_on = []
    control_loop_stream = erdos.LoopStream()
    # time_to_decision_loop_stream = erdos.LoopStream()
    if FLAGS.carla_mode == 'pseudo-asynchronous':
        release_sensor_stream = erdos.LoopStream()
        pipeline_finish_notify_stream = erdos.LoopStream()
    else:
        release_sensor_stream = erdos.IngestStream()
        pipeline_finish_notify_stream = erdos.IngestStream()
    notify_streams = []

    # Create operator that bridges between pipeline and CARLA.
    (
        pose_stream,
        pose_stream_for_control,
        ground_traffic_lights_stream,
        ground_obstacles_stream,
        ground_speed_limit_signs_stream,
        ground_stop_signs_stream,
        vehicle_id_stream,
        open_drive_stream,
        global_trajectory_stream,
    ) = pylot.operator_creator.add_carla_bridge(
        control_loop_stream,
        release_sensor_stream,
        pipeline_finish_notify_stream,
    )

    ######################
    # Add sensors.
    ######################
    (center_camera_stream, notify_rgb_stream,
     center_camera_setup) = pylot.operator_creator.add_rgb_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    notify_streams.append(notify_rgb_stream)
    if pylot.flags.must_add_depth_camera_sensor():
        (depth_camera_stream, notify_depth_stream,
         depth_camera_setup) = pylot.operator_creator.add_depth_camera(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        depth_camera_stream = None
    if pylot.flags.must_add_segmented_camera_sensor():
        (ground_segmented_stream, notify_segmented_stream,
         _) = pylot.operator_creator.add_segmented_camera(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        ground_segmented_stream = None

    if pylot.flags.must_add_lidar_sensor():
        # Place LiDAR sensor in the same location as the center camera.
        (point_cloud_stream, notify_lidar_stream,
         lidar_setup) = pylot.operator_creator.add_lidar(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        point_cloud_stream = None
        lidar_setup = None

    if FLAGS.obstacle_location_finder_sensor == 'lidar':
        depth_stream = point_cloud_stream
        # Camera sensors are slower than the lidar sensor.
        notify_streams.append(notify_lidar_stream)
    elif FLAGS.obstacle_location_finder_sensor == 'depth_camera':
        depth_stream = depth_camera_stream
        notify_streams.append(notify_depth_stream)
    else:
        raise ValueError(
            'Unknown --obstacle_location_finder_sensor value {}'.format(
                FLAGS.obstacle_location_finder_sensor))

    imu_stream = None
    if pylot.flags.must_add_imu_sensor():
        (imu_stream, _) = pylot.operator_creator.add_imu(
            pylot.utils.Transform(location=pylot.utils.Location(),
                                  rotation=pylot.utils.Rotation()),
            vehicle_id_stream)

    gnss_stream = None
    if pylot.flags.must_add_gnss_sensor():
        (gnss_stream, _) = pylot.operator_creator.add_gnss(
            pylot.utils.Transform(location=pylot.utils.Location(),
                                  rotation=pylot.utils.Rotation()),
            vehicle_id_stream)

    if FLAGS.localization:
        pose_stream = pylot.operator_creator.add_localization(
            imu_stream, gnss_stream, pose_stream)

    ######################
    # Add detection.
    ######################

    # obstacles_stream, perfect_obstacles_stream = \
    #     pylot.component_creator.add_obstacle_detection(
    #         center_camera_stream, center_camera_setup, pose_stream,
    #         depth_stream, depth_camera_stream, ground_segmented_stream,
    #         ground_obstacles_stream, ground_speed_limit_signs_stream,
    #         ground_stop_signs_stream, time_to_decision_loop_stream)
    # tl_transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
    #                                      pylot.utils.Rotation())
    # traffic_lights_stream, tl_camera_stream = \
    #     pylot.component_creator.add_traffic_light_detection(
    #         tl_transform, vehicle_id_stream, release_sensor_stream,
    #         pose_stream, depth_stream, ground_traffic_lights_stream)
    #
    # lane_detection_stream = pylot.component_creator.add_lane_detection(
    #     center_camera_stream, pose_stream, open_drive_stream)
    # if lane_detection_stream is None:
    #     lane_detection_stream = erdos.IngestStream()
    #     streams_to_send_top_on.append(lane_detection_stream)
    #
    # obstacles_tracking_stream = pylot.component_creator.add_obstacle_tracking(
    #     center_camera_stream, center_camera_setup, obstacles_stream,
    #     depth_stream, vehicle_id_stream, pose_stream, ground_obstacles_stream,
    #     time_to_decision_loop_stream)
    #
    # segmented_stream = pylot.component_creator.add_segmentation(
    #     center_camera_stream, ground_segmented_stream)
    #
    # depth_stream = pylot.component_creator.add_depth(transform,
    #                                                  vehicle_id_stream,
    #                                                  center_camera_setup,
    #                                                  depth_camera_stream)

    ######################
    # Add prediction?.
    ######################

    # if FLAGS.fusion:
    #     pylot.operator_creator.add_fusion(pose_stream, obstacles_stream,
    #                                       depth_stream,
    #                                       ground_obstacles_stream)
    #
    # prediction_stream, prediction_camera_stream, notify_prediction_stream = \
    #     pylot.component_creator.add_prediction(
    #         obstacles_tracking_stream, vehicle_id_stream, transform,
    #         release_sensor_stream, pose_stream, point_cloud_stream,
    #         lidar_setup)
    # if prediction_stream is None:
    #     prediction_stream = obstacles_stream
    # if notify_prediction_stream:
    #     notify_streams.append(notify_prediction_stream)

    ######################
    # Add planning?.
    ######################

    # goal_location = pylot.utils.Location(float(FLAGS.goal_location[0]),
    #                                      float(FLAGS.goal_location[1]),
    #                                      float(FLAGS.goal_location[2]))
    # waypoints_stream = pylot.component_creator.add_planning(
    #     goal_location, pose_stream, prediction_stream, traffic_lights_stream,
    #     lane_detection_stream, open_drive_stream, global_trajectory_stream,
    #     time_to_decision_loop_stream)
    #
    # if FLAGS.carla_mode == "pseudo-asynchronous":
    #     # Add a synchronizer in the pseudo-asynchronous mode.
    #     (
    #         waypoints_stream_for_control,
    #         pose_stream_for_control,
    #         sensor_ready_stream,
    #         _pipeline_finish_notify_stream,
    #     ) = pylot.operator_creator.add_planning_pose_synchronizer(
    #         waypoints_stream, pose_stream_for_control, pose_stream,
    #         *notify_streams)
    #     release_sensor_stream.set(sensor_ready_stream)
    #     pipeline_finish_notify_stream.set(_pipeline_finish_notify_stream)
    # else:
    #     waypoints_stream_for_control = waypoints_stream
    #     pose_stream_for_control = pose_stream

    ######################
    # Add control.
    ######################

    # control_stream = pylot.component_creator.add_control(
    #     pose_stream_for_control, waypoints_stream_for_control,
    #     vehicle_id_stream, perfect_obstacles_stream)

    from test_operator import TestOperator
    op_config = erdos.OperatorConfig(name='test_operator',
                                     flow_watermarks=False,
                                     log_file_name=FLAGS.log_file_name,
                                     csv_log_file_name=FLAGS.csv_log_file_name,
                                     profile_file_name=FLAGS.profile_file_name)
    [control_stream] = erdos.connect(TestOperator, op_config,
                                     [center_camera_stream], FLAGS)
    control_loop_stream.set(control_stream)

    # add_evaluation_operators(vehicle_id_stream, pose_stream, imu_stream,
    #                          pose_stream_for_control,
    #                          waypoints_stream_for_control)

    ######################
    # Add ?.
    ######################
    # 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)

    control_display_stream = None
    ###########################################################################
    # if pylot.flags.must_visualize():
    #     control_display_stream, ingest_streams = \
    #         pylot.operator_creator.add_visualizer(
    #             pose_stream, center_camera_stream, tl_camera_stream,
    #             prediction_camera_stream, depth_camera_stream,
    #             point_cloud_stream, segmented_stream, imu_stream,
    #             obstacles_stream, traffic_lights_stream,
    #             obstacles_tracking_stream, lane_detection_stream,
    #             prediction_stream, waypoints_stream, control_stream)
    #     streams_to_send_top_on += ingest_streams
    if pylot.flags.must_visualize():
        control_display_stream, ingest_streams = \
            pylot.operator_creator.add_visualizer(
                pose_stream, center_camera_stream, None,
                None, depth_camera_stream,
                point_cloud_stream, None, imu_stream,
                None, None,
                None, None,
                None, None, None)
        streams_to_send_top_on += ingest_streams
    ############################################################################

    node_handle = erdos.run_async()

    for stream in streams_to_send_top_on:
        stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
    # If we did not use the pseudo-asynchronous mode, ask the sensors to
    # release their readings whenever.
    if FLAGS.carla_mode != "pseudo-asynchronous":
        release_sensor_stream.send(
            erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
        pipeline_finish_notify_stream.send(
            erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))

    return node_handle, control_display_stream
예제 #17
0
파일: lincoln.py 프로젝트: ymote/pylot
def main(argv):
    (obstacles_stream, traffic_lights_stream, obstacles_tracking_stream,
     open_drive_stream, global_trajectory_stream, control_display_stream,
     streams_to_send_top_on) = create_data_flow()
    # Run the data-flow.
    node_handle = erdos.run_async()
    signal.signal(signal.SIGINT, shutdown)

    # Send waypoints.
    waypoints = Waypoints.read_from_csv_file(FLAGS.waypoints_csv_file,
                                             FLAGS.target_speed)
    global_trajectory_stream.send(
        WaypointsMessage(
            erdos.Timestamp(coordinates=[0]), waypoints,
            pylot.planning.utils.BehaviorPlannerState.FOLLOW_WAYPOINTS))

    # Send top watermark on all streams that require it.
    top_msg = erdos.WatermarkMessage(erdos.Timestamp(is_top=True))
    open_drive_stream.send(top_msg)
    global_trajectory_stream.send(top_msg)
    for stream in streams_to_send_top_on:
        stream.send(top_msg)

    time_to_sleep = 1.0 / FLAGS.sensor_frequency
    count = 0
    try:
        while True:
            timestamp = erdos.Timestamp(coordinates=[count])
            if not FLAGS.obstacle_detection:
                obstacles_stream.send(ObstaclesMessage(timestamp, []))
                obstacles_stream.send(erdos.WatermarkMessage(timestamp))
            if not FLAGS.traffic_light_detection:
                traffic_lights_stream.send(TrafficLightsMessage(timestamp, []))
                traffic_lights_stream.send(erdos.WatermarkMessage(timestamp))
            if not FLAGS.obstacle_tracking:
                obstacles_tracking_stream.send(
                    ObstacleTrajectoriesMessage(timestamp, []))
                obstacles_tracking_stream.send(
                    erdos.WatermarkMessage(timestamp))
            count += 1
            if pylot.flags.must_visualize():
                import pygame
                from pygame.locals import K_n
                events = pygame.event.get()
                for event in events:
                    if event.type == pygame.KEYUP:
                        if event.key == K_n:
                            control_display_stream.send(
                                erdos.Message(erdos.Timestamp(coordinates=[0]),
                                              event.key))
                    elif event.type == pygame.QUIT:
                        raise KeyboardInterrupt
                    elif event.type == pygame.KEYDOWN:
                        if (event.key == pygame.K_c
                                and pygame.key.get_mods() & pygame.KMOD_CTRL):
                            raise KeyboardInterrupt

            # NOTE: We should offset sleep time by the time it takes to send
            # the messages.
            time.sleep(time_to_sleep)
    except KeyboardInterrupt:
        node_handle.shutdown()
        if pylot.flags.must_visualize():
            import pygame
            pygame.quit()
예제 #18
0
        write_stream.send(msg)

    @staticmethod
    def connect(read_streams):
        return [erdos.WriteStream()]


def driver():
    ingest_stream = erdos.IngestStream()
    (square_stream, ) = erdos.connect(SquareOp, [ingest_stream])
    extract_stream = erdos.ExtractStream(square_stream)

    return ingest_stream, extract_stream


if __name__ == "__main__":
    ingest_stream, extract_stream = erdos.run_async(driver)

    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)
        ingest_stream.send(erdos.WatermarkMessage(timestamp))
        recv_msg = extract_stream.read()
        print("ExtractStream: received {recv_msg}".format(recv_msg=recv_msg))

        count += 1
        time.sleep(1)
예제 #19
0
def main(argv):
    transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                      pylot.utils.Rotation())

    control_loop_stream = erdos.LoopStream()
    release_sensor_stream = erdos.IngestStream()
    pipeline_finish_notify_stream = erdos.IngestStream()
    # Create an operator that connects to the simulator.
    (
        pose_stream,
        pose_stream_for_control,
        ground_traffic_lights_stream,
        ground_obstacles_stream,
        ground_speed_limit_signs_stream,
        ground_stop_signs_stream,
        vehicle_id_stream,
        open_drive_stream,
        global_trajectory_stream,
    ) = pylot.operator_creator.add_simulator_bridge(
        control_loop_stream, release_sensor_stream,
        pipeline_finish_notify_stream)

    # Add sensors.
    (center_camera_stream, notify_rgb_stream,
     rgb_camera_setup) = pylot.operator_creator.add_rgb_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    (depth_camera_stream, _,
     depth_camera_setup) = pylot.operator_creator.add_depth_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    (segmented_stream, _,
     _) = pylot.operator_creator.add_segmented_camera(transform,
                                                      vehicle_id_stream,
                                                      release_sensor_stream)

    if FLAGS.log_rgb_camera:
        pylot.operator_creator.add_camera_logging(
            center_camera_stream, 'center_camera_logger_operator', 'center-')

    if FLAGS.log_segmented_camera:
        pylot.operator_creator.add_camera_logging(
            segmented_stream, 'center_segmented_camera_logger_operator',
            'segmented-')

    if FLAGS.log_depth_camera:
        pylot.operator_creator.add_camera_logging(
            depth_camera_stream, 'depth_camera_logger_operator', 'depth-')

    imu_stream = None
    if FLAGS.log_imu:
        (imu_stream,
         _) = pylot.operator_creator.add_imu(transform, vehicle_id_stream)
        pylot.operator_creator.add_imu_logging(imu_stream)

    traffic_lights_stream = None
    traffic_light_camera_stream = None
    if FLAGS.log_traffic_lights:
        (traffic_light_camera_stream, _,
         traffic_light_camera_setup) = pylot.operator_creator.add_rgb_camera(
             transform, vehicle_id_stream, release_sensor_stream,
             'traffic_light_camera', 45)
        pylot.operator_creator.add_camera_logging(
            traffic_light_camera_stream,
            'traffic_light_camera_logger_operator', 'traffic-light-')
        (traffic_light_segmented_camera_stream, _, _) = \
            pylot.operator_creator.add_segmented_camera(
                transform,
                vehicle_id_stream,
                release_sensor_stream,
                'traffic_light_segmented_camera',
                45)
        (traffic_light_depth_camera_stream, _, _) = \
            pylot.operator_creator.add_depth_camera(
                transform, vehicle_id_stream, release_sensor_stream,
                'traffic_light_depth_camera', 45)
        traffic_lights_stream = \
            pylot.operator_creator.add_perfect_traffic_light_detector(
                ground_traffic_lights_stream,
                traffic_light_camera_stream,
                traffic_light_depth_camera_stream,
                traffic_light_segmented_camera_stream,
                pose_stream)
        pylot.operator_creator.add_bounding_box_logging(traffic_lights_stream)

    if FLAGS.log_left_right_cameras:
        (left_camera_stream, right_camera_stream, _,
         _) = pylot.operator_creator.add_left_right_cameras(
             transform, vehicle_id_stream, release_sensor_stream)
        pylot.operator_creator.add_camera_logging(
            left_camera_stream, 'left_camera_logger_operator', 'left-')
        pylot.operator_creator.add_camera_logging(
            right_camera_stream, 'right_camera_logger_operator', 'right-')

    point_cloud_stream = None
    if FLAGS.log_lidar:
        (point_cloud_stream, _,
         _) = pylot.operator_creator.add_lidar(transform, vehicle_id_stream,
                                               release_sensor_stream)
        pylot.operator_creator.add_lidar_logging(point_cloud_stream)

    obstacles_stream = None
    if FLAGS.log_obstacles:
        obstacles_stream = pylot.operator_creator.add_perfect_detector(
            depth_camera_stream, center_camera_stream, segmented_stream,
            pose_stream, ground_obstacles_stream,
            ground_speed_limit_signs_stream, ground_stop_signs_stream)
        pylot.operator_creator.add_bounding_box_logging(obstacles_stream)

    if FLAGS.log_multiple_object_tracker:
        pylot.operator_creator.add_multiple_object_tracker_logging(
            obstacles_stream)

    obstacles_tracking_stream = None
    if FLAGS.log_trajectories or FLAGS.log_chauffeur:
        obstacles_tracking_stream = \
            pylot.operator_creator.add_perfect_tracking(
                vehicle_id_stream,
                ground_obstacles_stream,
                pose_stream)
        if FLAGS.log_trajectories:
            pylot.operator_creator.add_trajectory_logging(
                obstacles_tracking_stream)

    top_down_segmented_stream = None
    top_down_camera_setup = None
    if FLAGS.log_chauffeur or FLAGS.log_top_down_segmentation:
        top_down_transform = pylot.utils.get_top_down_transform(
            transform, FLAGS.top_down_camera_altitude)
        (top_down_segmented_stream, _, _) = \
            pylot.operator_creator.add_segmented_camera(
                top_down_transform,
                vehicle_id_stream,
                release_sensor_stream,
                name='top_down_segmented_camera',
                fov=90)

        if FLAGS.log_top_down_segmentation:
            pylot.operator_creator.add_camera_logging(
                top_down_segmented_stream,
                'top_down_segmented_logger_operator', 'top-down-segmented-')

        if FLAGS.log_chauffeur:
            (top_down_camera_stream,
             top_down_camera_setup) = \
                pylot.operator_creator.add_rgb_camera(
                    top_down_transform,
                    vehicle_id_stream,
                    name='top_down_rgb_camera',
                    fov=90)
            pylot.operator_creator.add_chauffeur_logging(
                vehicle_id_stream, pose_stream, obstacles_tracking_stream,
                top_down_camera_stream, top_down_segmented_stream,
                top_down_camera_setup)

    # TODO: Hack! We synchronize on a single stream, based on a guesestimate
    # of which stream is slowest. Instead, We should synchronize on all output
    # streams, and we should ensure that even the operators without output
    # streams complete.
    if FLAGS.control == 'simulator_auto_pilot':
        # We insert a synchronizing operator that sends back a command when
        # the low watermark progresses on all input stream.
        stream_to_sync_on = center_camera_stream
        if obstacles_tracking_stream is not None:
            stream_to_sync_on = obstacles_tracking_stream
        if traffic_lights_stream is not None:
            stream_to_sync_on = traffic_lights_stream
        if obstacles_stream is not None:
            stream_to_sync_on = obstacles_stream
        control_stream = pylot.operator_creator.add_synchronizer(
            vehicle_id_stream, stream_to_sync_on)
        control_loop_stream.set(control_stream)
    else:
        raise ValueError(
            "Must be in auto pilot mode. Pass --control=simulator_auto_pilot")

    control_display_stream = None
    streams_to_send_top_on = []
    if pylot.flags.must_visualize():
        control_display_stream, ingest_streams = \
            pylot.operator_creator.add_visualizer(
                pose_stream=pose_stream,
                camera_stream=center_camera_stream,
                tl_camera_stream=traffic_light_camera_stream,
                depth_stream=depth_camera_stream,
                point_cloud_stream=point_cloud_stream,
                segmentation_stream=segmented_stream,
                imu_stream=imu_stream,
                obstacles_stream=obstacles_stream,
                traffic_lights_stream=traffic_lights_stream,
                tracked_obstacles_stream=obstacles_tracking_stream)
        streams_to_send_top_on += ingest_streams

    # Connect an instance to the simulator to make sure that we can turn the
    # synchronous mode off after the script finishes running.
    client, world = pylot.simulation.utils.get_world(FLAGS.simulator_host,
                                                     FLAGS.simulator_port,
                                                     FLAGS.simulator_timeout)

    # Run the data-flow.
    node_handle = erdos.run_async()

    signal.signal(signal.SIGINT, shutdown)

    # Ask all sensors to release their data.
    release_sensor_stream.send(
        erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
    for stream in streams_to_send_top_on:
        stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))

    try:
        if pylot.flags.must_visualize():
            pylot.utils.run_visualizer_control_loop(control_display_stream)
        node_handle.wait()
    except KeyboardInterrupt:
        node_handle.shutdown()
        pylot.simulation.utils.set_asynchronous_mode(world)
        if pylot.flags.must_visualize():
            import pygame
            pygame.quit()
예제 #20
0
파일: pylot_old.py 프로젝트: ayjchen1/pylot
def driver():
    transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                      pylot.utils.Rotation(pitch=-15))
    streams_to_send_top_on = []
    control_loop_stream = erdos.LoopStream()
    time_to_decision_loop_stream = erdos.LoopStream()
    if FLAGS.simulator_mode == 'pseudo-asynchronous':
        release_sensor_stream = erdos.LoopStream()
        pipeline_finish_notify_stream = erdos.LoopStream()
    else:
        release_sensor_stream = erdos.IngestStream()
        pipeline_finish_notify_stream = erdos.IngestStream()
    notify_streams = []

    # Create operator that bridges between pipeline and the simulator.
    (
        pose_stream,
        pose_stream_for_control,
        ground_traffic_lights_stream,
        ground_obstacles_stream,
        ground_speed_limit_signs_stream,
        ground_stop_signs_stream,
        vehicle_id_stream,
        open_drive_stream,
        global_trajectory_stream,
    ) = pylot.operator_creator.add_simulator_bridge(
        control_loop_stream,
        release_sensor_stream,
        pipeline_finish_notify_stream,
    )

    # Add sensors.
    (center_camera_stream, notify_rgb_stream,
     center_camera_setup) = pylot.operator_creator.add_rgb_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    notify_streams.append(notify_rgb_stream)
    if pylot.flags.must_add_depth_camera_sensor():
        (depth_camera_stream, notify_depth_stream,
         depth_camera_setup) = pylot.operator_creator.add_depth_camera(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        depth_camera_stream = None
    if pylot.flags.must_add_segmented_camera_sensor():
        (ground_segmented_stream, notify_segmented_stream,
         _) = pylot.operator_creator.add_segmented_camera(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        ground_segmented_stream = None

    if pylot.flags.must_add_lidar_sensor():
        # Place LiDAR sensor in the same location as the center camera.
        (point_cloud_stream, notify_lidar_stream,
         lidar_setup) = pylot.operator_creator.add_lidar(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        point_cloud_stream = None
        lidar_setup = None

    if FLAGS.obstacle_location_finder_sensor == 'lidar':
        depth_stream = point_cloud_stream
        # Camera sensors are slower than the lidar sensor.
        notify_streams.append(notify_lidar_stream)
    elif FLAGS.obstacle_location_finder_sensor == 'depth_camera':
        depth_stream = depth_camera_stream
        notify_streams.append(notify_depth_stream)
    else:
        raise ValueError(
            'Unknown --obstacle_location_finder_sensor value {}'.format(
                FLAGS.obstacle_location_finder_sensor))

    imu_stream = None
    if pylot.flags.must_add_imu_sensor():
        (imu_stream, _) = pylot.operator_creator.add_imu(
            pylot.utils.Transform(location=pylot.utils.Location(),
                                  rotation=pylot.utils.Rotation()),
            vehicle_id_stream)

    gnss_stream = None
    if pylot.flags.must_add_gnss_sensor():
        (gnss_stream, _) = pylot.operator_creator.add_gnss(
            pylot.utils.Transform(location=pylot.utils.Location(),
                                  rotation=pylot.utils.Rotation()),
            vehicle_id_stream)

    if FLAGS.localization:
        pose_stream = pylot.operator_creator.add_localization(
            imu_stream, gnss_stream, pose_stream)

    obstacles_stream, perfect_obstacles_stream, obstacles_error_stream = \
        pylot.component_creator.add_obstacle_detection(
            center_camera_stream, center_camera_setup, pose_stream,
            depth_stream, depth_camera_stream, ground_segmented_stream,
            ground_obstacles_stream, ground_speed_limit_signs_stream,
            ground_stop_signs_stream, time_to_decision_loop_stream)

    tl_transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                         pylot.utils.Rotation())
    traffic_lights_stream, tl_camera_stream = \
        pylot.component_creator.add_traffic_light_detection(
            tl_transform, vehicle_id_stream, release_sensor_stream,
            pose_stream, depth_stream, ground_traffic_lights_stream)

    lane_detection_stream = pylot.component_creator.add_lane_detection(
        center_camera_stream, pose_stream, open_drive_stream)
    if lane_detection_stream is None:
        lane_detection_stream = erdos.IngestStream()
        streams_to_send_top_on.append(lane_detection_stream)

    obstacles_tracking_stream = pylot.component_creator.add_obstacle_tracking(
        center_camera_stream, center_camera_setup, obstacles_stream,
        depth_stream, vehicle_id_stream, pose_stream, ground_obstacles_stream,
        time_to_decision_loop_stream)

    segmented_stream = pylot.component_creator.add_segmentation(
        center_camera_stream, ground_segmented_stream)

    depth_stream = pylot.component_creator.add_depth(transform,
                                                     vehicle_id_stream,
                                                     center_camera_setup,
                                                     depth_camera_stream)

    if FLAGS.fusion:
        pylot.operator_creator.add_fusion(pose_stream, obstacles_stream,
                                          depth_stream,
                                          ground_obstacles_stream)

    prediction_stream, prediction_camera_stream, notify_prediction_stream = \
        pylot.component_creator.add_prediction(
            obstacles_tracking_stream, vehicle_id_stream, transform,
            release_sensor_stream, pose_stream, point_cloud_stream,
            lidar_setup)
    if prediction_stream is None:
        prediction_stream = obstacles_stream
    if notify_prediction_stream:
        notify_streams.append(notify_prediction_stream)

    goal_location = pylot.utils.Location(float(FLAGS.goal_location[0]),
                                         float(FLAGS.goal_location[1]),
                                         float(FLAGS.goal_location[2]))
    waypoints_stream = pylot.component_creator.add_planning(
        goal_location, pose_stream, prediction_stream, traffic_lights_stream,
        lane_detection_stream, open_drive_stream, global_trajectory_stream,
        time_to_decision_loop_stream)

    if FLAGS.simulator_mode == "pseudo-asynchronous":
        # Add a synchronizer in the pseudo-asynchronous mode.
        (
            waypoints_stream_for_control,
            pose_stream_for_control,
            sensor_ready_stream,
            _pipeline_finish_notify_stream,
        ) = pylot.operator_creator.add_planning_pose_synchronizer(
            waypoints_stream, pose_stream_for_control, pose_stream,
            *notify_streams)
        release_sensor_stream.set(sensor_ready_stream)
        pipeline_finish_notify_stream.set(_pipeline_finish_notify_stream)
    else:
        waypoints_stream_for_control = waypoints_stream
        pose_stream_for_control = pose_stream

    control_stream = pylot.component_creator.add_control(
        pose_stream_for_control, waypoints_stream_for_control,
        vehicle_id_stream, perfect_obstacles_stream)
    control_loop_stream.set(control_stream)

    add_evaluation_operators(vehicle_id_stream, pose_stream, imu_stream,
                             pose_stream_for_control,
                             waypoints_stream_for_control)

    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)

    control_display_stream = None
    if pylot.flags.must_visualize():
        control_display_stream, ingest_streams = \
            pylot.operator_creator.add_visualizer(
                pose_stream, center_camera_stream, tl_camera_stream,
                prediction_camera_stream, depth_camera_stream,
                point_cloud_stream, segmented_stream, imu_stream,
                obstacles_stream, obstacles_error_stream, traffic_lights_stream,
                obstacles_tracking_stream, lane_detection_stream,
                prediction_stream, waypoints_stream, control_stream)
        streams_to_send_top_on += ingest_streams

    node_handle = erdos.run_async()

    for stream in streams_to_send_top_on:
        stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
    # If we did not use the pseudo-asynchronous mode, ask the sensors to
    # release their readings whenever.
    if FLAGS.simulator_mode != "pseudo-asynchronous":
        release_sensor_stream.send(
            erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
        pipeline_finish_notify_stream.send(
            erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))

    return node_handle, control_display_stream
예제 #21
0
파일: pylot.py 프로젝트: fangedward/pylot
def driver():
    transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                      pylot.utils.Rotation())

    control_loop_stream = erdos.LoopStream()
    time_to_decision_loop_stream = erdos.LoopStream()
    if FLAGS.carla_mode == 'pseudo-asynchronous':
        release_sensor_stream = erdos.LoopStream()
    else:
        release_sensor_stream = erdos.IngestStream()
    notify_streams = []

    # Create carla operator.
    (
        pose_stream,
        pose_stream_for_control,
        ground_traffic_lights_stream,
        ground_obstacles_stream,
        ground_speed_limit_signs_stream,
        ground_stop_signs_stream,
        vehicle_id_stream,
        open_drive_stream,
        global_trajectory_stream,
    ) = pylot.operator_creator.add_carla_bridge(control_loop_stream,
                                                release_sensor_stream)

    # Add sensors.
    (center_camera_stream, notify_rgb_stream,
     rgb_camera_setup) = pylot.operator_creator.add_rgb_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    notify_streams.append(notify_rgb_stream)
    if pylot.flags.must_add_depth_camera_sensor():
        (depth_camera_stream, notify_depth_stream,
         depth_camera_setup) = pylot.operator_creator.add_depth_camera(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        depth_camera_stream = None
    if pylot.flags.must_add_segmented_camera_sensor():
        (ground_segmented_stream, notify_segmented_stream,
         _) = pylot.operator_creator.add_segmented_camera(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        ground_segmented_stream = None

    if pylot.flags.must_add_lidar_sensor():
        # Place Lidar sensor in the same location as the center camera.
        (point_cloud_stream, notify_lidar_stream,
         lidar_setup) = pylot.operator_creator.add_lidar(
             transform, vehicle_id_stream, release_sensor_stream)
    else:
        point_cloud_stream = None

    if FLAGS.obstacle_location_finder_sensor == 'lidar':
        depth_stream = point_cloud_stream
        # Camera sensors are slower than the lidar sensor.
        notify_streams.append(notify_lidar_stream)
    elif FLAGS.obstacle_location_finder_sensor == 'depth_camera':
        depth_stream = depth_camera_stream
        notify_streams.append(notify_depth_stream)
    else:
        raise ValueError(
            'Unknown --obstacle_location_finder_sensor value {}'.format(
                FLAGS.obstacle_location_finder_sensor))

    imu_stream = None
    if pylot.flags.must_add_imu_sensor():
        (imu_stream,
         _) = pylot.operator_creator.add_imu(transform, vehicle_id_stream)

    obstacles_stream = \
        pylot.component_creator.add_obstacle_detection(
            center_camera_stream, rgb_camera_setup, pose_stream,
            depth_stream, depth_camera_stream, ground_segmented_stream,
            ground_obstacles_stream, ground_speed_limit_signs_stream,
            ground_stop_signs_stream, time_to_decision_loop_stream)
    traffic_lights_stream = \
        pylot.component_creator.add_traffic_light_detection(
            transform, vehicle_id_stream, release_sensor_stream, pose_stream,
            depth_stream, ground_traffic_lights_stream)

    lane_detection_stream = pylot.component_creator.add_lane_detection(
        center_camera_stream, pose_stream)

    obstacles_tracking_stream = pylot.component_creator.add_obstacle_tracking(
        center_camera_stream, rgb_camera_setup, obstacles_stream, depth_stream,
        vehicle_id_stream, pose_stream, ground_obstacles_stream,
        time_to_decision_loop_stream)

    segmented_stream = pylot.component_creator.add_segmentation(
        center_camera_stream, ground_segmented_stream)

    depth_stream = pylot.component_creator.add_depth(transform,
                                                     vehicle_id_stream,
                                                     rgb_camera_setup,
                                                     depth_camera_stream)

    if FLAGS.fusion:
        pylot.operator_creator.add_fusion(pose_stream, obstacles_stream,
                                          depth_stream,
                                          ground_obstacles_stream)

    prediction_stream = pylot.component_creator.add_prediction(
        obstacles_tracking_stream, vehicle_id_stream, transform,
        release_sensor_stream, pose_stream, point_cloud_stream, lidar_setup)

    # Add planning operators.
    goal_location = pylot.utils.Location(float(FLAGS.goal_location[0]),
                                         float(FLAGS.goal_location[1]),
                                         float(FLAGS.goal_location[2]))
    waypoints_stream = pylot.component_creator.add_planning(
        goal_location, pose_stream, prediction_stream, center_camera_stream,
        obstacles_stream, traffic_lights_stream, open_drive_stream,
        global_trajectory_stream, time_to_decision_loop_stream)

    # Add a synchronizer in the pseudo-asynchronous mode.
    if FLAGS.carla_mode == "pseudo-asynchronous":
        (
            waypoints_stream_for_control,
            pose_stream_for_control,
            sensor_ready_stream,
        ) = pylot.operator_creator.add_planning_pose_synchronizer(
            waypoints_stream, pose_stream_for_control, pose_stream,
            *notify_streams)
        release_sensor_stream.set(sensor_ready_stream)
    else:
        waypoints_stream_for_control = waypoints_stream
        pose_stream_for_control = pose_stream

    # Add the behaviour planning and control operator.
    control_stream = pylot.component_creator.add_control(
        pose_stream_for_control, waypoints_stream_for_control)
    control_loop_stream.set(control_stream)

    if FLAGS.evaluation:
        # Add the collision sensor.
        collision_stream = pylot.operator_creator.add_collision_sensor(
            vehicle_id_stream)

        # Add the lane invasion sensor.
        lane_invasion_stream = pylot.operator_creator.add_lane_invasion_sensor(
            vehicle_id_stream)

        # Add the traffic light invasion sensor.
        traffic_light_invasion_stream = \
            pylot.operator_creator.add_traffic_light_invasion_sensor(
                vehicle_id_stream, pose_stream)

        # Add the evaluation logger.
        pylot.operator_creator.add_eval_metric_logging(
            collision_stream, lane_invasion_stream,
            traffic_light_invasion_stream, imu_stream, pose_stream,
            obstacles_stream)

        # Add control evaluation logging operator.
        pylot.operator_creator.add_control_evaluation(
            pose_stream_for_control, waypoints_stream_for_control)

    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)

    pylot.operator_creator.add_sensor_visualizers(center_camera_stream,
                                                  depth_camera_stream,
                                                  point_cloud_stream,
                                                  ground_segmented_stream,
                                                  imu_stream, pose_stream)
    erdos.run_async()

    # If we did not use the pseudo-asynchronous mode, ask the sensors to
    # release their readings whenever.
    if FLAGS.carla_mode != "pseudo-asynchronous":
        release_sensor_stream.send(
            erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
예제 #22
0
def main(argv):
    transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                      pylot.utils.Rotation())

    control_loop_stream = erdos.LoopStream()
    release_sensor_stream = erdos.IngestStream()
    # Create carla operator.
    (
        pose_stream,
        pose_stream_for_control,
        ground_traffic_lights_stream,
        ground_obstacles_stream,
        ground_speed_limit_signs_stream,
        ground_stop_signs_stream,
        vehicle_id_stream,
        open_drive_stream,
        global_trajectory_stream,
    ) = pylot.operator_creator.add_carla_bridge(control_loop_stream,
                                                release_sensor_stream)

    # Add sensors.
    (center_camera_stream, notify_rgb_stream,
     rgb_camera_setup) = pylot.operator_creator.add_rgb_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    (depth_camera_stream, _,
     depth_camera_setup) = pylot.operator_creator.add_depth_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    (segmented_stream, _,
     _) = pylot.operator_creator.add_segmented_camera(transform,
                                                      vehicle_id_stream,
                                                      release_sensor_stream)

    if FLAGS.log_rgb_camera:
        pylot.operator_creator.add_camera_logging(
            center_camera_stream, 'center_camera_logger_operator',
            'carla-center-')

    if FLAGS.log_segmented_camera:
        pylot.operator_creator.add_camera_logging(
            segmented_stream, 'center_segmented_camera_logger_operator',
            'carla-segmented-')

    if FLAGS.log_depth_camera:
        pylot.operator_creator.add_camera_logging(
            depth_camera_stream, 'depth_camera_logger_operator',
            'carla-depth-')

    imu_stream = None
    if FLAGS.log_imu:
        (imu_stream,
         _) = pylot.operator_creator.add_imu(transform, vehicle_id_stream)
        pylot.operator_creator.add_imu_logging(imu_stream)

    traffic_lights_stream = None
    if FLAGS.log_traffic_lights:
        (traffic_light_camera_stream, _,
         traffic_light_camera_setup) = pylot.operator_creator.add_rgb_camera(
             transform, vehicle_id_stream, release_sensor_stream,
             'traffic_light_camera', 45)
        pylot.operator_creator.add_camera_logging(
            traffic_light_camera_stream,
            'traffic_light_camera_logger_operator', 'carla-traffic-light-')
        (traffic_light_segmented_camera_stream, _, _) = \
            pylot.operator_creator.add_segmented_camera(
                transform,
                vehicle_id_stream,
                release_sensor_stream,
                'traffic_light_segmented_camera',
                45)
        (traffic_light_depth_camera_stream, _, _) = \
            pylot.operator_creator.add_depth_camera(
                transform, vehicle_id_stream, release_sensor_stream,
                'traffic_light_depth_camera', 45)
        traffic_lights_stream = \
            pylot.operator_creator.add_perfect_traffic_light_detector(
                ground_traffic_lights_stream,
                traffic_light_camera_stream,
                traffic_light_depth_camera_stream,
                traffic_light_segmented_camera_stream,
                pose_stream)
        pylot.operator_creator.add_bounding_box_logging(traffic_lights_stream)

    if FLAGS.log_left_right_cameras:
        (left_camera_stream, right_camera_stream, _,
         _) = pylot.operator_creator.add_left_right_cameras(
             transform, vehicle_id_stream, release_sensor_stream)
        pylot.operator_creator.add_camera_logging(
            left_camera_stream, 'left_camera_logger_operator', 'carla-left-')
        pylot.operator_creator.add_camera_logging(
            right_camera_stream, 'right_camera_logger_operator',
            'carla-right-')

    point_cloud_stream = None
    if FLAGS.log_lidar:
        (point_cloud_stream, _,
         _) = pylot.operator_creator.add_lidar(transform, vehicle_id_stream,
                                               release_sensor_stream)
        pylot.operator_creator.add_lidar_logging(point_cloud_stream)

    obstacles_stream = None
    if FLAGS.log_obstacles:
        obstacles_stream = pylot.operator_creator.add_perfect_detector(
            depth_camera_stream, center_camera_stream, segmented_stream,
            pose_stream, ground_obstacles_stream,
            ground_speed_limit_signs_stream, ground_stop_signs_stream)
        pylot.operator_creator.add_bounding_box_logging(obstacles_stream)

    if FLAGS.log_multiple_object_tracker:
        pylot.operator_creator.add_multiple_object_tracker_logging(
            obstacles_stream)

    obstacles_tracking_stream = None
    if FLAGS.log_trajectories or FLAGS.log_chauffeur:
        obstacles_tracking_stream = \
            pylot.operator_creator.add_perfect_tracking(
                ground_obstacles_stream,
                pose_stream)
        if FLAGS.log_trajectories:
            pylot.operator_creator.add_trajectory_logging(
                obstacles_tracking_stream)

    top_down_segmented_stream = None
    top_down_camera_setup = None
    if FLAGS.log_chauffeur or FLAGS.log_top_down_segmentation:
        top_down_transform = pylot.utils.get_top_down_transform(
            transform, FLAGS.top_down_lateral_view)
        (top_down_segmented_stream, _) = \
            pylot.operator_creator.add_segmented_camera(
                top_down_transform,
                vehicle_id_stream,
                name='top_down_segmented_camera',
                fov=90)

        if FLAGS.log_top_down_segmentation:
            pylot.operator_creator.add_camera_logging(
                top_down_segmented_stream,
                'top_down_segmented_logger_operator',
                'carla-top-down-segmented-')

        if FLAGS.log_chauffeur:
            (top_down_camera_stream,
             top_down_camera_setup) = \
                pylot.operator_creator.add_rgb_camera(
                    top_down_transform,
                    vehicle_id_stream,
                    name='top_down_rgb_camera',
                    fov=90)
            pylot.operator_creator.add_chauffeur_logging(
                vehicle_id_stream, pose_stream, obstacles_tracking_stream,
                top_down_camera_stream, top_down_segmented_stream,
                top_down_camera_setup)

    pylot.operator_creator.add_sensor_visualizers(center_camera_stream,
                                                  depth_camera_stream,
                                                  point_cloud_stream,
                                                  segmented_stream, imu_stream,
                                                  pose_stream)

    # TODO: Hack! We synchronize on a single stream, based on a guesestimate
    # of which stream is slowest. Instead, We should synchronize on all output
    # streams, and we should ensure that even the operators without output
    # streams complete.
    if FLAGS.control_agent == 'carla_auto_pilot':
        # We insert a synchronizing operator that sends back a command when
        # the low watermark progresses on all input stream.
        stream_to_sync_on = center_camera_stream
        if obstacles_tracking_stream is not None:
            stream_to_sync_on = obstacles_tracking_stream
        if traffic_lights_stream is not None:
            stream_to_sync_on = traffic_lights_stream
        if obstacles_stream is not None:
            stream_to_sync_on = obstacles_stream
        control_stream = pylot.operator_creator.add_synchronizer(
            stream_to_sync_on)
        control_loop_stream.set(control_stream)
    else:
        raise ValueError(
            "Must be in auto pilot mode. Pass --control_agent=carla_auto_pilot"
        )

    # Run the data-flow.
    erdos.run_async()

    # Ask all sensors to release their data.
    release_sensor_stream.send(
        erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
예제 #23
0
def main(argv):
    """ Computes ground obstacle detection and segmentation decay."""
    transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                      pylot.utils.Rotation())

    control_loop_stream = erdos.LoopStream()
    release_sensor_stream = erdos.IngestStream()
    # Create carla operator.
    (
        pose_stream,
        pose_stream_for_control,
        ground_traffic_lights_stream,
        ground_obstacles_stream,
        ground_speed_limit_signs_stream,
        ground_stop_signs_stream,
        vehicle_id_stream,
        open_drive_stream,
        global_trajectory_stream,
    ) = pylot.operator_creator.add_carla_bridge(control_loop_stream,
                                                release_sensor_stream)

    # Add camera sensors.
    (center_camera_stream, notify_rgb_stream,
     rgb_camera_setup) = pylot.operator_creator.add_rgb_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    (depth_camera_stream, notify_depth_stream,
     depth_camera_setup) = pylot.operator_creator.add_depth_camera(
         transform, vehicle_id_stream, release_sensor_stream)
    (segmented_stream, _,
     _) = pylot.operator_creator.add_segmented_camera(transform,
                                                      vehicle_id_stream,
                                                      release_sensor_stream)

    map_stream = None
    if FLAGS.compute_detection_decay:
        obstacles_stream = pylot.operator_creator.add_perfect_detector(
            depth_camera_stream, center_camera_stream, segmented_stream,
            pose_stream, ground_obstacles_stream,
            ground_speed_limit_signs_stream, ground_stop_signs_stream)
        map_stream = pylot.operator_creator.add_detection_decay(
            obstacles_stream)

    iou_stream = None
    if FLAGS.compute_segmentation_decay:
        iou_stream = pylot.operator_creator.add_segmentation_decay(
            segmented_stream)

    # TODO: Hack! We synchronize on a single stream, based on a guesestimated
    # of which stream is slowest. Instead, We should synchronize on all output
    # streams, and we should ensure that even the operators without output
    # streams complete.
    if FLAGS.control_agent == 'carla_auto_pilot':
        stream_to_sync_on = iou_stream
        if map_stream is not None:
            stream_to_sync_on = map_stream
        op_config = erdos.OperatorConfig(name='synchronizer_operator',
                                         flow_watermarks=False)
        (control_stream, ) = erdos.connect(SynchronizerOperator, op_config,
                                           [stream_to_sync_on], FLAGS)
        control_loop_stream.set(control_stream)
    else:
        raise ValueError(
            "Must be in auto pilot mode. Pass --control_agent=carla_auto_pilot"
        )

    erdos.run_async()

    # Ask all sensors to release their data.
    release_sensor_stream.send(
        erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
예제 #24
0
파일: pylot.py 프로젝트: ayjchen1/pylot
def driver():
    csv_logger = erdos.utils.setup_csv_logging("head-csv", FLAGS.csv_log_file_name)
    csv_logger.info('TIME,SIMTIME,CAMERA,GROUNDID,LABEL,X,Y,Z,ERROR')

    streams_to_send_top_on = []
    control_loop_stream = erdos.LoopStream()
    time_to_decision_loop_stream = erdos.LoopStream()
    if FLAGS.simulator_mode == 'pseudo-asynchronous':
        release_sensor_stream = erdos.LoopStream()
        pipeline_finish_notify_stream = erdos.LoopStream()
    else:
        release_sensor_stream = erdos.IngestStream()
        pipeline_finish_notify_stream = erdos.IngestStream()
    notify_streams = []

    # Create operator that bridges between pipeline and the simulator.
    (
        pose_stream,
        pose_stream_for_control,
        ground_traffic_lights_stream,
        ground_obstacles_stream,
        ground_speed_limit_signs_stream,
        ground_stop_signs_stream,
        vehicle_id_stream,
        open_drive_stream,
        global_trajectory_stream,
    ) = pylot.operator_creator.add_simulator_bridge(
        control_loop_stream,
        release_sensor_stream,
        pipeline_finish_notify_stream,
    )

    # Add sensors.
    front_transform = pylot.utils.Transform(FRONT_CAMERA_LOCATION, pylot.utils.Rotation(pitch=-5))
    back_transform = pylot.utils.Transform(BACK_CAMERA_LOCATION, pylot.utils.Rotation(pitch=0, yaw=180)) # CORRECT ROTATION?

    #camera_names = ["FRONT", "BACK"]
    #transforms = [front_transform, back_transform]
    camera_names = ["FRONT"]
    transforms = [front_transform]
    rgb_camera_streams, rgb_camera_setups, depth_camera_streams, segmented_camera_streams, point_cloud_streams, lidar_setups, depth_streams = \
            add_cameras(vehicle_id_stream, release_sensor_stream, notify_streams, transforms)

    # add a birds-eye camera

    top_down_transform = pylot.utils.get_top_down_transform(
                pylot.utils.Transform(pylot.utils.Location(),
                                      pylot.utils.Rotation()),
                                      FLAGS.top_down_camera_altitude)
    (bird_camera_stream, notify_bird_stream, bird_setup) = \
        pylot.operator_creator.add_bird_camera(top_down_transform, vehicle_id_stream, release_sensor_stream)
    notify_streams.append(notify_bird_stream)

    imu_stream = None
    if pylot.flags.must_add_imu_sensor():
        (imu_stream, _) = pylot.operator_creator.add_imu(
            pylot.utils.Transform(location=pylot.utils.Location(),
                                  rotation=pylot.utils.Rotation()),
            vehicle_id_stream)

    gnss_stream = None
    if pylot.flags.must_add_gnss_sensor():
        (gnss_stream, _) = pylot.operator_creator.add_gnss(
            pylot.utils.Transform(location=pylot.utils.Location(),
                                  rotation=pylot.utils.Rotation()),
            vehicle_id_stream)

# ----------------------------------------------------------------------------------

    #IGNORE
    if FLAGS.localization:
        pose_stream = pylot.operator_creator.add_localization(
            imu_stream, gnss_stream, pose_stream)

    # for each camera
    obstacles_streams = []
    perfect_obstacles_streams = []
    obstacles_error_streams = []
    for i in range(len(transforms)):
        transform = transforms[i]
        rgb_camera_stream = rgb_camera_streams[i]
        rgb_camera_setup = rgb_camera_setups[i]
        depth_camera_stream = depth_camera_streams[i]
        ground_segmented_stream = segmented_camera_streams[i]
        point_cloud_stream = point_cloud_streams[i]
        lidar_setup = lidar_setups[i]
        depth_stream = depth_streams[i]
        eval_name = camera_names[i] + "-eval"

        obstacles_stream, perfect_obstacles_stream, obstacles_error_stream = \
            pylot.component_creator.add_obstacle_detection(
                rgb_camera_stream, rgb_camera_setup, pose_stream,
                depth_stream, depth_camera_stream, ground_segmented_stream,
                ground_obstacles_stream, ground_speed_limit_signs_stream,
                ground_stop_signs_stream, time_to_decision_loop_stream, eval_name)

        print("CREATED COMPONENTS: ", transform.location)

        obstacles_streams.append(obstacles_stream)
        perfect_obstacles_streams.append(perfect_obstacles_stream)
        obstacles_error_streams.append(obstacles_error_stream)

    # ------------------------------------------------------------------------
    # ------------------------------------------------------------------------
    # ------------------------------------------------------------------------
    # ------------------------------------------------------------------------
    # add all of the other operators (mostly irrelevant)
    # just use the front camera for all other components
    center_camera_stream = rgb_camera_streams[0]
    center_camera_setup = rgb_camera_setups[0]
    obstacles_stream = obstacles_streams[0]
    ground_segmented_stream = segmented_camera_streams[0]
    point_cloud_stream = point_cloud_streams[0]
    depth_stream = depth_streams[0]

    tl_transform = pylot.utils.Transform(FRONT_CAMERA_LOCATION,
                                        pylot.utils.Rotation())
    # = ground, = None
    traffic_lights_stream, tl_camera_stream = \
        pylot.component_creator.add_traffic_light_detection(
            tl_transform, vehicle_id_stream, release_sensor_stream,
            pose_stream, depth_stream, ground_traffic_lights_stream)

    # = None
    lane_detection_stream = pylot.component_creator.add_lane_detection(
        center_camera_stream, pose_stream, open_drive_stream)
    if lane_detection_stream is None:
        lane_detection_stream = erdos.IngestStream()
        streams_to_send_top_on.append(lane_detection_stream)

    # = None
    obstacles_tracking_stream = pylot.component_creator.add_obstacle_tracking(
        center_camera_stream, center_camera_setup, obstacles_stream,
        depth_stream, vehicle_id_stream, pose_stream, ground_obstacles_stream,
        time_to_decision_loop_stream)

    # = None
    segmented_stream = pylot.component_creator.add_segmentation(
        center_camera_stream, ground_segmented_stream)

    # = None
    depth_stream = pylot.component_creator.add_depth(front_transform,
                                                     vehicle_id_stream,
                                                     center_camera_setup,
                                                     depth_camera_stream)

    #IGNORE
    if FLAGS.fusion:
        pylot.operator_creator.add_fusion(pose_stream, obstacles_stream,
                                          depth_stream,
                                          ground_obstacles_stream)
    # = None, = None, = None
    prediction_stream, prediction_camera_stream, notify_prediction_stream = \
        pylot.component_creator.add_prediction(
            obstacles_tracking_stream, vehicle_id_stream, front_transform,
            release_sensor_stream, pose_stream, point_cloud_stream,
            lidar_setup)
    if prediction_stream is None:
        prediction_stream = obstacles_stream
    if notify_prediction_stream:
        notify_streams.append(notify_prediction_stream)

    goal_location = pylot.utils.Location(float(FLAGS.goal_location[0]),
                                         float(FLAGS.goal_location[1]),
                                         float(FLAGS.goal_location[2]))

    waypoints_stream = pylot.component_creator.add_planning(
        goal_location, pose_stream, prediction_stream, traffic_lights_stream,
        lane_detection_stream, open_drive_stream, global_trajectory_stream,
        time_to_decision_loop_stream)

    if FLAGS.simulator_mode == "pseudo-asynchronous":
        # Add a synchronizer in the pseudo-asynchronous mode.
        (
            waypoints_stream_for_control,
            pose_stream_for_control,
            sensor_ready_stream,
            _pipeline_finish_notify_stream,
        ) = pylot.operator_creator.add_planning_pose_synchronizer(
            waypoints_stream, pose_stream_for_control, pose_stream,
            *notify_streams)
        release_sensor_stream.set(sensor_ready_stream)
        pipeline_finish_notify_stream.set(_pipeline_finish_notify_stream)
    else:
        waypoints_stream_for_control = waypoints_stream
        pose_stream_for_control = pose_stream


    # synchronizing on front perfect obstacle stream -- is that correct?
    control_stream = pylot.component_creator.add_control(
        pose_stream_for_control, waypoints_stream_for_control,
        vehicle_id_stream, perfect_obstacles_streams[0])
    control_loop_stream.set(control_stream)

    add_evaluation_operators(vehicle_id_stream, pose_stream, imu_stream,
                             pose_stream_for_control,
                             waypoints_stream_for_control)

    time_to_decision_stream = pylot.operator_creator.add_time_to_decision(
        pose_stream, obstacles_streams[0])
    time_to_decision_loop_stream.set(time_to_decision_stream)

    control_display_stream = None
    if pylot.flags.must_visualize():
        control_display_stream, ingest_streams = \
            pylot.operator_creator.add_visualizer(
                pose_stream, rgb_camera_streams, bird_camera_stream, tl_camera_stream,
                prediction_camera_stream, depth_camera_streams,
                point_cloud_streams, segmented_stream, imu_stream,
                obstacles_streams, obstacles_error_streams, perfect_obstacles_streams,
                traffic_lights_stream, obstacles_tracking_stream, lane_detection_stream,
                prediction_stream, waypoints_stream, control_stream)
        streams_to_send_top_on += ingest_streams

    node_handle = erdos.run_async()

    for stream in streams_to_send_top_on:
        stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
    # If we did not use the pseudo-asynchronous mode, ask the sensors to
    # release their readings whenever.
    if FLAGS.simulator_mode != "pseudo-asynchronous":
        release_sensor_stream.send(
            erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
        pipeline_finish_notify_stream.send(
            erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))

    return node_handle, control_display_stream