Esempio n. 1
0
def run_graph(spin):
    graph = erdos.graph.get_current_graph()
    first = graph.add(FirstOp, name='first')
    second = graph.add(SecondOp, name='second', init_args={'spin': spin})
    graph.connect([first], [second])
    graph.connect([second], [first])
    graph.execute(FLAGS.framework)
Esempio n. 2
0
def run_graph(argv):
    """Sums the squares of 2 numbers. """

    graph = erdos.graph.get_current_graph()
    sub_graph = graph.add(SumSquaresGraph, name="sum_squares")

    # Add operators
    int1 = graph.add(IntegerOp,
                     name="int1",
                     init_args={
                         "number": 1,
                         "stream_name": "int1_out"
                     },
                     setup_args={"stream_name": "int1_out"})
    int2 = graph.add(IntegerOp,
                     name="int2",
                     init_args={
                         "number": 2,
                         "stream_name": "int2_out"
                     },
                     setup_args={"stream_name": "int2_out"})
    square_op = graph.add(SquareOp, name="default_square")

    # Connect operators
    graph.connect([int1, int2], [sub_graph])
    graph.connect([sub_graph], [square_op])

    # Execute graph
    graph.execute(FLAGS.framework)
def run_graph(n_pub, n_sub, spin):

    graph = erdos.graph.get_current_graph()

    # Add publishers
    publishers = []
    for i in range(n_pub):
        pub = graph.add(PublisherOp, name='publisher_%d' % i)
        publishers.append(pub)

    # Add subscribers
    subscribers = []
    for i in range(n_sub):
        sub = graph.add(
            SubscriberOp,
            name='subscriber_%d' % i,
            init_args={
                'num_pub_ops': n_pub,
                'spin': spin
            })
        subscribers.append(sub)

    # Connect operators
    graph.connect(publishers, subscribers)

    # Execute graph
    graph.execute(FLAGS.framework)
Esempio n. 4
0
def add_object_tracking_op(graph, carla_op, obj_detector_ops):
    tracker_op = None
    name = 'tracker_' + FLAGS.tracker_type
    setup_args = {'output_stream_name': 'tracker_stream'}
    init_args = {
        'output_stream_name': 'tracker_stream',
        'tracker_type': FLAGS.tracker_type,
        'flags': FLAGS,
        'log_file_name': FLAGS.log_file_name,
        'csv_file_name': FLAGS.csv_log_file_name
    }
    if FLAGS.tracker_type == 'cv2':
        # Doesn't require a GPU.
        tracker_op = graph.add(ObjectTrackerOp,
                               name=name,
                               setup_args=setup_args,
                               init_args=init_args)
    else:
        # Other trackers require a GPU.
        tracker_op = graph.add(
            ObjectTrackerOp,
            name=name,
            setup_args=setup_args,
            init_args=init_args,
            _resources={"GPU": FLAGS.obj_tracking_gpu_memory_fraction})
    graph.connect([carla_op] + obj_detector_ops, [tracker_op])
    return tracker_op
Esempio n. 5
0
def analyze_frequency(graph, file_name, output_file_name):
    log_reader_op = graph.add(
        LogReaderOp,
        'log_reader',
        init_args={
            'output_name': 'log_reader',
            'log_file_name': file_name
        },
        setup_args={'output_name': 'log_reader'})
    frequency_jitter_op = graph.add(
        WindowOp,
        name='frequency_jitter_op',
        init_args={
            'output_stream_name': 'frequency_jitter_stream',
            'assigner': SliddingCountWindowAssigner(2),
            'trigger': CountWindowTrigger(2),
            'processor': FrequencyMissProcessor()
        },
        setup_args={'output_stream_name': 'frequency_jitter_stream'})
    file_writer_op = graph.add(
        FileWriterOp,
        name='frequency_file_op',
        init_args={'file_name': output_file_name})
    graph.connect([log_reader_op], [frequency_jitter_op])
    graph.connect([frequency_jitter_op], [file_writer_op])
