added spectator as ego parameter to API docs
This commit is contained in:
parent
7df2fd8a96
commit
5c445df124
|
@ -310,7 +310,7 @@ An attachment like the previous one but that does not make the collision test, a
|
|||
|
||||
## carla.BlueprintLibrary<a name="carla.BlueprintLibrary"></a>
|
||||
A class that contains the blueprints provided for actor spawning. Its main application is to return [carla.ActorBlueprint](#carla.ActorBlueprint) objects needed to spawn actors. Each blueprint has an identifier and attributes that may or may not be modifiable. The library is automatically created by the server and can be accessed through [carla.World](#carla.World).
|
||||
|
||||
|
||||
[Here](bp_library.md) is a reference containing every available blueprint and its specifics.
|
||||
|
||||
### Methods
|
||||
|
@ -319,6 +319,12 @@ Filters a list of blueprints matching the `wildcard_pattern` against the id and
|
|||
- **Parameters:**
|
||||
- `wildcard_pattern` (_str_)
|
||||
- **Return:** _[carla.BlueprintLibrary](#carla.BlueprintLibrary)_
|
||||
- <a name="carla.BlueprintLibrary.filter_by_attribute"></a>**<font color="#7fb800">filter_by_attribute</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**name**</font>, <font color="#00a6ed">**value**</font>)
|
||||
Filters a list of blueprints with a given attribute matching the `value` against every blueprint contained in this library and returns the result as a new one. Matching follows [fnmatch](https://docs.python.org/2/library/fnmatch.html) standard.
|
||||
- **Parameters:**
|
||||
- `name` (_str_)
|
||||
- `value` (_str_)
|
||||
- **Return:** _[carla.BlueprintLibrary](#carla.BlueprintLibrary)_
|
||||
- <a name="carla.BlueprintLibrary.find"></a>**<font color="#7fb800">find</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**id**</font>)
|
||||
Returns the blueprint corresponding to that identifier.
|
||||
- **Parameters:**
|
||||
|
@ -3625,14 +3631,21 @@ Defines wether to use deterministic physics for pedestrian death animations or p
|
|||
Used for large maps only. Configures the maximum distance from the hero vehicle to stream tiled maps. Regions of the map within this range will be visible (and capable of simulating physics). Regions outside this region will not be loaded.
|
||||
- <a name="carla.WorldSettings.actor_active_distance"></a>**<font color="#f8805a">actor_active_distance</font>** (_float_)
|
||||
Used for large maps only. Configures the distance from the hero vehicle to convert actors to dormant. Actors within this range will be active, and actors outside will become dormant.
|
||||
- <a name="carla.WorldSettings.spectator_as_ego"></a>**<font color="#f8805a">spectator_as_ego</font>** (_bool_)
|
||||
Used for large maps only. Defines the influence of the spectator on tile loading in Large Maps. By default, the spectator will provoke loading of neighboring tiles in the absence of an ego actor. This might be inconvenient for applications that immediately spawn an ego actor.
|
||||
|
||||
### Methods
|
||||
- <a name="carla.WorldSettings.__init__"></a>**<font color="#7fb800">\__init__</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**synchronous_mode**=False</font>, <font color="#00a6ed">**no_rendering_mode**=False</font>, <font color="#00a6ed">**fixed_delta_seconds**=0.0</font>)
|
||||
- <a name="carla.WorldSettings.__init__"></a>**<font color="#7fb800">\__init__</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**synchronous_mode**=False</font>, <font color="#00a6ed">**no_rendering_mode**=False</font>, <font color="#00a6ed">**fixed_delta_seconds**=0.0</font>, <font color="#00a6ed">**max_culling_distance**=0.0</font>, <font color="#00a6ed">**deterministic_ragdolls**=False</font>, <font color="#00a6ed">**tile_stream_distance**=3000</font>, <font color="#00a6ed">**actor_active_distance**=2000</font>, <font color="#00a6ed">**spectator_as_ego**=True</font>)
|
||||
Creates an object containing desired settings that could later be applied through [carla.World](#carla.World) and its method __<font color="#7fb800">apply_settings()</font>__.
|
||||
- **Parameters:**
|
||||
- `synchronous_mode` (_bool_) - Set this to true to enable client-server synchrony.
|
||||
- `no_rendering_mode` (_bool_) - Set this to true to completely disable rendering in the simulation.
|
||||
- `fixed_delta_seconds` (_float<small> - seconds</small>_) - Set a fixed time-step in between frames. <code>0.0</code> means variable time-step and it is the default mode.
|
||||
- `max_culling_distance` (_float<small> - meters</small>_) - Configure the max draw distance for each mesh of the level.
|
||||
- `deterministic_ragdolls` (_bool_) - Defines wether to use deterministic physics or ragdoll simulation for pedestrian deaths.
|
||||
- `tile_stream_distance` (_float<small> - meters</small>_) - Used for large maps only. Configures the maximum distance from the hero vehicle to stream tiled maps.
|
||||
- `actor_active_distance` (_float<small> - meters</small>_) - Used for large maps only. Configures the distance from the hero vehicle to convert actors to dormant.
|
||||
- `spectator_as_ego` (_bool_) - Used for large maps only. Defines the influence of the spectator on tile loading in Large Maps.
|
||||
|
||||
##### Dunder methods
|
||||
- <a name="carla.WorldSettings.__eq__"></a>**<font color="#7fb800">\__eq__</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**other**=[carla.WorldSettings](#carla.WorldSettings)</font>)
|
||||
|
@ -4043,6 +4056,384 @@ document.getElementById("snipets-container").innerHTML = null;
|
|||
}
|
||||
</script>
|
||||
|
||||
<div id ="carla.World.enable_environment_objects-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.enable_environment_objects
|
||||
</p>
|
||||
<div id="carla.World.enable_environment_objects-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# This recipe turn visibility off and on for two specifc buildings on the map
|
||||
|
||||
# Get the buildings in the world
|
||||
world = client.get_world()
|
||||
env_objs = world.get_environment_objects(carla.CityObjectLabel.Buildings)
|
||||
|
||||
# Access individual building IDs and save in a set
|
||||
building_01 = env_objs[0]
|
||||
building_02 = env_objs[1]
|
||||
objects_to_toggle = {building_01.id, building_02.id}
|
||||
|
||||
# Toggle buildings off
|
||||
world.enable_environment_objects(objects_to_toggle, False)
|
||||
# Toggle buildings on
|
||||
world.enable_environment_objects(objects_to_toggle, True)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.enable_environment_objects-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.DebugHelper.draw_string-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.DebugHelper.draw_string
|
||||
</p>
|
||||
<div id="carla.DebugHelper.draw_string-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe is a modification of lane_explorer.py example.
|
||||
# It draws the path of an actor through the world, printing information at each waypoint.
|
||||
|
||||
# ...
|
||||
current_w = map.get_waypoint(vehicle.get_location())
|
||||
while True:
|
||||
|
||||
next_w = map.get_waypoint(vehicle.get_location(), lane_type=carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk )
|
||||
# Check if the vehicle is moving
|
||||
if next_w.id != current_w.id:
|
||||
vector = vehicle.get_velocity()
|
||||
# Check if the vehicle is on a sidewalk
|
||||
if current_w.lane_type == carla.LaneType.Sidewalk:
|
||||
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else red, 60)
|
||||
else:
|
||||
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else green, 60)
|
||||
debug.draw_string(current_w.transform.location, str('%15.0f km/h' % (3.6 * math.sqrt(vector.x**2 + vector.y**2 + vector.z**2))), False, orange, 60)
|
||||
draw_transform(debug, current_w.transform, white, 60)
|
||||
|
||||
# Update the current waypoint and sleep for some time
|
||||
current_w = next_w
|
||||
time.sleep(args.tick_time)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_string-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.unload_map_layer-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.unload_map_layer
|
||||
</p>
|
||||
<div id="carla.World.unload_map_layer-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# This recipe toggles off several layers in our "_Opt" maps
|
||||
|
||||
# Load town one with minimum layout (roads, sidewalks, traffic lights and traffic signs)
|
||||
# as well as buildings and parked vehicles
|
||||
world = client.load_world('Town01_Opt', carla.MapLayer.Buildings | carla.MapLayer.ParkedVehicles)
|
||||
|
||||
# Toggle all buildings off
|
||||
world.unload_map_layer(carla.MapLayer.Buildings)
|
||||
|
||||
# Toggle all parked vehicles off
|
||||
world.unload_map_layer(carla.MapLayer.ParkedVehicles)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.unload_map_layer-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Vehicle.set_wheel_steer_direction-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Vehicle.set_wheel_steer_direction
|
||||
</p>
|
||||
<div id="carla.Vehicle.set_wheel_steer_direction-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# Sets the appearance of the vehicles front wheels to 40°. Vehicle physics will not be affected.
|
||||
|
||||
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FR_Wheel, 40.0)
|
||||
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FL_Wheel, 40.0)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Vehicle.set_wheel_steer_direction-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Client.__init__-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Client.__init__
|
||||
</p>
|
||||
<div id="carla.Client.__init__-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows in every script provided in PythonAPI/Examples
|
||||
# and it is used to parse the client creation arguments when running the script.
|
||||
|
||||
argparser = argparse.ArgumentParser(
|
||||
description=__doc__)
|
||||
argparser.add_argument(
|
||||
'--host',
|
||||
metavar='H',
|
||||
default='127.0.0.1',
|
||||
help='IP of the host server (default: 127.0.0.1)')
|
||||
argparser.add_argument(
|
||||
'-p', '--port',
|
||||
metavar='P',
|
||||
default=2000,
|
||||
type=int,
|
||||
help='TCP port to listen to (default: 2000)')
|
||||
argparser.add_argument(
|
||||
'-s', '--speed',
|
||||
metavar='FACTOR',
|
||||
default=1.0,
|
||||
type=float,
|
||||
help='rate at which the weather changes (default: 1.0)')
|
||||
args = argparser.parse_args()
|
||||
|
||||
speed_factor = args.speed
|
||||
update_freq = 0.1 / speed_factor
|
||||
|
||||
client = carla.Client(args.host, args.port)
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Client.__init__-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Map.get_waypoint-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Map.get_waypoint
|
||||
</p>
|
||||
<div id="carla.Map.get_waypoint-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows the current traffic rules affecting the vehicle.
|
||||
# Shows the current lane type and if a lane change can be done in the actual lane or the surrounding ones.
|
||||
|
||||
# ...
|
||||
waypoint = world.get_map().get_waypoint(vehicle.get_location(),project_to_road=True, lane_type=(carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk))
|
||||
print("Current lane type: " + str(waypoint.lane_type))
|
||||
# Check current lane change allowed
|
||||
print("Current Lane change: " + str(waypoint.lane_change))
|
||||
# Left and Right lane markings
|
||||
print("L lane marking type: " + str(waypoint.left_lane_marking.type))
|
||||
print("L lane marking change: " + str(waypoint.left_lane_marking.lane_change))
|
||||
print("R lane marking type: " + str(waypoint.right_lane_marking.type))
|
||||
print("R lane marking change: " + str(waypoint.right_lane_marking.lane_change))
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Map.get_waypoint-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.Map.get_waypoint.jpg">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.spawn_actor-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.spawn_actor
|
||||
</p>
|
||||
<div id="carla.World.spawn_actor-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe attaches different camera / sensors to a vehicle with different attachments.
|
||||
|
||||
# ...
|
||||
camera = world.spawn_actor(rgb_camera_bp, transform, attach_to=vehicle, attachment_type=Attachment.Rigid)
|
||||
# Default attachment: Attachment.Rigid
|
||||
gnss_sensor = world.spawn_actor(sensor_gnss_bp, transform, attach_to=vehicle)
|
||||
collision_sensor = world.spawn_actor(sensor_collision_bp, transform, attach_to=vehicle)
|
||||
lane_invasion_sensor = world.spawn_actor(sensor_lane_invasion_bp, transform, attach_to=vehicle)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.spawn_actor-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.WalkerAIController.stop-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.WalkerAIController.stop
|
||||
</p>
|
||||
<div id="carla.WalkerAIController.stop-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
#To destroy the pedestrians, stop them from the navigation, and then destroy the objects (actor and controller).
|
||||
|
||||
# stop pedestrians (list is [controller, actor, controller, actor ...])
|
||||
for i in range(0, len(all_id), 2):
|
||||
all_actors[i].stop()
|
||||
|
||||
# destroy pedestrian (actor and controller)
|
||||
client.apply_batch([carla.command.DestroyActor(x) for x in all_id])
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.WalkerAIController.stop-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.DebugHelper.draw_box-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.DebugHelper.draw_box
|
||||
</p>
|
||||
<div id="carla.DebugHelper.draw_box-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows how to draw traffic light actor bounding boxes from a world snapshot.
|
||||
|
||||
# ....
|
||||
debug = world.debug
|
||||
world_snapshot = world.get_snapshot()
|
||||
|
||||
for actor_snapshot in world_snapshot:
|
||||
actual_actor = world.get_actor(actor_snapshot.id)
|
||||
if actual_actor.type_id == 'traffic.traffic_light':
|
||||
debug.draw_box(carla.BoundingBox(actor_snapshot.get_transform().location,carla.Vector3D(0.5,0.5,2)),actor_snapshot.get_transform().rotation, 0.05, carla.Color(255,0,0,0),0)
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_box-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.DebugHelper.draw_box.jpg">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.get_spectator-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.get_spectator
|
||||
</p>
|
||||
<div id="carla.World.get_spectator-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe spawns an actor and the spectator camera at the actor's location.
|
||||
|
||||
# ...
|
||||
world = client.get_world()
|
||||
spectator = world.get_spectator()
|
||||
|
||||
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
|
||||
transform = random.choice(world.get_map().get_spawn_points())
|
||||
vehicle = world.try_spawn_actor(vehicle_bp, transform)
|
||||
|
||||
# Wait for world to get the vehicle actor
|
||||
world.tick()
|
||||
|
||||
world_snapshot = world.wait_for_tick()
|
||||
actor_snapshot = world_snapshot.find(vehicle.id)
|
||||
|
||||
# Set spectator at given transform (vehicle transform)
|
||||
spectator.set_transform(actor_snapshot.get_transform())
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.get_spectator-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Sensor.listen-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Sensor.listen
|
||||
</p>
|
||||
<div id="carla.Sensor.listen-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe applies a color conversion to the image taken by a camera sensor,
|
||||
# so it is converted to a semantic segmentation image.
|
||||
|
||||
# ...
|
||||
camera_bp = world.get_blueprint_library().filter('sensor.camera.semantic_segmentation')
|
||||
# ...
|
||||
cc = carla.ColorConverter.CityScapesPalette
|
||||
camera.listen(lambda image: image.save_to_disk('output/%06d.png' % image.frame, cc))
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Sensor.listen-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.TrafficLight.set_state-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.TrafficLight.set_state
|
||||
</p>
|
||||
<div id="carla.TrafficLight.set_state-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe changes from red to green the traffic light that affects the vehicle.
|
||||
# This is done by detecting if the vehicle actor is at a traffic light.
|
||||
|
||||
# ...
|
||||
world = client.get_world()
|
||||
spectator = world.get_spectator()
|
||||
|
||||
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
|
||||
transform = random.choice(world.get_map().get_spawn_points())
|
||||
vehicle = world.try_spawn_actor(vehicle_bp, transform)
|
||||
|
||||
# Wait for world to get the vehicle actor
|
||||
world.tick()
|
||||
|
||||
world_snapshot = world.wait_for_tick()
|
||||
actor_snapshot = world_snapshot.find(vehicle.id)
|
||||
|
||||
# Set spectator at given transform (vehicle transform)
|
||||
spectator.set_transform(actor_snapshot.get_transform())
|
||||
# ...# ...
|
||||
if vehicle_actor.is_at_traffic_light():
|
||||
traffic_light = vehicle_actor.get_traffic_light()
|
||||
if traffic_light.get_state() == carla.TrafficLightState.Red:
|
||||
# world.hud.notification("Traffic light changed! Good to go!")
|
||||
traffic_light.set_state(carla.TrafficLightState.Green)
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.TrafficLight.set_state-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.TrafficLight.set_state.gif">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.ActorBlueprint.set_attribute-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.ActorBlueprint.set_attribute
|
||||
|
@ -4150,333 +4541,6 @@ for i in range(0, len(all_actors), 2):
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Client.__init__-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Client.__init__
|
||||
</p>
|
||||
<div id="carla.Client.__init__-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows in every script provided in PythonAPI/Examples
|
||||
# and it is used to parse the client creation arguments when running the script.
|
||||
|
||||
argparser = argparse.ArgumentParser(
|
||||
description=__doc__)
|
||||
argparser.add_argument(
|
||||
'--host',
|
||||
metavar='H',
|
||||
default='127.0.0.1',
|
||||
help='IP of the host server (default: 127.0.0.1)')
|
||||
argparser.add_argument(
|
||||
'-p', '--port',
|
||||
metavar='P',
|
||||
default=2000,
|
||||
type=int,
|
||||
help='TCP port to listen to (default: 2000)')
|
||||
argparser.add_argument(
|
||||
'-s', '--speed',
|
||||
metavar='FACTOR',
|
||||
default=1.0,
|
||||
type=float,
|
||||
help='rate at which the weather changes (default: 1.0)')
|
||||
args = argparser.parse_args()
|
||||
|
||||
speed_factor = args.speed
|
||||
update_freq = 0.1 / speed_factor
|
||||
|
||||
client = carla.Client(args.host, args.port)
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Client.__init__-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.DebugHelper.draw_box-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.DebugHelper.draw_box
|
||||
</p>
|
||||
<div id="carla.DebugHelper.draw_box-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows how to draw traffic light actor bounding boxes from a world snapshot.
|
||||
|
||||
# ....
|
||||
debug = world.debug
|
||||
world_snapshot = world.get_snapshot()
|
||||
|
||||
for actor_snapshot in world_snapshot:
|
||||
actual_actor = world.get_actor(actor_snapshot.id)
|
||||
if actual_actor.type_id == 'traffic.traffic_light':
|
||||
debug.draw_box(carla.BoundingBox(actor_snapshot.get_transform().location,carla.Vector3D(0.5,0.5,2)),actor_snapshot.get_transform().rotation, 0.05, carla.Color(255,0,0,0),0)
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_box-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.DebugHelper.draw_box.jpg">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.DebugHelper.draw_string-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.DebugHelper.draw_string
|
||||
</p>
|
||||
<div id="carla.DebugHelper.draw_string-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe is a modification of lane_explorer.py example.
|
||||
# It draws the path of an actor through the world, printing information at each waypoint.
|
||||
|
||||
# ...
|
||||
current_w = map.get_waypoint(vehicle.get_location())
|
||||
while True:
|
||||
|
||||
next_w = map.get_waypoint(vehicle.get_location(), lane_type=carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk )
|
||||
# Check if the vehicle is moving
|
||||
if next_w.id != current_w.id:
|
||||
vector = vehicle.get_velocity()
|
||||
# Check if the vehicle is on a sidewalk
|
||||
if current_w.lane_type == carla.LaneType.Sidewalk:
|
||||
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else red, 60)
|
||||
else:
|
||||
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else green, 60)
|
||||
debug.draw_string(current_w.transform.location, str('%15.0f km/h' % (3.6 * math.sqrt(vector.x**2 + vector.y**2 + vector.z**2))), False, orange, 60)
|
||||
draw_transform(debug, current_w.transform, white, 60)
|
||||
|
||||
# Update the current waypoint and sleep for some time
|
||||
current_w = next_w
|
||||
time.sleep(args.tick_time)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_string-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Map.get_waypoint-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Map.get_waypoint
|
||||
</p>
|
||||
<div id="carla.Map.get_waypoint-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe shows the current traffic rules affecting the vehicle.
|
||||
# Shows the current lane type and if a lane change can be done in the actual lane or the surrounding ones.
|
||||
|
||||
# ...
|
||||
waypoint = world.get_map().get_waypoint(vehicle.get_location(),project_to_road=True, lane_type=(carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk))
|
||||
print("Current lane type: " + str(waypoint.lane_type))
|
||||
# Check current lane change allowed
|
||||
print("Current Lane change: " + str(waypoint.lane_change))
|
||||
# Left and Right lane markings
|
||||
print("L lane marking type: " + str(waypoint.left_lane_marking.type))
|
||||
print("L lane marking change: " + str(waypoint.left_lane_marking.lane_change))
|
||||
print("R lane marking type: " + str(waypoint.right_lane_marking.type))
|
||||
print("R lane marking change: " + str(waypoint.right_lane_marking.lane_change))
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Map.get_waypoint-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.Map.get_waypoint.jpg">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Sensor.listen-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Sensor.listen
|
||||
</p>
|
||||
<div id="carla.Sensor.listen-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe applies a color conversion to the image taken by a camera sensor,
|
||||
# so it is converted to a semantic segmentation image.
|
||||
|
||||
# ...
|
||||
camera_bp = world.get_blueprint_library().filter('sensor.camera.semantic_segmentation')
|
||||
# ...
|
||||
cc = carla.ColorConverter.CityScapesPalette
|
||||
camera.listen(lambda image: image.save_to_disk('output/%06d.png' % image.frame, cc))
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Sensor.listen-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.TrafficLight.set_state-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.TrafficLight.set_state
|
||||
</p>
|
||||
<div id="carla.TrafficLight.set_state-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe changes from red to green the traffic light that affects the vehicle.
|
||||
# This is done by detecting if the vehicle actor is at a traffic light.
|
||||
|
||||
# ...
|
||||
world = client.get_world()
|
||||
spectator = world.get_spectator()
|
||||
|
||||
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
|
||||
transform = random.choice(world.get_map().get_spawn_points())
|
||||
vehicle = world.try_spawn_actor(vehicle_bp, transform)
|
||||
|
||||
# Wait for world to get the vehicle actor
|
||||
world.tick()
|
||||
|
||||
world_snapshot = world.wait_for_tick()
|
||||
actor_snapshot = world_snapshot.find(vehicle.id)
|
||||
|
||||
# Set spectator at given transform (vehicle transform)
|
||||
spectator.set_transform(actor_snapshot.get_transform())
|
||||
# ...# ...
|
||||
if vehicle_actor.is_at_traffic_light():
|
||||
traffic_light = vehicle_actor.get_traffic_light()
|
||||
if traffic_light.get_state() == carla.TrafficLightState.Red:
|
||||
# world.hud.notification("Traffic light changed! Good to go!")
|
||||
traffic_light.set_state(carla.TrafficLightState.Green)
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.TrafficLight.set_state-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
|
||||
<img src="/img/snipets_images/carla.TrafficLight.set_state.gif">
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Vehicle.set_wheel_steer_direction-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Vehicle.set_wheel_steer_direction
|
||||
</p>
|
||||
<div id="carla.Vehicle.set_wheel_steer_direction-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# Sets the appearance of the vehicles front wheels to 40°. Vehicle physics will not be affected.
|
||||
|
||||
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FR_Wheel, 40.0)
|
||||
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FL_Wheel, 40.0)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Vehicle.set_wheel_steer_direction-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.WalkerAIController.stop-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.WalkerAIController.stop
|
||||
</p>
|
||||
<div id="carla.WalkerAIController.stop-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
#To destroy the pedestrians, stop them from the navigation, and then destroy the objects (actor and controller).
|
||||
|
||||
# stop pedestrians (list is [controller, actor, controller, actor ...])
|
||||
for i in range(0, len(all_id), 2):
|
||||
all_actors[i].stop()
|
||||
|
||||
# destroy pedestrian (actor and controller)
|
||||
client.apply_batch([carla.command.DestroyActor(x) for x in all_id])
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.WalkerAIController.stop-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.enable_environment_objects-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.enable_environment_objects
|
||||
</p>
|
||||
<div id="carla.World.enable_environment_objects-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# This recipe turn visibility off and on for two specifc buildings on the map
|
||||
|
||||
# Get the buildings in the world
|
||||
world = client.get_world()
|
||||
env_objs = world.get_environment_objects(carla.CityObjectLabel.Buildings)
|
||||
|
||||
# Access individual building IDs and save in a set
|
||||
building_01 = env_objs[0]
|
||||
building_02 = env_objs[1]
|
||||
objects_to_toggle = {building_01.id, building_02.id}
|
||||
|
||||
# Toggle buildings off
|
||||
world.enable_environment_objects(objects_to_toggle, False)
|
||||
# Toggle buildings on
|
||||
world.enable_environment_objects(objects_to_toggle, True)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.enable_environment_objects-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.get_spectator-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.get_spectator
|
||||
</p>
|
||||
<div id="carla.World.get_spectator-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe spawns an actor and the spectator camera at the actor's location.
|
||||
|
||||
# ...
|
||||
world = client.get_world()
|
||||
spectator = world.get_spectator()
|
||||
|
||||
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
|
||||
transform = random.choice(world.get_map().get_spawn_points())
|
||||
vehicle = world.try_spawn_actor(vehicle_bp, transform)
|
||||
|
||||
# Wait for world to get the vehicle actor
|
||||
world.tick()
|
||||
|
||||
world_snapshot = world.wait_for_tick()
|
||||
actor_snapshot = world_snapshot.find(vehicle.id)
|
||||
|
||||
# Set spectator at given transform (vehicle transform)
|
||||
spectator.set_transform(actor_snapshot.get_transform())
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.get_spectator-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.load_map_layer-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.load_map_layer
|
||||
|
@ -4505,57 +4569,6 @@ world.load_map_layer(carla.MapLayer.ParkedVehicles)
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.spawn_actor-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.spawn_actor
|
||||
</p>
|
||||
<div id="carla.World.spawn_actor-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe attaches different camera / sensors to a vehicle with different attachments.
|
||||
|
||||
# ...
|
||||
camera = world.spawn_actor(rgb_camera_bp, transform, attach_to=vehicle, attachment_type=Attachment.Rigid)
|
||||
# Default attachment: Attachment.Rigid
|
||||
gnss_sensor = world.spawn_actor(sensor_gnss_bp, transform, attach_to=vehicle)
|
||||
collision_sensor = world.spawn_actor(sensor_collision_bp, transform, attach_to=vehicle)
|
||||
lane_invasion_sensor = world.spawn_actor(sensor_lane_invasion_bp, transform, attach_to=vehicle)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.spawn_actor-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.unload_map_layer-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.unload_map_layer
|
||||
</p>
|
||||
<div id="carla.World.unload_map_layer-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# This recipe toggles off several layers in our "_Opt" maps
|
||||
|
||||
# Load town one with minimum layout (roads, sidewalks, traffic lights and traffic signs)
|
||||
# as well as buildings and parked vehicles
|
||||
world = client.load_world('Town01_Opt', carla.MapLayer.Buildings | carla.MapLayer.ParkedVehicles)
|
||||
|
||||
# Toggle all buildings off
|
||||
world.unload_map_layer(carla.MapLayer.Buildings)
|
||||
|
||||
# Toggle all parked vehicles off
|
||||
world.unload_map_layer(carla.MapLayer.ParkedVehicles)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.unload_map_layer-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -152,6 +152,11 @@
|
|||
type: float
|
||||
doc: >
|
||||
Used for large maps only. Configures the distance from the hero vehicle to convert actors to dormant. Actors within this range will be active, and actors outside will become dormant.
|
||||
- var_name: spectator_as_ego
|
||||
type: bool
|
||||
doc: >
|
||||
Used for large maps only. Defines the influence of the spectator on tile loading in Large Maps. By default, the spectator will provoke loading of neighboring tiles in the absence of an ego actor. This might be inconvenient for applications that immediately spawn an ego actor.
|
||||
|
||||
# - METHODS ----------------------------
|
||||
methods:
|
||||
- def_name: __init__
|
||||
|
@ -172,6 +177,35 @@
|
|||
param_units: seconds
|
||||
doc: >
|
||||
Set a fixed time-step in between frames. <code>0.0</code> means variable time-step and it is the default mode.
|
||||
- param_name: max_culling_distance
|
||||
type: float
|
||||
default: 0.0
|
||||
param_units: meters
|
||||
doc: >
|
||||
Configure the max draw distance for each mesh of the level.
|
||||
- param_name: deterministic_ragdolls
|
||||
type: bool
|
||||
default: False
|
||||
doc: >
|
||||
Defines wether to use deterministic physics or ragdoll simulation for pedestrian deaths.
|
||||
- param_name: tile_stream_distance
|
||||
type: float
|
||||
default: 3000
|
||||
param_units: meters
|
||||
doc: >
|
||||
Used for large maps only. Configures the maximum distance from the hero vehicle to stream tiled maps.
|
||||
- param_name: actor_active_distance
|
||||
type: float
|
||||
default: 2000
|
||||
param_units: meters
|
||||
doc: >
|
||||
Used for large maps only. Configures the distance from the hero vehicle to convert actors to dormant.
|
||||
- param_name: spectator_as_ego
|
||||
type: bool
|
||||
default: True
|
||||
doc: >
|
||||
Used for large maps only. Defines the influence of the spectator on tile loading in Large Maps.
|
||||
|
||||
doc: >
|
||||
Creates an object containing desired settings that could later be applied through carla.World and its method __<font color="#7fb800">apply_settings()</font>__.
|
||||
# --------------------------------------
|
||||
|
|
Loading…
Reference in New Issue