def main(): """Creates and runs the dataflow graph.""" loop_stream = erdos.LoopStream() (stream, ) = erdos.connect(LoopOp, erdos.OperatorConfig(), [loop_stream]) loop_stream.set(stream) erdos.run()
def main(): """Creates and runs the dataflow graph.""" (count_stream, ) = erdos.connect(SendOp, erdos.OperatorConfig(), []) erdos.connect(CallbackOp, erdos.OperatorConfig(), [count_stream]) erdos.connect(PullOp, erdos.OperatorConfig(), [count_stream]) erdos.connect(TryPullOp, erdos.OperatorConfig(), [count_stream]) erdos.run()
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)
def main(): """Creates and runs the dataflow graph.""" loop_stream = erdos.streams.LoopStream() stream = erdos.connect_one_in_one_out( LoopOp, erdos.operator.OperatorConfig(), loop_stream ) loop_stream.connect_loop(stream) erdos.run()
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() # Create carla operator. (can_bus_stream, 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) # Add camera sensors. (center_camera_stream, rgb_camera_setup) = pylot.operator_creator.add_rgb_camera( transform, vehicle_id_stream) (depth_camera_stream, depth_camera_setup) = pylot.operator_creator.add_depth_camera( transform, vehicle_id_stream) (segmented_stream, _) = pylot.operator_creator.add_segmented_camera(transform, vehicle_id_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, can_bus_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()
def main(): source_stream = erdos.connect_source(SendOp, OperatorConfig()) map_stream = source_stream.map(lambda x: x**2) evens_stream, odds_stream = map_stream.split(lambda x: x % 2 == 0) flat_map_stream = map_stream.flat_map(lambda x: (f"Number {x}", float(x / 2))) str_stream, float_stream = flat_map_stream.split_by_type(str, float) merged_stream = evens_stream.concat(odds_stream, str_stream, float_stream) erdos.connect_sink(SinkOp, OperatorConfig(name="MergedOutput"), merged_stream) erdos.run()
def main(): """Creates and runs the dataflow graph.""" count_stream = erdos.connect_source(SendOp, erdos.operator.OperatorConfig()) erdos.connect_sink(CallbackOp, erdos.operator.OperatorConfig(), count_stream) erdos.connect_sink(PullOp, erdos.operator.OperatorConfig(), count_stream) erdos.connect_sink(TryPullOp, erdos.operator.OperatorConfig(), count_stream) erdos.run()
def main(): """Creates and runs the dataflow graph.""" left_stream = erdos.connect_source( SendOp, erdos.operator.OperatorConfig(name="FastSendOp"), frequency=2) right_stream = erdos.connect_source( SendOp, erdos.operator.OperatorConfig(name="SlowSendOp"), frequency=1) erdos.connect_two_in_one_out(JoinOp, erdos.operator.OperatorConfig(name="JoinOp"), left_stream, right_stream) erdos.run()
def main(): """Creates and runs the dataflow graph.""" (count_stream, ) = erdos.connect(SendOp, erdos.OperatorConfig(), []) (top_stream, ) = erdos.connect(TopOp, erdos.OperatorConfig(), []) (batch_stream, ) = erdos.connect(BatchOp, erdos.OperatorConfig(), [count_stream]) erdos.connect(CallbackWatermarkListener, erdos.OperatorConfig(), [batch_stream, top_stream]) erdos.connect(PullWatermarkListener, erdos.OperatorConfig(), [batch_stream]) erdos.run()
def main(): """Creates and runs the dataflow graph.""" (left_stream, ) = erdos.connect(SendOp, erdos.OperatorConfig(name="FastSendOp"), [], frequency=2) (right_stream, ) = erdos.connect(SendOp, erdos.OperatorConfig(name="SlowSendOp"), [], frequency=1) erdos.connect(JoinOp, erdos.OperatorConfig(), [left_stream, right_stream]) erdos.run()
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()
def main(): """Creates and runs the dataflow graph.""" count_stream = erdos.connect_source(SendOp, erdos.operator.OperatorConfig()) top_stream = erdos.connect_source(TopOp, erdos.operator.OperatorConfig()) batch_stream = erdos.connect_one_in_one_out( BatchOp, erdos.operator.OperatorConfig(), count_stream ) erdos.connect_sink( CallbackWatermarkListener, erdos.operator.OperatorConfig(), batch_stream ) erdos.connect_sink( CallbackWatermarkListener, erdos.operator.OperatorConfig(), top_stream ) erdos.connect_sink( PullWatermarkListener, erdos.operator.OperatorConfig(), batch_stream ) erdos.run()
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') args = parser.parse_args() """Creates and runs the dataflow graph.""" (count_stream, ) = erdos.connect(SendOp, 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()
while True: data = self.read_stream.read() print("PullOp: received {data}".format(data=data)) class TryPullOp: def __init__(self, read_stream): self.read_stream = read_stream @staticmethod def connect(read_streams): return [] def run(self): while True: data = self.read_stream.try_read() print("TryPullOp: received {data}".format(data=data)) time.sleep(0.5) def driver(): """Creates the dataflow graph.""" (count_stream, ) = erdos.connect(SendOp, []) erdos.connect(CallbackOp, [count_stream]) erdos.connect(PullOp, [count_stream]) erdos.connect(TryPullOp, [count_stream]) if __name__ == "__main__": erdos.run(driver)
def driver(): transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION, pylot.utils.Rotation()) control_loop_stream = erdos.LoopStream() # Create carla operator. (can_bus_stream, 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) # Add sensors. (center_camera_stream, rgb_camera_setup) = pylot.operator_creator.add_rgb_camera( transform, vehicle_id_stream) if pylot.flags.must_add_depth_camera_sensor(): (depth_camera_stream, depth_camera_setup) = pylot.operator_creator.add_depth_camera( transform, vehicle_id_stream) else: depth_camera_stream = None if pylot.flags.must_add_segmented_camera_sensor(): (ground_segmented_stream, _) = pylot.operator_creator.add_segmented_camera( transform, vehicle_id_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, lidar_setup) = pylot.operator_creator.add_lidar( transform, vehicle_id_stream) else: point_cloud_stream = None if FLAGS.obstacle_location_finder_sensor == 'lidar': depth_stream = point_cloud_stream elif FLAGS.obstacle_location_finder_sensor == 'depth_camera': depth_stream = depth_camera_stream else: raise ValueError( 'Unknown --obstacle_location_finder_sensor value {}'.format( FLAGS.obstacle_location_finder_sensor)) imu_stream = None if FLAGS.imu: (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, can_bus_stream, depth_stream, depth_camera_stream, ground_segmented_stream, ground_obstacles_stream, ground_speed_limit_signs_stream, ground_stop_signs_stream) traffic_lights_stream = \ pylot.component_creator.add_traffic_light_detection( transform, vehicle_id_stream, can_bus_stream, depth_stream, ground_traffic_lights_stream) lane_detection_stream = pylot.component_creator.add_lane_detection( center_camera_stream, can_bus_stream) obstacles_tracking_stream = pylot.component_creator.add_obstacle_tracking( center_camera_stream, rgb_camera_setup, obstacles_stream, depth_stream, vehicle_id_stream, can_bus_stream, ground_obstacles_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(can_bus_stream, obstacles_stream, depth_stream, ground_obstacles_stream) prediction_stream = pylot.component_creator.add_prediction( obstacles_tracking_stream, vehicle_id_stream, transform, can_bus_stream) # 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, can_bus_stream, prediction_stream, center_camera_stream, obstacles_stream, traffic_lights_stream, open_drive_stream, global_trajectory_stream) # Add the behaviour planning and control operator. control_stream = pylot.component_creator.add_control( can_bus_stream, waypoints_stream) control_loop_stream.set(control_stream) pylot.operator_creator.add_sensor_visualizers(center_camera_stream, depth_camera_stream, point_cloud_stream, ground_segmented_stream, imu_stream, can_bus_stream) erdos.run()
def main(argv): transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION, pylot.utils.Rotation()) control_loop_stream = erdos.LoopStream() # Create carla operator. (can_bus_stream, 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) # Add sensors. (center_camera_stream, rgb_camera_setup) = pylot.operator_creator.add_rgb_camera( transform, vehicle_id_stream) (depth_camera_stream, depth_camera_setup) = pylot.operator_creator.add_depth_camera( transform, vehicle_id_stream) (segmented_stream, _) = pylot.operator_creator.add_segmented_camera(transform, vehicle_id_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, '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, 'traffic_light_segmented_camera', 45) (traffic_light_depth_camera_stream, _) = \ pylot.operator_creator.add_depth_camera( transform, vehicle_id_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, can_bus_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) 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) 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, can_bus_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, can_bus_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, can_bus_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, can_bus_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()
def main(argv): erdos.run(driver)