Esempio n. 1
0
    def __init__(self, left_camera_stream, right_camera_stream,
                 depth_estimation_stream, transform, fov, flags):
        left_camera_stream.add_callback(self.on_left_camera_msg)
        right_camera_stream.add_callback(self.on_right_camera_msg)
        erdos.add_watermark_callback([left_camera_stream, right_camera_stream],
                                     [depth_estimation_stream],
                                     self.compute_depth)
        self._flags = flags
        self._left_imgs = {}
        self._right_imgs = {}
        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)
        self._transform = transform
        self._fov = fov
        # Load AnyNet
        model = anynet.AnyNet(AnyNetArgs())
        model = nn.DataParallel(model).cuda()
        pretrained = os.path.join(self._flags.depth_estimation_model_path,
                                  'checkpoint/sceneflow/sceneflow.tar')
        resume = os.path.join(self._flags.depth_estimation_model_path,
                              'checkpoint/kitti2015_ck/checkpoint.tar')
        if os.path.isfile(pretrained):
            _ = torch.load(pretrained)
        else:
            self._logger.warning('No pretrained Anynet model')

        if os.path.isfile(resume):
            _ = torch.load(resume)
        else:
            self._logger.warning('No Anynet checkpoint available')

        self._model = model
    def __init__(self,
                 ground_traffic_lights_stream,
                 tl_camera_stream,
                 depth_camera_stream,
                 segmented_camera_stream,
                 can_bus_stream,
                 traffic_lights_stream,
                 name,
                 flags,
                 log_file_name=None):
        ground_traffic_lights_stream.add_callback(self.on_traffic_light_update)
        tl_camera_stream.add_callback(self.on_bgr_camera_update)
        depth_camera_stream.add_callback(self.on_depth_camera_update)
        segmented_camera_stream.add_callback(self.on_segmented_frame)
        can_bus_stream.add_callback(self.on_can_bus_update)
        erdos.add_watermark_callback([
            ground_traffic_lights_stream, tl_camera_stream,
            depth_camera_stream, segmented_camera_stream, can_bus_stream
        ], [traffic_lights_stream], self.on_watermark)
        self._name = name
        self._logger = erdos.utils.setup_logging(name, log_file_name)
        self._flags = flags
        _, world = get_world(self._flags.carla_host, self._flags.carla_port,
                             self._flags.carla_timeout)
        if world is None:
            raise ValueError("There was an issue connecting to the simulator.")
        self._town_name = world.get_map().name

        self._traffic_lights = deque()
        self._bgr_msgs = deque()
        self._depth_frame_msgs = deque()
        self._segmented_msgs = deque()
        self._can_bus_msgs = deque()
        self._frame_cnt = 0
Esempio n. 3
0
 def __init__(self,
              ground_segmented_stream,
              segmented_stream,
              name,
              flags,
              log_file_name=None,
              csv_file_name=None):
     ground_segmented_stream.add_callback(self.on_ground_segmented_frame)
     segmented_stream.add_callback(self.on_segmented_frame)
     # Register a watermark callback.
     erdos.add_watermark_callback(
         [ground_segmented_stream, segmented_stream], [],
         self.on_notification)
     self._name = name
     self._flags = flags
     self._logger = erdos.utils.setup_logging(name, log_file_name)
     self._csv_logger = erdos.utils.setup_csv_logging(
         name + '-csv', csv_file_name)
     # Buffer of ground truth segmented frames.
     self._ground_frames = []
     # Buffer of segmentation output frames.
     self._segmented_frames = []
     # Heap storing pairs of (ground/output time, game time).
     self._segmented_start_end_times = []
     self._sim_interval = None
     self._last_notification = None
Esempio n. 4
0
 def __init__(self, read_stream, top_stream):
     read_stream.add_callback(lambda m: print(
         "CallbackWatermarkListener: received message {m}".format(m=m)))
     erdos.add_watermark_callback(
         [read_stream, top_stream], [],
         lambda t: print("CallbackWatermarkListener: received watermark {t}"
                         .format(t=t)))
