Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
def main(argv):
    graph = erdos.graph.get_current_graph()

    front_locations = FLAGS.front_camera_locations.split(',')

    for location in front_locations:
        analyze_frequency(graph, 'camera_' + location + '.log',
                          'jitter_camera_' + location + '.log')

    graph.execute(FLAGS.framework)
Exemplo n.º 6
0
def main(argv):

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

    # Add operators
    camera = graph.add(
        CameraOperator, name='camera', setup_args={'op_name': 'camera'})
    detector = graph.add(
        DetectionOperator,
        name='detector',
        init_args={
            'min_runtime_us': 1,
            'max_runtime_us': 100,
            'min_det_objs': 3,
            'max_det_objs': 15
        },
        setup_args={'op_name': 'detector'})
    lidar = graph.add(
        LidarOperator,
        name='lidar',
        init_args={'num_points': 100000},
        setup_args={'op_name': 'lidar'})
    tracker = graph.add(
        TrackerOperator,
        name='tracker',
        init_args={
            'min_runtime_us': 1,
            'max_runtime_us': 100
        },
        setup_args={'op_name': 'tracker'})
    segmentation = graph.add(
        SegmentationOperator,
        name='seg',
        init_args={
            'min_runtime_us': 1,
            'max_runtime_us': 100
        },
        setup_args={'op_name': 'seg'})
    slam = graph.add(
        SLAMOperator,
        name='SLAM',
        init_args={
            'min_runtime_us': 1,
            'max_runtime_us': 100
        })

    # Connect operators
    graph.connect([camera], [detector, segmentation])
    graph.connect([camera, detector], [tracker])
    graph.connect([lidar, tracker], [slam])

    # Execute graph
    graph.execute(FLAGS.framework)
Exemplo n.º 7
0
def main(argv):
    # Create the graph.
    graph = erdos.graph.get_current_graph()
    construct_graph(graph)

    # Execute the graph.
    graph.execute("ros")
    try:
        while True:
            pass
    except KeyboardInterrupt:
        pass
Exemplo 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")
Exemplo 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)
Exemplo n.º 10
0
def main(argv):

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

    if FLAGS.test_case == 'service':
        from beginner_tutorials.srv import *
        from beginner_tutorials.srv import AddTwoIntsRequest, AddTwoInts, AddTwoIntsResponse
        # Add operators
        add_two_ints_input_op = graph.add(AddTwoIntsInputOp, name='add_op')
        ros_service_op = graph.add(ROSServiceOp,
                                   name='ros_service',
                                   init_args={
                                       'service_name': 'add_two_ints',
                                       'srv_type': AddTwoInts
                                   },
                                   setup_args={
                                       'srv_ret_type': AddTwoIntsResponse,
                                       'op_name': 'add_two_ints'
                                   })

        # Connect graph
        graph.connect([add_two_ints_input_op], [ros_service_op])
    elif FLAGS.test_case == 'publisher':
        data_generator_op = graph.add(DataGeneratorOp, name='data_gen')
        ros_publisher_op = graph.add(ROSPublisherOp,
                                     name='ros_publisher',
                                     init_args={
                                         'ros_topic': 'my_topic',
                                         'data_type': String
                                     })
        graph.connect([data_generator_op], [ros_publisher_op])
    elif FLAGS.test_case == 'subscriber':
        ros_subscriber_op = graph.add(
            ROSSubscriberOp,
            name='ros_subscriber',
            init_args={
                'ros_topics_type': [('/my_topic', String, 'erdos_stream')]
            },
            setup_args={
                'ros_topics_type': [('/my_topic', String, 'erdos_stream')]
            })
        echo_op = graph.add(EchoOp, name='echo_op')
        graph.connect([ros_subscriber_op], [echo_op])
    else:
        raise ValueError('Unexpected test_case {}'.format(FLAGS.test_case))

    # Execute graph
    graph.execute(FLAGS.framework)
