예제 #1
0
    def run(self):
        # Read the vehicle id from the vehicle id stream
        vehicle_id_msg = self._vehicle_id_stream.read()
        vehicle_id = vehicle_id_msg.data
        self._logger.debug(
            "The LidarDriverOperator received the vehicle id: {}".format(
                vehicle_id))

        # Connect to the world. We connect here instead of in the constructor
        # to ensure we're connected to the latest world.
        client, world = get_world(self._flags.simulator_host,
                                  self._flags.simulator_port,
                                  self._flags.simulator_timeout)
        simulator_version = client.get_client_version()
        set_simulation_mode(world, self._flags)

        self._vehicle = get_vehicle_handle(world, vehicle_id)

        # Install the Lidar.
        lidar_blueprint = world.get_blueprint_library().find(
            self._lidar_setup.lidar_type)
        lidar_blueprint.set_attribute('channels',
                                      str(self._lidar_setup.channels))
        if not (simulator_version.startswith('0.8') or re.match(
                '0\.9\.[0-6]', simulator_version) is not None):  # noqa: W605
            # Any simulator version after 0.9.6.
            lidar_blueprint.set_attribute(
                'range', str(self._lidar_setup.get_range_in_meters()))
        else:
            lidar_blueprint.set_attribute('range',
                                          str(self._lidar_setup.range))
        lidar_blueprint.set_attribute('points_per_second',
                                      str(self._lidar_setup.points_per_second))
        lidar_blueprint.set_attribute(
            'rotation_frequency', str(self._lidar_setup.rotation_frequency))
        lidar_blueprint.set_attribute('upper_fov',
                                      str(self._lidar_setup.upper_fov))
        lidar_blueprint.set_attribute('lower_fov',
                                      str(self._lidar_setup.lower_fov))
        if self._flags.simulator_lidar_frequency == -1:
            lidar_blueprint.set_attribute('sensor_tick', '0.0')
        else:
            lidar_blueprint.set_attribute(
                'sensor_tick',
                str(1.0 / self._flags.simulator_lidar_frequency))

        transform = self._lidar_setup.get_transform().as_simulator_transform()

        self._logger.debug("Spawning a lidar: {}".format(self._lidar_setup))
        # NOTE: The LiDAR can be attached on a rigid or a spring arm. If the
        # LiDAR is attached too low, on a rigit, then the point cloud is empty.
        # Otherwise, if the LiDAR is attached on a SpringArm it won't provide
        # 360 degrees point clouds.
        self._lidar = world.spawn_actor(lidar_blueprint,
                                        transform,
                                        attach_to=self._vehicle)

        # Register the callback on the Lidar.
        self._lidar.listen(self.process_point_clouds)
    def run(self):
        # Read the vehicle ID from the vehicle ID stream.
        vehicle_id_msg = self._vehicle_id_stream.read()
        vehicle_id = vehicle_id_msg.data

        # Connect to the world. We connect here instead of in the constructor
        # to ensure we're connected to the latest world.
        _, world = get_world(self._flags.carla_host, self._flags.carla_port,
                             self._flags.carla_timeout)
        set_simulation_mode(world, self._flags)

        self._vehicle = get_vehicle_handle(world, vehicle_id)
예제 #3
0
    def run(self):
        # Read the vehicle id from the vehicle id stream
        vehicle_id_msg = self._vehicle_id_stream.read()
        vehicle_id = vehicle_id_msg.data
        self._logger.debug(
            "The IMUDriverOperator received the vehicle id: {}".format(
                vehicle_id))

        # Connect to the world. We connect here instead of in the constructor
        # to ensure we're connected to the latest world.
        _, world = get_world(self._flags.simulator_host,
                             self._flags.simulator_port,
                             self._flags.simulator_timeout)
        set_simulation_mode(world, self._flags)

        self._vehicle = get_vehicle_handle(world, vehicle_id)

        # Install the IMU.
        imu_blueprint = world.get_blueprint_library().find('sensor.other.imu')

        # Set noise attributes.
        imu_blueprint.set_attribute('noise_accel_stddev_x',
                                    str(self._flags.accel_noise_stddev_x))
        imu_blueprint.set_attribute('noise_accel_stddev_y',
                                    str(self._flags.accel_noise_stddev_y))
        imu_blueprint.set_attribute('noise_accel_stddev_z',
                                    str(self._flags.accel_noise_stddev_z))
        imu_blueprint.set_attribute('noise_gyro_stddev_x',
                                    str(self._flags.gyro_noise_stddev_x))
        imu_blueprint.set_attribute('noise_gyro_stddev_y',
                                    str(self._flags.gyro_noise_stddev_y))
        imu_blueprint.set_attribute('noise_gyro_stddev_z',
                                    str(self._flags.gyro_noise_stddev_z))

        if self._flags.simulator_imu_frequency == -1:
            imu_blueprint.set_attribute('sensor_tick', '0.0')
        else:
            imu_blueprint.set_attribute(
                'sensor_tick', str(1.0 / self._flags.simulator_imu_frequency))

        transform = self._imu_setup.get_transform().as_simulator_transform()

        self._logger.debug("Spawning an IMU: {}".format(self._imu_setup))

        self._imu = world.spawn_actor(imu_blueprint,
                                      transform,
                                      attach_to=self._vehicle)

        # Register the callback on the IMU.
        self._imu.listen(self.process_imu)