Esempio n. 6
0
def add_localization_graph(graph, front_locations, tracker_ops):
    # 1 LIDAR, 100000 points per point cloud.
    lidar_op = graph.add(LidarOperator,
                         name='lidar',
                         init_args={
                             'num_points': 100000,
                             'buffer_logs': FLAGS.buffer_logs
                         },
                         setup_args={'op_name': 'lidar'})

    # 1 GPS
    gps_op = graph.add(GPSOperator,
                       name='GPS',
                       init_args={'buffer_logs': FLAGS.buffer_logs})

    # 1 IMU
    imu_op = graph.add(
        IMUOperator,
        name='IMU',
        init_args={'buffer_logs': FLAGS.buffer_logs},
    )

    # 4 short range radars
    short_radars = ['front_left', 'front_right', 'rear_left', 'rear_right']
    short_radar_ops = []
    for location in short_radars:
        radar_name = 'short_radar_' + location
        short_radar_ops.append(add_radar_op(graph, radar_name))

    # 1 long range radar
    long_radar_op = add_radar_op(graph, 'long_radar')

    # 1 SLAM operator.
    slam_op = graph.add(SLAMOperator,
                        name='SLAM',
                        init_args={
                            'min_runtime_us': 1,
                            'max_runtime_us': 100,
                            'buffer_logs': FLAGS.buffer_logs
                        })

    # 3 depth cameras
    depth_camera_ops = []
    for location in front_locations:
        depth_camera_ops.append(
            add_depth_camera_op(graph, 'depth_camera_' + location))

    # fusion operator
    fusion_op = graph.add(FusionOperator,
                          name='fusion',
                          init_args={
                              'min_runtime_us': 1,
                              'max_runtime_us': 100,
                              'buffer_logs': FLAGS.buffer_logs
                          })

    graph.connect([lidar_op, long_radar_op, gps_op, imu_op], [slam_op])
    graph.connect([slam_op, lidar_op] + tracker_ops + short_radar_ops +
                  depth_camera_ops, [fusion_op])
    return (slam_op, fusion_op)
Esempio n. 7
0
def run_graph(spin):
    graph = erdos.graph.get_current_graph()
    first_graph = graph.add(FirstGraph, name='first_graph')
    second_graph = graph.add(SecondGraph,
                             name='second_graph',
                             setup_args={'spin': spin})
    graph.connect([first_graph], [second_graph])
    graph.connect([second_graph], [first_graph])
    graph.execute(FLAGS.framework)
Esempio n. 8
0
def main():
    # Create operators
    graph = erdos.graph.get_current_graph()
    car_racing_op = graph.add(CarRacingOp, name='car_racing')
    action_op = graph.add(ActionOp, name='action')

    # Add connect streams to operators for cyclical graph
    graph.connect([car_racing_op], [action_op])
    graph.connect([action_op], [car_racing_op])

    # Execute graph
    graph.execute("ray")
Esempio n. 9
0
def main(argv):
    # Set up graph
    graph = erdos.graph.get_current_graph()

    # Add operators
    input_op = graph.add(InputOperator, name='input_op')
    push_op = graph.add(PushOperator, name='push_op')

    # Connect graph
    graph.connect([input_op], [push_op])

    # Execute graph
    graph.execute(FLAGS.framework)
Esempio n. 10
0
def main(argv):
    # Set up the graph.
    graph = erdos.graph.get_current_graph()

    # Add the operators.
    source_op_1 = graph.add(SourceOperator, name = "FirstOperator")
    debug_op_1  = graph.add(DebugOperator, name = "DebugOperator")
    sink_op_1 = graph.add(SinkOperator, name = "SinkOperator")

    # Connect the operators.
    graph.connect([source_op_1], [debug_op_1])
    graph.connect([debug_op_1], [sink_op_1])

    # Execute the graph.
    graph.execute('ray')