Exemplo 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)
Exemplo n.º 12
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')
Exemplo n.º 13
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)
Exemplo n.º 14
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')
Exemplo n.º 15
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)
Exemplo n.º 16
0
def main(argv):
    # Define graph
    graph = erdos.graph.get_current_graph()

    # Add camera and lidar driver operators to the data-flow graph.
    (bgr_camera_setup, carla_op, camera_ops,
     lidar_ops) = add_driver_operators(graph,
                                       auto_pilot=FLAGS.carla_auto_pilot)

    # Add debugging operators (e.g., visualizers) to the data-flow graph.
    add_debugging_component(graph, carla_op, camera_ops, lidar_ops)

    if FLAGS.use_perfect_perception:
        # Add operators that use ground information.
        (obj_det_ops, traffic_light_det_ops, lane_det_ops,
         segmentation_ops) = add_perfect_perception_component(
             graph, bgr_camera_setup, 'perfect_detector_output', carla_op,
             camera_ops)
    else:
        # Add detectors.
        (obj_det_ops, traffic_light_det_ops,
         lane_det_ops) = add_detection_component(graph, bgr_camera_setup,
                                                 camera_ops, carla_op)

        # Add segmentation operators.
        segmentation_ops = add_segmentation_component(graph, camera_ops)

    add_ground_eval_ops(graph, obj_det_ops, camera_ops)

    # Add the behaviour planning agent operator.
    agent_op = add_agent_op(graph, carla_op, traffic_light_det_ops,
                            obj_det_ops, segmentation_ops, lane_det_ops,
                            bgr_camera_setup)

    # Add planning operators.
    goal_location = (234.269989014, 59.3300170898, 39.4306259155)
    goal_orientation = (1.0, 0.0, 0.22)
    add_planning_component(graph,
                           goal_location,
                           goal_orientation,
                           carla_op,
                           agent_op,
                           city_name='Town{:02d}'.format(FLAGS.carla_town))

    graph.execute(FLAGS.framework)
Exemplo n.º 17
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)
Exemplo n.º 18
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')
Exemplo n.º 19
0
def main(argv):
    """Sums the squares of 2 numbers. """

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

    # Add operators
    int1 = graph.add(IntegerOp, name='int1', init_args={'number': 1})
    int2 = graph.add(IntegerOp, name='int2', init_args={'number': 2})
    square1 = graph.add(SquareOp, name='square')
    square2 = graph.add(SquareOp, name='square2')
    sum = graph.add(SumOp, name='sum')

    # Connect operators
    graph.connect([int1], [square1])
    graph.connect([int2], [square2])
    graph.connect([square1, square2], [sum])

    # Execute graph
    graph.execute(FLAGS.framework)
Exemplo n.º 20
0
def main(argv):
    graph = erdos.graph.get_current_graph()

    front_locations = FLAGS.front_camera_locations.split(',')

    side_locations = []
    if FLAGS.side_cameras:
        side_locations = ['side_left', 'side_right']

    rear_locations = []
    if FLAGS.rear_cameras:
        rear_locations = ['rear_left', 'rear_center', 'rear_right']

    tracker_ops = []
    lane_det_ops = []
    traffic_light_det_ops = []
    intersection_det_ops = []
    traffic_sign_det_ops = []
    for location in front_locations:
        ops = add_front_camera_processing_graph(graph, location)
        tracker_ops.append(ops[0])
        lane_det_ops.append(ops[1])
        traffic_light_det_ops.append(ops[2])
        intersection_det_ops.append(ops[3])
        traffic_sign_det_ops.append(ops[4])

    for location in side_locations:
        ops = add_side_camera_processing_graph(graph, location)
        tracker_ops.append(ops[0])
        lane_det_ops.append(ops[1])
        traffic_light_det_ops.append(ops[2])
        intersection_det_ops.append(ops[3])
        traffic_sign_det_ops.append(ops[4])

    for location in rear_locations:
        ops = add_rear_camera_processing_graph(graph, location)
        tracker_ops.append(ops[0])

    # TODO(ionel): Plugin mapping operator.
    # mapping_op = graph.add(
    #     MappingOperator,
    #     name='mapping',
    #     init_args={'buffer_logs': FLAGS.buffer_logs})

    # 1 mission planner operator.
    mission_planner_op = graph.add(MissionPlannerOperator,
                                   name='mission_planner',
                                   init_args={
                                       'min_runtime_us': 1,
                                       'max_runtime_us': 100,
                                       'buffer_logs': FLAGS.buffer_logs
                                   })
    # 1 motion planner operator.
    motion_planner_op = graph.add(MotionPlannerOperator,
                                  name='motion_planner',
                                  init_args={
                                      'min_runtime_us': 1,
                                      'max_runtime_us': 100,
                                      'buffer_logs': FLAGS.buffer_logs
                                  })

    (slam_op, fusion_op) = add_localization_graph(graph, front_locations,
                                                  tracker_ops)
    prediction_op = add_prediction_graph(graph, tracker_ops)[0]

    graph.connect([slam_op], [mission_planner_op])
    graph.connect([mission_planner_op, fusion_op, prediction_op] +
                  lane_det_ops + traffic_light_det_ops + intersection_det_ops +
                  traffic_sign_det_ops, [motion_planner_op])

    graph.execute(FLAGS.framework)
