當前位置: 首頁>>代碼示例>>Python>>正文


Python carla.WeatherParameters方法代碼示例

本文整理匯總了Python中carla.WeatherParameters方法的典型用法代碼示例。如果您正苦於以下問題:Python carla.WeatherParameters方法的具體用法?Python carla.WeatherParameters怎麽用?Python carla.WeatherParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在carla的用法示例。


在下文中一共展示了carla.WeatherParameters方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def __init__(self, filename, client):

        self.xml_tree = ET.parse(filename)
        self._filename = filename

        self._validate_openscenario_configuration()
        self.client = client

        self.catalogs = {}

        self.other_actors = []
        self.ego_vehicles = []
        self.trigger_points = []
        self.weather = carla.WeatherParameters()

        self.storyboard = self.xml_tree.find("Storyboard")
        self.story = self.storyboard.find("Story")
        self.init = self.storyboard.find("Init")

        logging.basicConfig()
        self.logger = logging.getLogger("[SR:OpenScenarioConfiguration]")

        self._set_parameters()
        self._parse_openscenario_configuration() 
開發者ID:carla-simulator,項目名稱:scenario_runner,代碼行數:26,代碼來源:openscenario_configuration.py

示例2: on_weather_changed

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def on_weather_changed(self, weather_parameters):
        """
        Callback on new weather parameters
        :return:
        """
        if not self.carla_world:
            return
        rospy.loginfo("Applying weather parameters...")
        weather = carla.WeatherParameters()
        weather.cloudiness = weather_parameters.cloudiness
        weather.precipitation = weather_parameters.precipitation
        weather.precipitation_deposits = weather_parameters.precipitation_deposits
        weather.wind_intensity = weather_parameters.wind_intensity
        weather.fog_density = weather_parameters.fog_density
        weather.fog_distance = weather_parameters.fog_distance
        weather.wetness = weather_parameters.wetness
        weather.sun_azimuth_angle = weather_parameters.sun_azimuth_angle
        weather.sun_altitude_angle = weather_parameters.sun_altitude_angle
        self.carla_world.set_weather(weather) 
開發者ID:carla-simulator,項目名稱:ros-bridge,代碼行數:21,代碼來源:bridge.py

示例3: find_weather_presets

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def find_weather_presets():
        """
        Get weather presets from CARLA
        """
        rgx = re.compile('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)')
        name = lambda x: ' '.join(m.group(0) for m in rgx.finditer(x))
        presets = [x for x in dir(carla.WeatherParameters) if re.match('[A-Z].+', x)]
        return [(getattr(carla.WeatherParameters, x), name(x)) for x in presets] 
開發者ID:carla-simulator,項目名稱:scenario_runner,代碼行數:10,代碼來源:carla_data_provider.py

示例4: parse_weather

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def parse_weather(route):
        """
        Returns a carla.WeatherParameters with the corresponding weather for that route. If the route
        has no weather attribute, the default one is triggered.
        """

        route_weather = route.find("weather")
        if route_weather is None:

            weather = carla.WeatherParameters(sun_altitude_angle=70)

        else:
            weather = carla.WeatherParameters()
            for weather_attrib in route.iter("weather"):

                if 'cloudiness' in weather_attrib.attrib:
                    weather.cloudiness = float(weather_attrib.attrib['cloudiness'])
                if 'precipitation' in weather_attrib.attrib:
                    weather.precipitation = float(weather_attrib.attrib['precipitation'])
                if 'precipitation_deposits' in weather_attrib.attrib:
                    weather.precipitation_deposits = float(weather_attrib.attrib['precipitation_deposits'])
                if 'wind_intensity' in weather_attrib.attrib:
                    weather.wind_intensity = float(weather_attrib.attrib['wind_intensity'])
                if 'sun_azimuth_angle' in weather_attrib.attrib:
                    weather.sun_azimuth_angle = float(weather_attrib.attrib['sun_azimuth_angle'])
                if 'sun_altitude_angle' in weather_attrib.attrib:
                    weather.sun_altitude_angle = float(weather_attrib.attrib['sun_altitude_angle'])
                if 'wetness' in weather_attrib.attrib:
                    weather.wetness = float(weather_attrib.attrib['wetness'])
                if 'fog_distance' in weather_attrib.attrib:
                    weather.fog_distance = float(weather_attrib.attrib['fog_distance'])
                if 'fog_density' in weather_attrib.attrib:
                    weather.fog_density = float(weather_attrib.attrib['fog_density'])

        return weather 