Esempio n. 11
0
def run_graph():
    """Sums the squares of 2 numbers. """

    # Set up graph
    graph = erdos.graph.get_current_graph()

    # Add operators
    sum_squares_graph = graph.add(SumSquaresGraph, name='sum_squares')
    square_op = graph.add(SquareOp, name='square')

    # Connect Operators
    graph.connect([sum_squares_graph], [square_op])

    # Execute graph
    graph.execute(FLAGS.framework)
Esempio n. 12
0
def main(argv):
    graph = erdos.graph.get_current_graph()
    publish_op_one = graph.add(PublisherOperator,
                               name='publish_op_one',
                               init_args={'text': 'publish-one'})
    publish_op_two = graph.add(PublisherOperator,
                               name='publish_op_two',
                               init_args={'text': 'publish-two'})
    subscriber_with_print_op = graph.add(SubscriberWithPrintOperator,
                                         name='subscriber_with_print')
    subscriber_without_print_op = graph.add(SubscriberWithoutPrintOperator,
                                            name='subscriber_without_print')
    graph.connect([publish_op_one], [subscriber_with_print_op])
    graph.connect([publish_op_two], [subscriber_without_print_op])

    graph.execute(FLAGS.framework)
Esempio n. 13
0
def add_detector_ops(graph, carla_op):
    detector_ops = []
    if FLAGS.detector_ssd_mobilenet_v1:
        detector_ops.append(
            add_detector_op_helper(
                graph, 'detector_ssd_mobilenet_v1',
                'dependencies/data/ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb',
                FLAGS.obj_detection_gpu_memory_fraction))
    if FLAGS.detector_frcnn_resnet101:
        detector_ops.append(
            add_detector_op_helper(
                graph, 'detector_faster_rcnn_resnet101',
                'dependencies/data/faster_rcnn_resnet101_coco_2018_01_28/frozen_inference_graph.pb',
                FLAGS.obj_detection_gpu_memory_fraction))
    if FLAGS.detector_ssd_resnet50_v1:
        detector_ops.append(
            add_detector_op_helper(
                graph, 'detector_ssd_resnet50_v1',
                'dependencies/data/ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync_2018_07_03/frozen_inference_graph.pb',
                FLAGS.obj_detection_gpu_memory_fraction))
    if FLAGS.detector_center_net:
        obj_det_op = graph.add(DetectionCenterNetOperator,
                               name='detector_center_net',
                               setup_args={'output_stream_name': 'obj_stream'},
                               init_args={
                                   'output_stream_name': 'obj_stream',
                                   'flags': FLAGS,
                                   'log_file_name': FLAGS.log_file_name,
                                   'csv_file_name': FLAGS.csv_log_file_name
                               })
        detector_ops.append(obj_det_op)
    graph.connect([carla_op], detector_ops)
    return detector_ops
Esempio n. 14
0
def add_record_op(graph, carla_op, name, filename, filter_name):
    record_op = graph.add(RecordOp,
                          name=name,
                          init_args={'filename': filename},
                          setup_args={'filter_name': filter_name})
    graph.connect([carla_op], [record_op])
    return record_op
Esempio n. 15
0
def add_lidar_record_op(graph, carla_op):
    record_lidar_op = graph.add(
        RecordOp,
        name='record_lidar',
        init_args={'filename': 'pylot_lidar_data.erdos'},
        setup_args={'filter': 'lidar'})
    graph.connect([carla_op], [record_lidar_op])
    return record_lidar_op
Esempio n. 16
0
def main(argv):
    # Set up the graph.
    graph = erdos.graph.get_current_graph()

    # Add the operators.
    source_op = graph.add(FirstOperator,
                          name="gen_op",
                          init_args={'batch_size': 10})
    sum_op = graph.add(SecondOperator, name="sum_op")
    assert_op = graph.add(ThirdOperator, name="assert_op")

    # Connect the operators.
    graph.connect([source_op], [sum_op])
    graph.connect([sum_op], [assert_op])

    # Execute the graph.
    graph.execute('ray')