Exemplo n.º 21
0
def main(argv):
    # Get default data-flow graph.
    graph = erdos.graph.get_current_graph()

    camera_setups, top_down_segmented_camera_setup = create_camera_setups()
    lidar_setups = create_lidar_setups()

    # Add operator that interacts with the Carla simulator.
    (carla_op,
     camera_ops,
     lidar_ops) = pylot.operator_creator.create_driver_ops(
         graph, camera_setups, lidar_setups, auto_pilot=FLAGS.carla_auto_pilot)

    # Add an operator that logs BGR frames and segmented frames.
    camera_log_ops = []
    if FLAGS.log_cameras:
        camera_log_ops = [
            pylot.operator_creator.create_camera_logger_op(graph)]
    lidar_log_ops = []
    if FLAGS.log_lidar:
        lidar_log_ops = [pylot.operator_creator.create_lidar_logger_op(graph)]

    chauffeur_log_ops = []
    if FLAGS.log_chauffeur:
        chauffeur_log_ops = [pylot.operator_creator.create_chauffeur_logger_op(
            graph, top_down_segmented_camera_setup,
            pylot.utils.TOP_DOWN_SEGMENTED_CAMERA_NAME)]

    # Connect the camera logging ops with the camera ops.
    graph.connect(camera_ops, camera_log_ops + chauffeur_log_ops)
    graph.connect(lidar_ops, lidar_log_ops)

    detector_ops, bbox_logger_ops = add_perfect_detection_component(
        graph, camera_setups, carla_op, camera_ops)

    tracking_ops = add_perfect_tracking_component(graph, carla_op)
    trajectory_log_ops = []
    if FLAGS.log_trajectories:
        trajectory_log_ops = [
            pylot.operator_creator.create_trajectory_logger_op(graph)]
    graph.connect(tracking_ops, trajectory_log_ops + chauffeur_log_ops)

    multiple_object_tracker_logger_op = [
        pylot.operator_creator.create_multiple_object_tracker_logger_op(graph)]
    graph.connect(detector_ops, multiple_object_tracker_logger_op)

    # Add visual operators.
    pylot.operator_creator.add_visualization_operators(
        graph,
        camera_ops,
        lidar_ops,
        tracking_ops,
        pylot.utils.CENTER_CAMERA_NAME,
        pylot.utils.DEPTH_CAMERA_NAME,
        pylot.utils.FRONT_SEGMENTED_CAMERA_NAME,
        pylot.utils.TOP_DOWN_SEGMENTED_CAMERA_NAME,
        top_down_segmented_camera_setup)

    if FLAGS.carla_auto_pilot:
        # We do not need planning and agent ops if we're running in
        # auto pilot mode. Instead, we insert a synchronizing operator
        # that only sends back a command when all the operators in their
        # data-flow have finished processing a message.
        sync_op = graph.add(SynchronizerOp, name='sync_op')
        graph.connect(
            camera_ops + lidar_ops + camera_log_ops + lidar_log_ops +
            detector_ops + bbox_logger_ops + chauffeur_log_ops,
            [sync_op])
        graph.connect([sync_op], [carla_op])
        graph.connect([carla_op], chauffeur_log_ops)
    else:
        raise ValueError("Must be in auto pilot mode. Pass --carla_auto_pilot")

    graph.execute("ros")