開發者ID:carla-simulator,項目名稱:scenario_runner,代碼行數:37,代碼來源:route_parser.py

示例5: use_sample

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def use_sample(self, sample):
        print('USE_SAMPLE Sample:', sample)
        weather = carla.WeatherParameters(**{k: sample.params._asdict()[k] for k in WEATHER_PARAMS})
        self.world.world.set_weather(weather)
        for obj in sample.objects:
            spawn = Transform(self.snap_to_ground(Location(x=obj.position[0],
                                                           y=-obj.position[1], z=1)),
                              Rotation(yaw=-obj.heading * 180 / math.pi - 90))
            attrs = dict()
            if 'color' in obj._fields:
                color = str(int(obj.color.r * 255)) + ',' \
                    + str(int(obj.color.g * 255)) + ',' + str(int(obj.color.b * 255))
                attrs['color'] = color
            if 'blueprint' in obj._fields:
                attrs['blueprint_filter'] = obj.blueprint
            agent = BrakeAgent
            if 'agent' in obj._fields:
                agent = AGENTS[obj.agent]
            if obj.type in ['Vehicle', 'Car', 'Truck', 'Bicycle', 'Motorcycle']:
                self.world.add_vehicle(agent,
                                       spawn=spawn,
                                       has_collision_sensor=False,
                                       has_lane_sensor=False,
                                       ego=obj is sample.objects[0],
                                       **attrs)
            elif obj.type == 'Pedestrian':
                self.world.add_pedestrian(spawn=spawn, **attrs)
            elif obj.type in ['Prop', 'Trash', 'Cone']:
                self.world.add_prop(spawn=spawn, **attrs)
            else:
                print('Unsupported object type:', obj.type) 
開發者ID:BerkeleyLearnVerify,項目名稱:VerifAI,代碼行數:33,代碼來源:carla_scenic_task.py

示例6: find_weather_presets

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def find_weather_presets():
    rgx = re.compile('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)')
    name = lambda x: ' '.join(m.group(0) for m in rgx.finditer(x))
    presets = [x for x in dir(carla.WeatherParameters) if re.match('[A-Z].+', x)]
    return [(getattr(carla.WeatherParameters, x), name(x)) for x in presets] 
開發者ID:BerkeleyLearnVerify,項目名稱:VerifAI,代碼行數:7,代碼來源:carla_world.py

示例7: find_weather_presets

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def find_weather_presets():
    rgx = re.compile('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)')
    name = lambda x: ' '.join(  # noqa: E731
        m.group(0) for m in rgx.finditer(x))
    presets = [
        x for x in dir(carla.WeatherParameters) if re.match('[A-Z].+', x)
    ]
    return [(getattr(carla.WeatherParameters, x), name(x)) for x in presets] 
開發者ID:praveen-palanisamy,項目名稱:macad-gym,代碼行數:10,代碼來源:spawn_control.py

示例8: set_weather

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def set_weather(world, weather):
    """Sets the simulation weather."""
    names = [
        name for name in dir(carla.WeatherParameters)
        if re.match('[A-Z].+', name)
    ]
    weathers = {x: getattr(carla.WeatherParameters, x) for x in names}
    world.set_weather(weathers[weather])
    return weathers 
開發者ID:erdos-project,項目名稱:pylot,代碼行數:11,代碼來源:utils.py

示例9: change_weather

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def change_weather(world, weather):
    world.set_weather(getattr(carla.WeatherParameters, weather)) 
開發者ID:erdos-project,項目名稱:pylot,代碼行數:4,代碼來源:sign_data_gatherer.py

示例10: find_weather_presets

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def find_weather_presets():
    presets = [
        x for x in dir(carla.WeatherParameters) if re.match('[A-Z].+', x)
    ]
    return presets 
開發者ID:erdos-project,項目名稱:pylot,代碼行數:7,代碼來源:sign_data_gatherer.py