Esempio n. 17
0
def add_lidar_visualizer_op(graph, carla_op):
    lidar_visualizer_op = graph.add(LidarVisualizerOperator,
                                    name='lidar_visualizer',
                                    init_args={
                                        'flags': FLAGS,
                                        'log_file_name': FLAGS.log_file_name
                                    })
    graph.connect([carla_op], [lidar_visualizer_op])
Esempio n. 18
0
def run_graph(argv):

    # Extract variables
    num_messages = int(FLAGS.num_msg)
    fps = int(FLAGS.fps)
    fail_time = int(FLAGS.fail_time)
    state_size = int(FLAGS.state_size)
    checkpoint_freq = int(FLAGS.checkpoint_freq)

    # Define graph
    graph = erdos.graph.get_current_graph()

    source_op = graph.add(
        Source,
        name='source',
        init_args={'num_messages': num_messages,
                   'fps': fps,
                   'checkpoint_freq': checkpoint_freq}
    )

    failure_op = graph.add(
        FailureOperator,
        name='primary_failure',
        init_args={'state_size': state_size,
                   'checkpoint_freq': checkpoint_freq})

    sink_op = graph.add(
        Sink,
        name='sink',
        init_args={'state_size': state_size,
                   'checkpoint_freq': checkpoint_freq}
    )

    controller_op = graph.add(
        ControllerOperator,
        name='controller',
        init_args={'pre_failure_time_elapse_s': fail_time})

    # Connect Graph
    graph.connect([source_op], [failure_op])
    graph.connect([failure_op], [sink_op])
    graph.connect([sink_op], [controller_op])
    graph.connect([controller_op], [source_op, failure_op, sink_op])

    # Execute Graph
    graph.execute(FLAGS.framework)
Esempio n. 19
0
def add_fusion_ops(graph, carla_op, obj_detector_ops):
    fusion_op = graph.add(FusionOperator,
                          name='fusion',
                          setup_args={'output_stream_name': 'fusion_vehicles'},
                          init_args={
                              'flags': FLAGS,
                              'output_stream_name': 'fusion_vehicles',
                              'log_file_name': FLAGS.log_file_name,
                              'csv_file_name': FLAGS.csv_log_file_name
                          })
    fusion_verification_op = graph.add(
        FusionVerificationOperator,
        name='fusion_verifier',
        init_args={'log_file_name': FLAGS.log_file_name})
    graph.connect(obj_detector_ops + [carla_op], [fusion_op])
    graph.connect([fusion_op, carla_op], [fusion_verification_op])
    return (fusion_op, fusion_verification_op)
Esempio n. 20
0
def main(argv):
    graph = erdos.graph.get_current_graph()

    input_ops = []
    for i in range(0, 2):
        input_op = graph.add(InputOperator, name='input' + str(i))
        input_ops.append(input_op)

    sync_op = graph.add(SynchronizerLastDataOperator, name='synchronizer')
    # sync_op = SynchronizerBestDataOperator()
    # sync_op = SynchronizerDataWithinLimitOperator(500)

    # TODO(ionel): Implement!
    # sync_op = SynchronizerByDeadlineOperator()
    # sync_op = SynchronizerBestDataWithDelay()
    graph.connect(input_ops, [sync_op])

    graph.execute(FLAGS.framework)
Esempio n. 21
0
def add_segmented_video_op(graph, carla_op):
    segmented_video_op = graph.add(SegmentedVideoOperator,
                                   name='segmented_video',
                                   init_args={
                                       'flags': FLAGS,
                                       'log_file_name': FLAGS.log_file_name
                                   })
    graph.connect([carla_op], [segmented_video_op])
    return segmented_video_op
Esempio n. 22
0
def add_traffic_sign_det_op(graph, name):
    return graph.add(TrafficSignDetOperator,
                     name=name,
                     init_args={
                         'min_runtime_us': 1,
                         'max_runtime_us': 100,
                         'buffer_logs': FLAGS.buffer_logs
                     },
                     setup_args={'op_name': name})