Exemplo n.º 22
0
def main(argv):
    # Define graph
    graph = erdos.graph.get_current_graph()

    camera_setups = create_camera_setups()
    lidar_setups = create_lidar_setups()

    # Add operator that interacts with the Carla simulator.
    (carla_op,
     camera_ops,
     lidar_ops) = pylot.operator_creator.create_driver_ops(
         graph, camera_setups, lidar_setups, auto_pilot=FLAGS.carla_auto_pilot)

    # Add visual operators.
    pylot.operator_creator.add_visualization_operators(
        graph, camera_ops, lidar_ops, CENTER_CAMERA_NAME, DEPTH_CAMERA_NAME)

    # Add an operator that logs BGR frames and segmented frames.
    camera_log_ops = [pylot.operator_creator.create_camera_logger_op(graph)]
    lidar_log_ops = [pylot.operator_creator.create_lidar_logger_op(graph)]

    # Connect the camera logging ops with the camera ops.
    graph.connect(camera_ops, camera_log_ops)
    graph.connect(lidar_ops, lidar_log_ops)

    detector_ops, bbox_logger_ops = add_perfect_detection_component(
        graph, camera_setups, carla_op, camera_ops)

    if FLAGS.carla_auto_pilot:
        # We do not need planning and agent ops if we're running in
        # auto pilot mode. Instead, we insert a synchronizing operator
        # that only sends back a command when all the operators in their
        # data-flow have finished processing a message.
        sync_op = graph.add(SynchronizerOp, name='sync_op')
        graph.connect(
            camera_ops + lidar_ops + camera_log_ops + lidar_log_ops +
            detector_ops + bbox_logger_ops,
            [sync_op])
        graph.connect([sync_op], [carla_op])
    else:
        # Add agent that uses ground data to drive around.
        agent_op = pylot.operator_creator.create_ground_agent_op(graph)
        graph.connect([carla_op], [agent_op])
        graph.connect([agent_op], [carla_op])

        goal_location = (234.269989014, 59.3300170898, 39.4306259155)
        goal_orientation = (1.0, 0.0, 0.22)

        if '0.8' in FLAGS.carla_version:
            planning_op = pylot.operator_creator.create_legacy_planning_op(
                graph, 'Town{:02d}'.format(FLAGS.carla_town),
                goal_location, goal_orientation)
        elif '0.9' in FLAGS.carla_version:
            planning_op = pylot.operator_creator.create_planning_op(
                graph, goal_location)
        else:
            raise ValueError('Unexpected Carla version')
        graph.connect([carla_op], [planning_op])
        graph.connect([planning_op], [agent_op])

    graph.execute(FLAGS.framework)
Exemplo n.º 23
0
def main(argv):
    # Define graph
    graph = erdos.graph.get_current_graph()

    source_op = graph.add(Source, name='source')

    flux_ingress_op = graph.add(
        FluxIngressOperator,
        name='flux_ingress',
        init_args={'output_stream_name': 'ingress_out'},
        setup_args={'output_stream_name': 'ingress_out'})

    flux_primary_consumer_op = graph.add(FluxConsumerOperator,
                                         name='flux_primary_consumer',
                                         init_args={
                                             'replica_num': 0,
                                             'output_stream_name':
                                             'primary_data_stream',
                                             'ack_stream_name': 'primary_ack'
                                         },
                                         setup_args={
                                             'output_stream_name':
                                             'primary_data_stream',
                                             'ack_stream_name': 'primary_ack'
                                         })
    flux_secondary_consumer_op = graph.add(FluxConsumerOperator,
                                           name='flux_secondary_consumer',
                                           init_args={
                                               'replica_num': 1,
                                               'output_stream_name':
                                               'secondary_data_stream',
                                               'ack_stream_name':
                                               'secondary_ack'
                                           },
                                           setup_args={
                                               'output_stream_name':
                                               'secondary_data_stream',
                                               'ack_stream_name':
                                               'secondary_ack'
                                           })

    primary_failure_op = graph.add(
        FailureOperator,
        name='primary_failure',
        init_args={
            'output_stream_name': 'primary_failure',
            'replica_num': 0
        },
        setup_args={'output_stream_name': 'primary_failure'})

    secondary_failure_op = graph.add(
        FailureOperator,
        name='secondary_failure',
        init_args={
            'output_stream_name': 'secondary_failure',
            'replica_num': 1
        },
        setup_args={'output_stream_name': 'secondary_failure'})

    flux_primary_producer_op = graph.add(
        FluxProducerOperator,
        name='flux_primary_producer',
        init_args={
            'replica_num': 0,
            'output_stream_name': 'primary_producer'
        },
        setup_args={'output_stream_name': 'primary_producer'})
    flux_secondary_producer_op = graph.add(
        FluxProducerOperator,
        name='flux_secondary_producer',
        init_args={
            'replica_num': 1,
            'output_stream_name': 'secondary_producer'
        },
        setup_args={'output_stream_name': 'secondary_producer'})

    flux_egress_op = graph.add(FluxEgressOperator,
                               name='flux_egress',
                               init_args={
                                   'output_stream_name': 'egress_out',
                                   'ack_stream_name': 'ergress_ack'
                               },
                               setup_args={
                                   'output_stream_name': 'egress_out',
                                   'ack_stream_name': 'ergress_ack'
                               })

    sink_op = graph.add(Sink, name='sink')

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

    graph.connect([source_op], [flux_ingress_op])
    graph.connect([flux_ingress_op],
                  [flux_primary_consumer_op, flux_secondary_consumer_op])
    graph.connect([flux_primary_consumer_op, flux_secondary_consumer_op],
                  [flux_ingress_op])
    graph.connect([flux_primary_consumer_op], [primary_failure_op])
    graph.connect([flux_secondary_consumer_op], [secondary_failure_op])
    graph.connect([primary_failure_op], [flux_primary_producer_op])
    graph.connect([secondary_failure_op], [flux_secondary_producer_op])
    graph.connect([flux_primary_producer_op, flux_secondary_producer_op],
                  [flux_egress_op])
    graph.connect([flux_egress_op], [flux_secondary_producer_op, sink_op])

    graph.connect([controller_op], [
        flux_ingress_op, flux_primary_consumer_op, flux_secondary_consumer_op,
        flux_egress_op
    ] + [primary_failure_op, secondary_failure_op])

    graph.execute(FLAGS.framework)