Esempio n. 5
0
    def __init__(self, pose_stream, waypoints_stream, control_stream, flags):
        pose_stream.add_callback(self.on_pose_update)
        waypoints_stream.add_callback(self.on_waypoints_update)
        erdos.add_watermark_callback([pose_stream, waypoints_stream],
                                     [control_stream], self.on_watermark)
        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)
        self._flags = flags
        self._mpc_config = global_config

        pid_use_real_time = False
        if self._flags.execution_mode == 'real-world':
            # The PID is executing on a real car. Use the real time delta
            # between two control commands.
            pid_use_real_time = True
        if self._flags.carla_control_frequency == -1:
            dt = 1.0 / self._flags.carla_fps
        else:
            dt = 1.0 / self._flags.carla_control_frequency
        self._pid = PIDLongitudinalController(flags.pid_p, flags.pid_d,
                                              flags.pid_i, dt,
                                              pid_use_real_time)
        self._pose_msgs = deque()
        self._obstacles_msgs = deque()
        self._traffic_light_msgs = deque()
        self._waypoint_msgs = deque()
        self._mpc = None
Esempio n. 6
0
    def __init__(self, point_cloud_stream: erdos.ReadStream,
                 tracking_stream: erdos.ReadStream,
                 time_to_decision_stream: erdos.ReadStream,
                 prediction_stream: erdos.WriteStream, flags, lidar_setup):
        print("WARNING: R2P2 predicts only vehicle trajectories")
        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)
        self._csv_logger = erdos.utils.setup_csv_logging(
            self.config.name + '-csv', self.config.csv_log_file_name)
        self._flags = flags

        self._device = torch.device('cuda')
        self._r2p2_model = R2P2().to(self._device)
        state_dict = torch.load(flags.r2p2_model_path)
        self._r2p2_model.load_state_dict(state_dict)

        point_cloud_stream.add_callback(self.on_point_cloud_update)
        tracking_stream.add_callback(self.on_trajectory_update)
        time_to_decision_stream.add_callback(self.on_time_to_decision_update)
        erdos.add_watermark_callback([point_cloud_stream, tracking_stream],
                                     [prediction_stream], self.on_watermark)

        self._lidar_setup = lidar_setup

        self._point_cloud_msgs = deque()
        self._tracking_msgs = deque()
    def __init__(self,
                 obstacle_tracking_stream,
                 prediction_stream,
                 segmented_camera_stream,
                 name,
                 flags,
                 log_file_name=None):
        """ Initializes the TrackVisualizerOperator with the given
        parameters.

        Args:
            name: The name of the operator.
            flags: A handle to the global flags instance to retrieve the
                configuration.
            log_file_name: The file to log the required information to.
        """
        obstacle_tracking_stream.add_callback(self.on_tracking_update)
        prediction_stream.add_callback(self.on_prediction_update)
        segmented_camera_stream.add_callback(
            self.on_top_down_segmentation_update)
        erdos.add_watermark_callback([
            obstacle_tracking_stream, prediction_stream,
            segmented_camera_stream
        ], [], self.on_watermark)
        self._name = name
        self._logger = erdos.utils.setup_logging(name, log_file_name)
        self._flags = flags
        self._past_colors = {'person': [255, 0, 0], 'vehicle': [128, 128, 0]}
        self._future_colors = {'person': [0, 0, 255], 'vehicle': [0, 255, 0]}
        # Dictionaries to store incoming data.
        self._tracking_msgs = deque()
        self._top_down_segmentation_msgs = deque()
        self._prediction_msgs = deque()