예제 #4
0
    def run(self):
        # Read the vehicle ID from the vehicle ID stream.
        vehicle_id = self._vehicle_id_stream.read().data
        self._logger.debug(
            "The GNSSDriverOperator received the vehicle id: {}".format(
                vehicle_id))

        # Connect to the world.
        _, world = get_world(self._flags.simulator_host,
                             self._flags.simulator_port,
                             self._flags.simulator_timeout)
        set_simulation_mode(world, self._flags)

        # Retrieve the vehicle and install the GNSS sensor.
        self._vehicle = get_vehicle_handle(world, vehicle_id)
        gnss_blueprint = world.get_blueprint_library().find(
            'sensor.other.gnss')

        # Set the noise and bias parameters.
        gnss_blueprint.set_attribute('noise_alt_stddev',
                                     str(self._flags.gnss_noise_stddev_alt))
        gnss_blueprint.set_attribute('noise_lat_stddev',
                                     str(self._flags.gnss_noise_stddev_lat))
        gnss_blueprint.set_attribute('noise_lon_stddev',
                                     str(self._flags.gnss_noise_stddev_lon))
        gnss_blueprint.set_attribute('noise_alt_bias',
                                     str(self._flags.gnss_bias_alt))
        gnss_blueprint.set_attribute('noise_lat_bias',
                                     str(self._flags.gnss_bias_lat))
        gnss_blueprint.set_attribute('noise_lon_bias',
                                     str(self._flags.gnss_bias_lon))

        if self._flags.simulator_gnss_frequency == -1:
            gnss_blueprint.set_attribute('sensor_tick', '0.0')
        else:
            gnss_blueprint.set_attribute(
                'sensor_tick', str(1.0 / self._flags.simulator_gnss_frequency))
        transform = self._gnss_setup.get_transform().as_simulator_transform()
        self._logger.debug("Spawning a GNSS sensor: {}".format(
            self._gnss_setup))
        self._gnss = world.spawn_actor(gnss_blueprint,
                                       transform,
                                       attach_to=self._vehicle)

        # Register the callback on the GNSS sensor.
        self._gnss.listen(self.process_gnss)
예제 #5
0
    def run(self):
        # Read the vehicle id from the vehicle id stream
        vehicle_id_msg = self._vehicle_id_stream.read()
        vehicle_id = vehicle_id_msg.data
        self._logger.debug(
            "The CarlaCameraDriverOperator received the vehicle id: {}".format(
                vehicle_id))

        # Connect to the world. We connect here instead of in the constructor
        # to ensure we're connected to the latest world.
        _, 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.")
        set_simulation_mode(world, self._flags)

        self._vehicle = get_vehicle_handle(world, vehicle_id)

        # Install the camera.
        camera_blueprint = world.get_blueprint_library().find(
            self._camera_setup.camera_type)

        camera_blueprint.set_attribute('image_size_x',
                                       str(self._camera_setup.width))
        camera_blueprint.set_attribute('image_size_y',
                                       str(self._camera_setup.height))
        camera_blueprint.set_attribute('fov', str(self._camera_setup.fov))
        if self._flags.carla_camera_frequency == -1:
            camera_blueprint.set_attribute('sensor_tick', '0.0')
        else:
            camera_blueprint.set_attribute(
                'sensor_tick', str(1.0 / self._flags.carla_camera_frequency))

        transform = self._camera_setup.get_transform().as_carla_transform()

        self._logger.debug("Spawning a camera: {}".format(self._camera_setup))

        self._camera = world.spawn_actor(camera_blueprint,
                                         transform,
                                         attach_to=self._vehicle)

        # Register the callback on the camera.
        self._camera.listen(self.process_images)
    def run(self):
        # Read the vehicle id from the vehicle id stream
        vehicle_id_msg = self._vehicle_id_stream.read()
        vehicle_id = vehicle_id_msg.data
        self._logger.debug(
            "The CarlaLidarDriverOperator received the vehicle id: {}".format(
                vehicle_id))

        # Connect to the world. We connect here instead of in the constructor
        # to ensure we're connected to the latest world.
        _, 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.")
        set_simulation_mode(world, self._flags)

        self._vehicle = get_vehicle_handle(world, vehicle_id)

        # Install the Lidar.
        lidar_blueprint = world.get_blueprint_library().find(
            self._lidar_setup.lidar_type)
        lidar_blueprint.set_attribute('channels',
                                      str(self._lidar_setup.channels))
        if (self._flags.carla_version == '0.9.7'
                or self._flags.carla_version == '0.9.8'):
            lidar_blueprint.set_attribute(
                'range', str(self._lidar_setup.get_range_in_meters()))
        else:
            lidar_blueprint.set_attribute('range',
                                          str(self._lidar_setup.range))
        lidar_blueprint.set_attribute('points_per_second',
                                      str(self._lidar_setup.points_per_second))
        lidar_blueprint.set_attribute(
            'rotation_frequency', str(self._lidar_setup.rotation_frequency))
        lidar_blueprint.set_attribute('upper_fov',
                                      str(self._lidar_setup.upper_fov))
        lidar_blueprint.set_attribute('lower_fov',
                                      str(self._lidar_setup.lower_fov))
        if self._flags.carla_lidar_frequency == -1:
            lidar_blueprint.set_attribute('sensor_tick', '0.0')
        else:
            lidar_blueprint.set_attribute(
                'sensor_tick', str(1.0 / self._flags.carla_lidar_frequency))

        transform = self._lidar_setup.get_transform().as_carla_transform()

        self._logger.debug("Spawning a lidar: {}".format(self._lidar_setup))

        if self._flags.carla_version == '0.9.8':
            # Must attach lidar with a SpringArm, otherwise the point cloud is
            # empty.
            self._lidar = world.spawn_actor(
                lidar_blueprint,
                transform,
                attach_to=self._vehicle,
                attachment_type=carla.AttachmentType.SpringArm)
        else:
            self._lidar = world.spawn_actor(lidar_blueprint,
                                            transform,
                                            attach_to=self._vehicle)

        # Register the callback on the Lidar.
        self._lidar.listen(self.process_point_clouds)