Exemplo n.º 24
0
def run_graph(spin):
    graph = erdos.graph.get_current_graph()
    pub = graph.add(PublisherOp, name='publisher')
    sub = graph.add(SubscriberOp, name='subscriber', init_args={'spin': spin})
    graph.connect([pub], [sub])
    graph.execute(FLAGS.framework)
Exemplo n.º 25
0
def main(argv):

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

    logging_ops = []
    # Add an operator that logs RGB frames and segmented frames.
    camera_logger_op = graph.add(CameraLoggerOp,
                                 name='camera_logger_op',
                                 init_args={
                                     'flags': FLAGS,
                                     'log_file_name': FLAGS.log_file_name,
                                     'csv_file_name': FLAGS.csv_log_file_name
                                 })
    logging_ops.append(camera_logger_op)

    rgb_camera_setup = ('front_rgb_camera', 'SceneFinal',
                        (FLAGS.carla_camera_image_width,
                         FLAGS.carla_camera_image_height), (2.0, 0.0, 1.4))
    camera_setups = [rgb_camera_setup]

    # Depth camera is required to map from 3D object bounding boxes
    # to 2D.
    depth_camera_name = 'front_depth_camera'
    depth_camera_setup = (depth_camera_name, 'Depth',
                          (FLAGS.carla_camera_image_width,
                           FLAGS.carla_camera_image_height), (2.0, 0.0, 1.4))
    camera_setups.append(depth_camera_setup)
    # Add operator that converts from 3D bounding boxes
    # to 2D bouding boxes.
    ground_object_logger_op = graph.add(GroundTruthObjectLoggerOp,
                                        name='ground_truth_obj_logger',
                                        init_args={
                                            'rgb_camera_setup':
                                            rgb_camera_setup,
                                            'flags':
                                            FLAGS,
                                            'log_file_name':
                                            FLAGS.log_file_name,
                                            'csv_file_name':
                                            FLAGS.csv_log_file_name
                                        })
    logging_ops.append(ground_object_logger_op)

    # Record segmented frames as well. The CameraLoggerOp records them.
    segmentation_camera_setup = ('front_semantic_camera',
                                 'SemanticSegmentation',
                                 (FLAGS.carla_camera_image_width,
                                  FLAGS.carla_camera_image_height), (2.0, 0.0,
                                                                     1.4))
    camera_setups.append(segmentation_camera_setup)

    # Add operator that interacts with the Carla simulator.
    carla_op = add_carla_op(graph, camera_setups)

    # Add agent that uses ground data to drive around.
    goal_location = (234.269989014, 59.3300170898, 39.4306259155)
    goal_orientation = (1.0, 0.0, 0.22)
    agent_op = add_ground_agent_op(graph, carla_op, goal_location,
                                   goal_orientation)

    # Connect the operators.
    graph.connect([carla_op], [agent_op])
    graph.connect([agent_op], [carla_op])
    graph.connect([carla_op], logging_ops)

    graph.execute(FLAGS.framework)