Esempio n. 8
0
    def __init__(self, imu_stream: ReadStream, gnss_stream: ReadStream,
                 ground_pose_stream: ReadStream, pose_stream: WriteStream,
                 flags):
        # Queue of saved messages.
        self._imu_updates = deque()
        self._gnss_updates = deque()
        self._ground_pose_updates = None

        # Register callbacks on both the IMU and GNSS streams.
        imu_stream.add_callback(
            partial(self.save, msg_type="IMU", queue=self._imu_updates))

        gnss_stream.add_callback(
            partial(self.save, msg_type="GNSS", queue=self._gnss_updates))

        # Register the ground pose stream.
        self._ground_pose_updates = deque()
        ground_pose_stream.add_callback(
            partial(self.save,
                    msg_type="pose",
                    queue=self._ground_pose_updates))
        erdos.add_watermark_callback(
            [imu_stream, gnss_stream, ground_pose_stream], [],
            self.on_watermark)

        # Save the output stream.
        self._pose_stream = pose_stream

        # Initialize a logger.
        self._flags = flags
        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)

        # Gravity vector.
        self._g = np.array([0, 0, -9.81])

        # Previous timestamp values.
        self._last_pose_estimate = None
        self._last_timestamp = None

        # NOTE: At the start of the simulation, the vehicle drops down from
        # the sky, during which the IMU values screw up the calculations.
        # This boolean flag takes care to start the prediction only when the
        # values have stabilized.
        self._is_started = False

        # Constants required for the Kalman filtering.
        var_imu_f, var_imu_w, var_gnss = 0.5, 0.5, 0.1
        self.__Q = np.identity(6)
        self.__Q[0:3, 0:3] = self.__Q[0:3, 0:3] * var_imu_f
        self.__Q[3:6, 3:6] = self.__Q[3:6, 3:6] * var_imu_w

        self.__F = np.identity(9)

        self.__L = np.zeros([9, 6])
        self.__L[3:9, :] = np.identity(6)

        self.__R_GNSS = np.identity(3) * var_gnss

        self._last_covariance = np.zeros((9, 9))
Esempio n. 9
0
 def __init__(self, left_stream, right_stream, write_stream):
     self.left_msgs = {}
     self.right_msgs = {}
     left_stream.add_callback(self.recv_left)
     right_stream.add_callback(self.recv_right)
     erdos.add_watermark_callback([left_stream, right_stream],
                                  [write_stream], self.send_joined)
Esempio n. 10
0
    def __init__(self, depth_camera_stream: ReadStream,
                 center_camera_stream: ReadStream,
                 segmented_camera_stream: ReadStream, pose_stream: ReadStream,
                 ground_obstacles_stream: ReadStream,
                 ground_speed_limit_signs_stream: ReadStream,
                 ground_stop_signs_stream: ReadStream,
                 obstacles_stream: WriteStream, flags):
        depth_camera_stream.add_callback(self.on_depth_camera_update)
        center_camera_stream.add_callback(self.on_bgr_camera_update)
        segmented_camera_stream.add_callback(self.on_segmented_frame)
        pose_stream.add_callback(self.on_pose_update)
        ground_obstacles_stream.add_callback(self.on_obstacles_update)
        ground_speed_limit_signs_stream.add_callback(
            self.on_speed_limit_signs_update)
        ground_stop_signs_stream.add_callback(self.on_stop_signs_update)
        # Register a completion watermark callback. The callback is invoked
        # after all the messages with a given timestamp have been received.
        erdos.add_watermark_callback([
            depth_camera_stream, center_camera_stream, segmented_camera_stream,
            pose_stream, ground_obstacles_stream,
            ground_speed_limit_signs_stream, ground_stop_signs_stream
        ], [obstacles_stream], self.on_watermark)

        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)
        self._flags = flags
        # Queues of incoming data.
        self._bgr_msgs = deque()
        self._pose_msgs = deque()
        self._depth_frame_msgs = deque()
        self._obstacles = deque()
        self._segmented_msgs = deque()
        self._speed_limit_signs = deque()
        self._stop_signs = deque()
        self._frame_cnt = 0
Esempio n. 11
0
 def __init__(self,
              obstacles_stream,
              ground_obstacles_stream,
              name,
              flags,
              log_file_name=None,
              csv_file_name=None):
     obstacles_stream.add_callback(self.on_obstacles)
     ground_obstacles_stream.add_callback(self.on_ground_obstacles)
     erdos.add_watermark_callback(
         [obstacles_stream, ground_obstacles_stream], [],
         self.on_notification)
     self._name = name
     self._flags = flags
     self._logger = erdos.utils.setup_logging(name, log_file_name)
     self._csv_logger = erdos.utils.setup_csv_logging(
         name + '-csv', csv_file_name)
     self._last_notification = None
     # Buffer of detected obstacles.
     self._detected_obstacles = []
     # Buffer of ground obstacles.
     self._ground_obstacles = []
     # Heap storing pairs of (ground/output time, game time).
     self._detector_start_end_times = []
     self._sim_interval = None
