当前位置: 首页>>代码示例>>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;未经允许,请勿转载。