Exemplo n.º 26
0
def main(argv):

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

    rgb_camera_setup = (RGB_CAMERA_NAME, 'SceneFinal',
                        (FLAGS.carla_camera_image_width,
                         FLAGS.carla_camera_image_height), (2.0, 0.0, 1.4))
    camera_setups = [
        rgb_camera_setup,
        (DEPTH_CAMERA_NAME, 'Depth', (FLAGS.carla_camera_image_width,
                                      FLAGS.carla_camera_image_height),
         (2.0, 0.0, 1.4)),
        (SEGMENTED_CAMERA_NAME, 'SemanticSegmentation',
         (FLAGS.carla_camera_image_width,
          FLAGS.carla_camera_image_height), (2.0, 0.0, 1.4))
    ]

    # Add operators to the graph.
    carla_op = add_carla_op(graph, camera_setups)

    # Add visual operators.
    add_visualization_operators(graph, carla_op)

    # Add recording operators.
    add_recording_operators(graph, carla_op)

    # XXX(ionel): This planner is not currently in use.
    # planner_op = PlannerOperator('Town01', goal_location, goal_orientation)
    # planner_streams = planner_op([carla_op.get_output_stream('vehicle_pos')])
    # control_streams = control_op(planner_streams)

    segmentation_ops = []
    if FLAGS.segmentation_drn:
        segmentation_op = add_segmentation_drn_op(graph, carla_op)
        segmentation_ops.append(segmentation_op)
        if FLAGS.evaluate_segmentation:
            eval_segmentation_op = add_segmentation_eval_op(
                graph, carla_op, segmentation_op, SEGMENTED_CAMERA_NAME,
                'segmented_stream')

    if FLAGS.segmentation_dla:
        segmentation_op = add_segmentation_dla_op(graph, carla_op)
        segmentation_ops.append(segmentation_op)
        if FLAGS.evaluate_segmentation:
            eval_segmentation_op = add_segmentation_eval_op(
                graph, carla_op, segmentation_op, SEGMENTED_CAMERA_NAME,
                'segmented_stream')

    if FLAGS.eval_ground_truth_segmentation:
        eval_ground_truth_segmentation_op = add_segmentation_ground_eval_op(
            graph, carla_op, SEGMENTED_CAMERA_NAME)

    # This operator evaluates the temporal decay of the ground truth of
    # object detection across timestamps.
    if FLAGS.eval_ground_truth_object_detection:
        eval_ground_truth_detector_op = add_eval_ground_truth_detector_op(
            graph, carla_op, rgb_camera_setup, DEPTH_CAMERA_NAME)

    obj_detector_ops = []
    if FLAGS.obj_detection:
        obj_detector_ops = add_detector_ops(graph, carla_op)

        if FLAGS.evaluate_obj_detection:
            obstacle_accuracy_op = add_obstacle_accuracy_op(
                graph, obj_detector_ops, carla_op, rgb_camera_setup,
                DEPTH_CAMERA_NAME)

        if FLAGS.obj_tracking:
            tracker_op = add_object_tracking_op(graph, carla_op,
                                                obj_detector_ops)

        if FLAGS.fusion:
            (fusion_op,
             fusion_verification_op) = add_fusion_ops(graph, carla_op,
                                                      obj_detector_ops)

    traffic_light_det_ops = []
    if FLAGS.traffic_light_det:
        traffic_light_det_ops.append(add_traffic_light_op(graph, carla_op))

    lane_detection_ops = []
    if FLAGS.lane_detection:
        lane_detection_ops.append(add_lane_detection_op(graph, carla_op))

    agent_op = None
    if FLAGS.ground_agent_operator:
        agent_op = add_ground_agent_op(graph, carla_op)
    else:
        # TODO(ionel): The ERDOS agent doesn't use obj tracker and fusion.
        agent_op = add_erdos_agent_op(graph, carla_op, DEPTH_CAMERA_NAME,
                                      segmentation_ops, obj_detector_ops,
                                      traffic_light_det_ops,
                                      lane_detection_ops)

    goal_location = (234.269989014, 59.3300170898, 39.4306259155)
    goal_orientation = (1.0, 0.0, 0.22)
    waypointer_op = add_waypointer_op(graph, carla_op, agent_op, goal_location,
                                      goal_orientation)

    graph.execute(FLAGS.framework)