Esempio n. 12
0
    def __init__(self,
                 pose_stream,
                 point_cloud_stream,
                 tracking_stream,
                 vehicle_id_stream,
                 prediction_stream,
                 flags,
                 lidar_setup):
        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)
        self._flags = flags

        self._device = torch.device('cuda')
        self._r2p2_model = R2P2().to(self._device)
        state_dict = torch.load(flags.r2p2_model_path)
        self._r2p2_model.load_state_dict(state_dict)

        pose_stream.add_callback(self.on_pose_update)
        point_cloud_stream.add_callback(self.on_point_cloud_update)
        tracking_stream.add_callback(self.on_trajectory_update)
        erdos.add_watermark_callback(
            [pose_stream, point_cloud_stream, tracking_stream],
            [prediction_stream], self.on_watermark)

        self._vehicle_id_stream = vehicle_id_stream
        self._lidar_setup = lidar_setup

        self._can_bus_msgs = deque()
        self._point_cloud_msgs = deque()
        self._tracking_msgs = deque()
Esempio n. 13
0
 def __init__(self,
              can_bus_stream,
              tracking_stream,
              prediction_stream,
              name,
              flags,
              log_file_name=None,
              csv_file_name=None):
     can_bus_stream.add_callback(self._on_can_bus_update)
     tracking_stream.add_callback(self._on_tracking_update)
     prediction_stream.add_callback(self._on_prediction_update)
     erdos.add_watermark_callback(
         [can_bus_stream, tracking_stream, prediction_stream], [],
         self.on_notification)
     self._name = name
     self._flags = flags
     self._logger = erdos.utils.setup_logging(self._name, log_file_name)
     self._csv_logger = erdos.utils.setup_csv_logging(
         self._name + '-csv', csv_file_name)
     # Message buffers.
     self._prediction_msgs = deque()
     self._tracking_msgs = deque()
     self._can_bus_msgs = deque()
     # Accumulated list of predictions, from oldest to newest.
     self._predictions = deque(
         maxlen=self._flags.prediction_num_future_steps)
    def __init__(self,
                 pose_stream,
                 open_drive_stream,
                 route_stream,
                 trajectory_stream,
                 flags,
                 goal_location=None):
        pose_stream.add_callback(self.on_pose_update)
        open_drive_stream.add_callback(self.on_opendrive_map)
        route_stream.add_callback(self.on_route_msg)
        erdos.add_watermark_callback(
            [pose_stream, open_drive_stream, route_stream],
            [trajectory_stream], self.on_watermark)

        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)
        self._flags = flags
        # Do not set the goal location here so that the behavior planner
        # issues an initial message.
        self._goal_location = None
        # Initialize the state of the behaviour planner.
        self.__initialize_behaviour_planner()
        self._pose_msgs = deque()
        self._ego_info = EgoInfo()
        if goal_location:
            self._route = Waypoints(
                deque([
                    pylot.utils.Transform(goal_location,
                                          pylot.utils.Rotation())
                ]))
        else:
            self._route = None
        self._map = None