Esempio n. 23
0
def add_lane_det_op(graph, name):
    return graph.add(LaneDetOperator,
                     name=name,
                     init_args={
                         'min_runtime_us': 1,
                         'max_runtime_us': 100,
                         'buffer_logs': FLAGS.buffer_logs
                     },
                     setup_args={'op_name': name})
Esempio n. 24
0
def add_segmentation_op(graph, name):
    return graph.add(SegmentationOperator,
                     name=name,
                     init_args={
                         'min_runtime_us': 1,
                         'max_runtime_us': 100,
                         'buffer_logs': FLAGS.buffer_logs
                     },
                     setup_args={'op_name': name})
Esempio n. 25
0
def main(argv):
    # Set up the graph.
    graph = erdos.graph.get_current_graph()

    # Add the operators.
    source_op_1 = graph.add(
        SourceOperator,
        name="FirstOperator",
        init_args={
            'batch_size': BATCH_SIZE,
            'send_batch': lambda x: x % 2 == True,
            'output_stream_name': 'first-stream',
        },
        setup_args={
            'output_stream_name': 'first-stream',
        })
    source_op_2 = graph.add(
        SourceOperator,
        name="SecondOperator",
        init_args={
            'batch_size': BATCH_SIZE,
            'send_batch': lambda x: x % 2 == False,
            'output_stream_name': 'second-stream',
        },
        setup_args={
            'output_stream_name': 'second-stream',
        })
    release_op = graph.add(
        EarlyReleaseOperator,
        name="ReleaseOperator",
        init_args={
            'output_stream_name': 'release-stream',
        },
        setup_args={
            'output_stream_name': 'release-stream',
        })
    sink_op = graph.add(SinkOperator, name="SinkOperator")

    # Connect the operators.
    graph.connect([source_op_1, source_op_2], [release_op])
    graph.connect([release_op], [sink_op])

    # Execute the graph.
    graph.execute('ray')
Esempio n. 26
0
def add_camera_video_op(graph, carla_op, name, filter_name):
    video_op = graph.add(VideoOperator,
                         name=name,
                         init_args={
                             'flags': FLAGS,
                             'log_file_name': FLAGS.log_file_name
                         },
                         setup_args={'filter_name': filter_name})
    graph.connect([carla_op], [video_op])
    return video_op
Esempio n. 27
0
def create_agent_op(graph, bgr_camera_setup):
    agent_op = graph.add(PylotAgentOperator,
                         name='pylot_agent',
                         init_args={
                             'flags': FLAGS,
                             'bgr_camera_setup': bgr_camera_setup,
                             'log_file_name': FLAGS.log_file_name,
                             'csv_file_name': FLAGS.csv_log_file_name
                         })
    return agent_op
Esempio n. 28
0
def add_prediction_graph(graph, tracker_ops):
    prediction_op = graph.add(PredictionOperator,
                              name='prediction',
                              init_args={
                                  'min_runtime_us': 1,
                                  'max_runtime_us': 100,
                                  'buffer_logs': FLAGS.buffer_logs
                              })
    graph.connect([prediction_op], tracker_ops)
    return [prediction_op]
Esempio n. 29
0
def add_record_carla_op(graph, carla_op):
    input_names = [
        'vehicle_pos', 'acceleration', 'forward_speed', 'traffic_lights',
        'pedestrians', 'vehicles', 'traffic_signs'
    ]
    record_carla_op = graph.add(
        RecordOp,
        name='record_carla',
        init_args={'filename': 'pylot_carla_data.erdos'},
        setup_args={'filter': input_names})
    graph.connect([carla_op], [record_carla_op])
Esempio n. 30
0
def add_detector_op(graph, detector_name):
    return graph.add(DetectionOperator,
                     name=detector_name,
                     init_args={
                         'min_runtime_us': 1,
                         'max_runtime_us': 100,
                         'min_det_objs': 3,
                         'max_det_objs': 15,
                         'buffer_logs': FLAGS.buffer_logs
                     },
                     setup_args={'op_name': detector_name})