Exemplo n.º 27
0
def main(argv):
    graph = erdos.graph.get_current_graph()
    data_gen_op = graph.add(DataGeneratorOp, name='data_gen_op')
    if FLAGS.where_test:
        where_op = graph.add(WhereOp,
                             name='where_op',
                             init_args={
                                 'where_lambda': lambda msg: msg.data % 2 == 0,
                                 'output_stream_name': 'where_stream'
                             },
                             setup_args={
                                 'filter_stream_lambda':
                                 lambda stream: stream.name == 'data_stream',
                                 'output_stream_name':
                                 'where_stream'
                             })
        log_op = graph.add(LogOp, name='where_log_op')
        graph.connect([data_gen_op], [where_op])
        graph.connect([where_op], [log_op])

    if FLAGS.map_test:
        map_op = graph.add(MapOp,
                           name='map_op',
                           init_args={
                               'map_lambda': lambda msg: msg.data * msg.data,
                               'output_stream_name': 'map_stream'
                           },
                           setup_args={
                               'filter_stream_lambda':
                               lambda stream: stream.name == 'data_stream',
                               'output_stream_name':
                               'map_stream'
                           })
        log_op = graph.add(LogOp, name='map_log_op')
        graph.connect([data_gen_op], [map_op])
        graph.connect([map_op], [log_op])

    if FLAGS.concat_test:
        concat_op = graph.add(
            ConcatOp,
            name='concat_op',
            init_args={'output_stream_name': 'concat_stream'},
            setup_args={'output_stream_name': 'concat_stream'})
        log_op = graph.add(LogOp, name='concat_log_op')
        graph.connect([data_gen_op], [concat_op])
        graph.connect([concat_op], [log_op])

    if FLAGS.map_many_test:
        map_many_op = graph.add(
            MapManyOp,
            name='map_many_op',
            init_args={'output_stream_name': 'flat_stream'},
            setup_args={
                'filter_stream_lambda':
                lambda stream: stream.name == 'list_data_stream',
                'output_stream_name': 'flat_stream'
            })
        log_op = graph.add(LogOp, name='map_many_log_op')
        graph.connect([data_gen_op], [map_many_op])
        graph.connect([map_many_op], [log_op])

    if FLAGS.unzip_test:
        unzip_op = graph.add(
            UnzipOp,
            name='unzip_op',
            init_args={
                'output_stream_name1': 'unzip_left_stream',
                'output_stream_name2': 'unzip_right_stream',
            },
            setup_args={
                'output_stream_name1':
                'unzip_left_stream',
                'output_stream_name2':
                'unzip_right_stream',
                'filter_stream_lambda':
                lambda stream: stream.name == 'tuple_data_stream'
            })
        log_op = graph.add(LogOp, name='unzip_log_op')
        graph.connect([data_gen_op], [unzip_op])
        graph.connect([unzip_op], [log_op])

    if FLAGS.counting_window_test:
        window_op = graph.add(WindowOp,
                              name='counting_window_op',
                              init_args={
                                  'output_stream_name': 'window_stream',
                                  'assigner': CountWindowAssigner(2),
                                  'trigger': CountWindowTrigger(2),
                                  'processor': SumWindowProcessor()
                              },
                              setup_args={
                                  'output_stream_name':
                                  'window_stream',
                                  'filter_stream_lambda':
                                  lambda stream: stream.name == 'data_stream'
                              })
        log_op = graph.add(LogOp, name='window_log_op')
        graph.connect([data_gen_op], [window_op])
        graph.connect([window_op], [log_op])

    if FLAGS.tumbling_window_test:
        window_op = graph.add(WindowOp,
                              name='tumbling_window_op',
                              init_args={
                                  'output_stream_name': 'window_stream',
                                  'assigner': TumblingWindowAssigner(2000),
                                  'trigger': TimeWindowTrigger(),
                                  'processor': SumWindowProcessor()
                              },
                              setup_args={
                                  'output_stream_name':
                                  'window_stream',
                                  'filter_stream_lambda':
                                  lambda stream: stream.name == 'data_stream'
                              })
        log_op = graph.add(LogOp, name='window_log_op')
        graph.connect([data_gen_op], [window_op])
        graph.connect([window_op], [log_op])

    graph.execute(FLAGS.framework)