Esempio n. 15
0
 def __init__(self,
              can_bus_stream,
              ground_obstacles_stream,
              ground_traffic_lights_stream,
              waypoints_stream,
              control_stream,
              name,
              flags,
              log_file_name=None,
              csv_file_name=None):
     can_bus_stream.add_callback(self.on_can_bus_update)
     ground_obstacles_stream.add_callback(self.on_obstacles_update)
     ground_traffic_lights_stream.add_callback(
         self.on_traffic_lights_update)
     waypoints_stream.add_callback(self.on_waypoints_update)
     erdos.add_watermark_callback([
         can_bus_stream, ground_obstacles_stream,
         ground_traffic_lights_stream, waypoints_stream
     ], [control_stream], self.on_watermark)
     self._name = name
     self._logger = erdos.utils.setup_logging(name, log_file_name)
     self._csv_logger = erdos.utils.setup_csv_logging(
         name + '-csv', csv_file_name)
     self._flags = flags
     self._map = HDMap(
         get_map(self._flags.carla_host, self._flags.carla_port,
                 self._flags.carla_timeout), log_file_name)
     self._pid = PID(p=flags.pid_p, i=flags.pid_i, d=flags.pid_d)
     self._can_bus_msgs = deque()
     self._obstacle_msgs = deque()
     self._traffic_light_msgs = deque()
     self._waypoint_msgs = deque()
    def __init__(self, waypoints_read_stream, pose_read_stream,
                 localization_pose_stream, notify_stream1, notify_stream2,
                 waypoints_write_stream, pose_write_stream,
                 release_sensor_stream, flags):
        # Register callbacks on both the waypoints and the pose stream.
        waypoints_read_stream.add_callback(self.on_waypoints_update)
        pose_read_stream.add_callback(self.on_pose_update)
        localization_pose_stream.add_callback(self.on_localization_update)
        erdos.add_watermark_callback([notify_stream1, notify_stream2],
                                     [release_sensor_stream],
                                     self.on_sensor_ready)

        # Register watermark callback on pose and the joined stream.
        erdos.add_watermark_callback(
            [pose_read_stream], [waypoints_write_stream, pose_write_stream],
            self.on_pose_watermark)

        # Save the write streams.
        self._waypoints_write_stream = waypoints_write_stream

        # Initialize a logger.
        self._flags = flags
        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)
        self._csv_logger = erdos.utils.setup_csv_logging(
            self.config.name + '-csv', self.config.csv_log_file_name)

        # Data used by the operator.
        self._pose_map = dict()
        self._waypoints = deque()
        self._first_waypoint = True
        self._last_highest_applicable_time = None
Esempio n. 17
0
    def __init__(self,
                 ground_obstacles_stream,
                 can_bus_stream,
                 ground_tracking_stream,
                 name,
                 flags,
                 log_file_name=None):
        """Initializes the PerfectTracker Operator. """
        ground_obstacles_stream.add_callback(self.on_obstacles_update)
        can_bus_stream.add_callback(self.on_can_bus_update)
        erdos.add_watermark_callback([ground_obstacles_stream, can_bus_stream],
                                     [ground_tracking_stream],
                                     self.on_watermark)
        self._name = name
        self._logger = erdos.utils.setup_logging(name, log_file_name)
        self._flags = flags
        # Queues of incoming data.
        self._obstacles_raw_msgs = deque()
        self._can_bus_msgs = deque()

        # Processed data. Key is actor id, value is deque containing the past
        # trajectory of the corresponding actor. Trajectory is stored in world
        # coordinates, for ease of transformation.
        trajectory = lambda: deque(maxlen=self._flags.
                                   perfect_tracking_num_steps)
        self._obstacles = defaultdict(trajectory)
Esempio n. 18
0
 def __init__(self, ground_vehicle_id_stream: erdos.ReadStream,
              release_sensor_stream: erdos.ReadStream,
              camera_stream: erdos.WriteStream,
              notify_reading_stream: erdos.WriteStream, camera_setup,
              flags):
     erdos.add_watermark_callback([release_sensor_stream], [],
                                  self.release_data)
     self._vehicle_id_stream = ground_vehicle_id_stream
     self._camera_stream = camera_stream
     self._notify_reading_stream = notify_reading_stream
     self._flags = flags
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     self._camera_setup = camera_setup
     # The hero vehicle actor object we obtain from the simulator.
     self._vehicle = None
     # The camera sensor actor object we obtain from the simulator.
     self._camera = None
     self._pickle_lock = threading.Lock()
     self._pickled_messages = {}
     # Lock to ensure that the callbacks do not execute simultaneously.
     self._lock = threading.Lock()
     # If false then the operator does not send data until it receives
     # release data watermark. Otherwise, it sends as soon as it
     # receives it.
     self._release_data = False