示例11: setup_static

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def setup_static(world, client, scene_elements, actor_list):
  this_weather = scene_elements["weather"]
  weather = carla.WeatherParameters(
      cloudyness=this_weather["cloudyness"],
      precipitation=this_weather["precipitation"],
      precipitation_deposits=this_weather["precipitation_deposits"],
      sun_altitude_angle=this_weather["sun_altitude_angle"],
      sun_azimuth_angle=this_weather["sun_azimuth_angle"],
      wind_intensity=this_weather["wind_intensity"])
  world.set_weather(weather)

  spawn_cmds = []
  for car in scene_elements["static_cars"]:
    car_location = carla.Location(x=car["location_xyz"][0],
                                  y=car["location_xyz"][1],
                                  z=car["location_xyz"][2])
    car_rotation = carla.Rotation(pitch=car["rotation_pyr"][0],
                                  yaw=car["rotation_pyr"][1],
                                  roll=car["rotation_pyr"][2])
    car_bp = world.get_blueprint_library().find(car["bp"])
    assert car_bp is not None, car_bp
    # the static car can be walked though
    spawn_cmds.append(
        carla.command.SpawnActor(
            car_bp, carla.Transform(
                location=car_location, rotation=car_rotation)).then(
                    carla.command.SetSimulatePhysics(
                        carla.command.FutureActor, False)))

  # spawn the actors needed for the static scene setup
  if spawn_cmds:
    response = client.apply_batch_sync(spawn_cmds)
    all_actors = world.get_actors([x.actor_id for x in response])
    actor_list += all_actors 
開發者ID:JunweiLiang,項目名稱:Multiverse,代碼行數:36,代碼來源:utils.py

示例12: get_weather_from_env_action

# 需要導入模塊: import carla [as 別名]
# 或者: from carla import WeatherParameters [as 別名]
def get_weather_from_env_action(xml_tree, catalogs):
        """
        Extract the CARLA weather parameters from an OSC EnvironmentAction

        Args:
            xml_tree: Containing the EnvironmentAction,
                or the reference to the catalog it is defined in.
            catalogs: XML Catalogs that could contain the EnvironmentAction

        returns:
           Weather (srunner.scenariomanager.weather_sim.Weather)
        """
        set_environment = next(xml_tree.iter("EnvironmentAction"))

        if sum(1 for _ in set_environment.iter("Weather")) != 0:
            environment = set_environment.find("Environment")
        elif set_environment.find("CatalogReference") is not None:
            catalog_reference = set_environment.find("CatalogReference")
            environment = catalogs[catalog_reference.attrib.get(
                "catalogName")][catalog_reference.attrib.get("entryName")]

        weather = environment.find("Weather")
        sun = weather.find("Sun")

        carla_weather = carla.WeatherParameters()
        carla_weather.sun_azimuth_angle = math.degrees(float(sun.attrib.get('azimuth', 0)))
        carla_weather.sun_altitude_angle = math.degrees(float(sun.attrib.get('elevation', 0)))
        carla_weather.cloudiness = 100 - float(sun.attrib.get('intensity', 0)) * 100
        fog = weather.find("Fog")
        carla_weather.fog_distance = float(fog.attrib.get('visualRange', 'inf'))
        if carla_weather.fog_distance < 1000:
            carla_weather.fog_density = 100
        carla_weather.precipitation = 0
        carla_weather.precipitation_deposits = 0
        carla_weather.wetness = 0
        carla_weather.wind_intensity = 0
        precepitation = weather.find("Precipitation")
        if precepitation.attrib.get('precipitationType') == "rain":
            carla_weather.precipitation = float(precepitation.attrib.get('intensity')) * 100
            carla_weather.precipitation_deposits = 100  # if it rains, make the road wet
            carla_weather.wetness = carla_weather.precipitation
        elif precepitation.attrib.get('type') == "snow":
            raise AttributeError("CARLA does not support snow precipitation")

        time_of_day = environment.find("TimeOfDay")
        weather_animation = strtobool(time_of_day.attrib.get("animation"))
        time = time_of_day.attrib.get("dateTime")
        dtime = datetime.datetime.strptime(time, "%Y-%m-%dT%H:%M:%S")

        return Weather(carla_weather, dtime, weather_animation) 
開發者ID:carla-simulator,項目名稱:scenario_runner,代碼行數:52,代碼來源:openscenario_parser.py


注:本文中的carla.WeatherParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。