Esempio n. 19
0
    def __init__(self,
                 pose_stream,
                 prediction_stream,
                 global_trajectory_stream,
                 open_drive_stream,
                 time_to_decision_stream,
                 waypoints_stream,
                 flags,
                 goal_location=None,
                 log_file_name=None,
                 csv_file_name=None):
        pose_stream.add_callback(self.on_pose_update)
        prediction_stream.add_callback(self.on_prediction_update)
        global_trajectory_stream.add_callback(self.on_global_trajectory)
        open_drive_stream.add_callback(self.on_opendrive_map)
        time_to_decision_stream.add_callback(self.on_time_to_decision)
        erdos.add_watermark_callback(
            [pose_stream, prediction_stream, time_to_decision_stream],
            [waypoints_stream], self.on_watermark)
        self._logger = erdos.utils.setup_logging(self.config.name,
                                                 self.config.log_file_name)
        self._flags = flags
        self._vehicle_transform = None
        self._map = None
        self._waypoints = None
        self._prev_waypoints = None
        self._goal_location = goal_location

        self._pose_msgs = deque()
        self._prediction_msgs = deque()
        self._ttd_msgs = deque()
Esempio n. 20
0
 def __init__(self, camera_stream, control_stream, flags):
     # pose_stream.add_callback(self.on_pose_update)
     # waypoints_stream.add_callback(self.on_waypoints_update)
     erdos.add_watermark_callback([camera_stream],
                                  [control_stream], self.on_watermark)
     self._flags = flags
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
Esempio n. 21
0
 def __init__(self, ground_vehicle_id_stream: ReadStream,
              wait_stream: ReadStream, control_stream: WriteStream, flags):
     erdos.add_watermark_callback([wait_stream], [control_stream],
                                  self.on_watermark)
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     self._vehicle_id_stream = ground_vehicle_id_stream
     self._vehicle = None
     self._flags = flags
Esempio n. 22
0
 def __init__(self, pose_stream: erdos.ReadStream,
              prediction_stream: erdos.ReadStream,
              static_obstacles_stream: erdos.ReadStream,
              lanes_stream: erdos.ReadStream,
              route_stream: erdos.ReadStream,
              open_drive_stream: erdos.ReadStream,
              time_to_decision_stream: erdos.ReadStream,
              waypoints_stream: erdos.WriteStream, flags):
     pose_stream.add_callback(self.on_pose_update)
     prediction_stream.add_callback(self.on_prediction_update)
     static_obstacles_stream.add_callback(self.on_static_obstacles_update)
     lanes_stream.add_callback(self.on_lanes_update)
     route_stream.add_callback(self.on_route)
     open_drive_stream.add_callback(self.on_opendrive_map)
     time_to_decision_stream.add_callback(self.on_time_to_decision)
     erdos.add_watermark_callback([
         pose_stream, prediction_stream, static_obstacles_stream,
         lanes_stream, time_to_decision_stream, route_stream
     ], [waypoints_stream], self.on_watermark)
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     self._flags = flags
     # We do not know yet the vehicle's location.
     self._ego_transform = None
     self._map = None
     self._world = World(flags, self._logger)
     if self._flags.planning_type == 'waypoint':
         # Use the FOT planner for overtaking.
         from pylot.planning.frenet_optimal_trajectory.fot_planner \
             import FOTPlanner
         self._planner = FOTPlanner(self._world, self._flags, self._logger)
     elif self._flags.planning_type == 'frenet_optimal_trajectory':
         from pylot.planning.frenet_optimal_trajectory.fot_planner \
             import FOTPlanner
         self._planner = FOTPlanner(self._world, self._flags, self._logger)
     elif self._flags.planning_type == 'hybrid_astar':
         from pylot.planning.hybrid_astar.hybrid_astar_planner \
             import HybridAStarPlanner
         self._planner = HybridAStarPlanner(self._world, self._flags,
                                            self._logger)
     elif self._flags.planning_type == 'rrt_star':
         from pylot.planning.rrt_star.rrt_star_planner import RRTStarPlanner
         self._planner = RRTStarPlanner(self._world, self._flags,
                                        self._logger)
     else:
         raise ValueError('Unexpected planning type: {}'.format(
             self._flags.planning_type))
     self._state = BehaviorPlannerState.FOLLOW_WAYPOINTS
     self._pose_msgs = deque()
     self._prediction_msgs = deque()
     self._static_obstacles_msgs = deque()
     self._lanes_msgs = deque()
     self._ttd_msgs = deque()
Esempio n. 23
0
 def __init__(self, waypoints_stream, camera_stream, can_bus_stream, flags):
     waypoints_stream.add_callback(self.on_wp_update)
     camera_stream.add_callback(self.on_bgr_frame)
     can_bus_stream.add_callback(self.on_can_bus_update)
     erdos.add_watermark_callback([camera_stream, waypoints_stream], [],
                                  self.on_watermark)
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     self._flags = flags
     self._bgr_msgs = deque()
     self._waypoints_msgs = deque()
     self._can_bus_msgs = deque()
 def __init__(self, pose_stream: ReadStream, open_drive_stream: ReadStream,
              center_camera_stream: ReadStream,
              detected_lane_stream: WriteStream, flags):
     pose_stream.add_callback(self.on_pose_update)
     center_camera_stream.add_callback(self.on_bgr_camera_update)
     erdos.add_watermark_callback([pose_stream, center_camera_stream],
                                  [detected_lane_stream],
                                  self.on_position_update)
     self._flags = flags
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     self._bgr_msgs = deque()
     self._pose_msgs = deque()
Esempio n. 25
0
 def __init__(self, pose_stream, waypoints_stream, control_stream, flags):
     pose_stream.add_callback(self.on_pose_update)
     waypoints_stream.add_callback(self.on_waypoints_update)
     erdos.add_watermark_callback([pose_stream, waypoints_stream],
                                  [control_stream], self.on_watermark)
     self._flags = flags
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     self._pid = PID(p=self._flags.pid_p,
                     i=self._flags.pid_i,
                     d=self._flags.pid_d)
     # Queues in which received messages are stored.
     self._waypoint_msgs = deque()
     self._pose_msgs = deque()
Esempio n. 26
0
 def __init__(self,
              can_bus_stream,
              waypoints_stream,
              traffic_lights_stream,
              obstacles_stream,
              point_cloud_stream,
              open_drive_stream,
              control_stream,
              name,
              flags,
              camera_setup,
              log_file_name=None,
              csv_file_name=None):
     can_bus_stream.add_callback(self.on_can_bus_update)
     waypoints_stream.add_callback(self.on_waypoints_update)
     traffic_lights_stream.add_callback(self.on_traffic_lights_update)
     obstacles_stream.add_callback(self.on_obstacles_update)
     point_cloud_stream.add_callback(self.on_point_cloud_update)
     open_drive_stream.add_callback(self.on_open_drive_map)
     erdos.add_watermark_callback([
         can_bus_stream, waypoints_stream, traffic_lights_stream,
         obstacles_stream, point_cloud_stream
     ], [control_stream], self.on_watermark)
     self._name = name
     self._flags = flags
     self._camera_setup = camera_setup
     self._log_file_name = log_file_name
     self._logger = erdos.utils.setup_logging(name, log_file_name)
     self._csv_logger = erdos.utils.setup_csv_logging(
         name + '-csv', csv_file_name)
     if not hasattr(self._flags, 'track'):
         # The agent is not used in the Carla challenge. It has access to
         # the simulator, and to the town map.
         self._map = HDMap(
             get_map(self._flags.carla_host, self._flags.carla_port,
                     self._flags.carla_timeout), log_file_name)
         self._logger.debug('Agent running using map')
     else:
         self._map = None
     self._pid = PID(p=self._flags.pid_p,
                     i=self._flags.pid_i,
                     d=self._flags.pid_d)
     # Queues in which received messages are stored.
     self._waypoint_msgs = deque()
     self._can_bus_msgs = deque()
     self._traffic_lights_msgs = deque()
     self._obstacles_msgs = deque()
     self._point_clouds = deque()
     self._vehicle_labels = {'car', 'bicycle', 'motorcycle', 'bus', 'truck'}
Esempio n. 27
0
 def __init__(self, pose_stream, waypoints_stream, control_stream, flags):
     pose_stream.add_callback(self.on_pose_update)
     waypoints_stream.add_callback(self.on_waypoints_update)
     erdos.add_watermark_callback([pose_stream, waypoints_stream],
                                  [control_stream], self.on_watermark)
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     self._flags = flags
     self._config = global_config
     self._pid = PID(p=flags.pid_p, i=flags.pid_i, d=flags.pid_d)
     self._pose_msgs = deque()
     self._obstacles_msgs = deque()
     self._traffic_light_msgs = deque()
     self._waypoint_msgs = deque()
     self._mpc = None
Esempio n. 28
0
 def __init__(self, obstacles_stream, depth_stream, pose_stream,
              obstacles_output_stream, flags, camera_setup):
     obstacles_stream.add_callback(self.on_obstacles_update)
     depth_stream.add_callback(self.on_depth_update)
     pose_stream.add_callback(self.on_pose_update)
     erdos.add_watermark_callback(
         [obstacles_stream, depth_stream, pose_stream],
         [obstacles_output_stream], self.on_watermark)
     self._flags = flags
     self._camera_setup = camera_setup
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     # Queues in which received messages are stored.
     self._obstacles_msgs = deque()
     self._depth_msgs = deque()
     self._pose_msgs = deque()
Esempio n. 29
0
 def __init__(self, pose_stream, waypoints_stream, control_stream, flags):
     pose_stream.add_callback(self.on_pose_update)
     waypoints_stream.add_callback(self.on_waypoints_update)
     erdos.add_watermark_callback([pose_stream, waypoints_stream],
                                  [control_stream], self.on_watermark)
     self._flags = flags
     self._logger = erdos.utils.setup_logging(self.config.name,
                                              self.config.log_file_name)
     # TODO(ionel): Add path to calculate pid error with real time.
     if self._flags.carla_control_frequency == -1:
         dt = 1.0 / self._flags.carla_fps
     else:
         dt = 1.0 / self._flags.carla_control_frequency
     self._pid = PIDLongitudinalController(1.0, 0, 0.05, dt)
     # Queues in which received messages are stored.
     self._waypoint_msgs = deque()
     self._pose_msgs = deque()
Esempio n. 30
0
    def __init__(self,
                 left_camera_stream,
                 right_camera_stream,
                 depth_estimation_stream,
                 name,
                 transform,
                 fov,
                 flags,
                 log_file_name=None,
                 csv_file_name=None):

        left_camera_stream.add_callback(self.on_left_camera_msg)
        right_camera_stream.add_callback(self.on_right_camera_msg)
        erdos.add_watermark_callback([left_camera_stream, right_camera_stream],
                                     [depth_estimation_stream],
                                     self.compute_depth)
        self._name = name
        self._flags = flags
        self._left_imgs = {}
        self._right_imgs = {}
        self._logger = erdos.utils.setup_logging(name, log_file_name)
        self._csv_logger = erdos.utils.setup_csv_logging(
            name + '-csv', csv_file_name)
        self._transform = transform
        self._fov = fov
        # Load AnyNet
        model = anynet.anynet.AnyNet()
        model = nn.DataParallel(model).cuda()
        pretrained = os.path.join(self._flags.depth_estimation_model_path,
                                  'results/pretrained_anynet/checkpoint.tar')
        resume = os.path.join(self._flags.depth_estimation_model_path,
                              'results/finetune_anynet/checkpoint.tar')
        if os.path.isfile(pretrained):
            checkpoint = torch.load(pretrained)
            model.load_state_dict(checkpoint['state_dict'])
        else:
            self._logger.warning('No pretrained Anynet model')

        if os.path.isfile(resume):
            checkpoint = torch.load(resume)
            model.load_state_dict(checkpoint['state_dict'])
        else:
            self._logger.warning('No Anynet checkpoint available')

        self._model = model