added extra traffic manager functions
This commit is contained in:
parent
e753be908b
commit
a4f5c26efa
|
@ -2375,6 +2375,11 @@ Forces a vehicle to change either to the lane on its left or right, if existing,
|
|||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle being forced to change lanes.
|
||||
- `direction` (_bool_) - Destination lane. __True__ is the one on the right and __False__ is the left one.
|
||||
- <a name="carla.TrafficManager.global_lane_offset"></a>**<font color="#7fb800">global_lane_offset</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**offset**</font>)
|
||||
Sets a global lane offset displacement from the center line. Positive values imply a right offset while negative ones mean a left one.
|
||||
Default is 0. Numbers high enough to cause the vehicle to drive through other lanes might break the controller.
|
||||
- **Parameters:**
|
||||
- `offset` (_float_) - Lane offset displacement from the center line.
|
||||
- <a name="carla.TrafficManager.global_percentage_speed_difference"></a>**<font color="#7fb800">global_percentage_speed_difference</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**percentage**</font>)
|
||||
Sets the difference the vehicle's intended speed and its current speed limit. Speed limits can be exceeded by setting the `perc` to a negative value.
|
||||
Default is 30. Exceeding a speed limit can be done using negative percentages.
|
||||
|
@ -2405,12 +2410,28 @@ During the localization stage, this method sets a percent chance that vehicle wi
|
|||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose behaviour is being changed.
|
||||
- `perc` (_float_) - Between 0 and 100. Amount of times the vehicle will follow the keep right rule.
|
||||
- <a name="carla.TrafficManager.random_left_lanechange_percentage"></a>**<font color="#7fb800">random_left_lanechange_percentage</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**percentage**</font>)
|
||||
Adjust probability that in each timestep the actor will perform a left lane change, dependent on lane change availability.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - The actor that you wish to query.
|
||||
- `percentage` (_float_) - The probability of lane change in percentage units (between 0 and 100).
|
||||
- <a name="carla.TrafficManager.random_right_lanechange_percentage"></a>**<font color="#7fb800">random_right_lanechange_percentage</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**percentage**</font>)
|
||||
Adjust probability that in each timestep the actor will perform a right lane change, dependent on lane change availability.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - The actor that you wish to query.
|
||||
- `percentage` (_float_) - The probability of lane change in percentage units (between 0 and 100).
|
||||
- <a name="carla.TrafficManager.update_vehicle_lights"></a>**<font color="#7fb800">update_vehicle_lights</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**do_update**</font>)
|
||||
Sets if the Traffic Manager is responsible of updating the vehicle lights, or not.
|
||||
Default is __False__. The traffic manager will not change the vehicle light status of a vehicle, unless its auto_update_status is st to __True__.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose lights status is being changed.
|
||||
- `do_update` (_bool_) - If __True__ the traffic manager will manage the vehicle lights for the specified vehicle.
|
||||
- <a name="carla.TrafficManager.vehicle_lane_offset"></a>**<font color="#7fb800">vehicle_lane_offset</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**offset**</font>)
|
||||
Sets a lane offset displacement from the center line. Positive values imply a right offset while negative ones mean a left one.
|
||||
Default is 0. Numbers high enough to cause the vehicle to drive through other lanes might break the controller.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose lane offset behaviour is being changed.
|
||||
- `offset` (_float_) - Lane offset displacement from the center line.
|
||||
- <a name="carla.TrafficManager.vehicle_percentage_speed_difference"></a>**<font color="#7fb800">vehicle_percentage_speed_difference</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**percentage**</font>)
|
||||
Sets the difference the vehicle's intended speed and its current speed limit. Speed limits can be exceeded by setting the `perc` to a negative value.
|
||||
Default is 30. Exceeding a speed limit can be done using negative percentages.
|
||||
|
@ -2419,6 +2440,16 @@ Default is 30. Exceeding a speed limit can be done using negative percentages.
|
|||
- `percentage` (_float_) - Percentage difference between intended speed and the current limit.
|
||||
|
||||
##### Getters
|
||||
- <a name="carla.TrafficManager.get_all_actions"></a>**<font color="#7fb800">get_all_actions</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>)
|
||||
Returns all known actions (i.e. road options and waypoints) that an actor controlled by the Traffic Manager will perform in its next steps.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - The actor that you wish to query.
|
||||
- **Return:** _list of lists with each element as follows - [Road option (string e.g. 'Left', 'Right', 'Straight'), Next waypoint ([carla.Waypoint](#carla.Waypoint))]_
|
||||
- <a name="carla.TrafficManager.get_next_action"></a>**<font color="#7fb800">get_next_action</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>)
|
||||
Returns the next known road option and waypoint that an actor controlled by the Traffic Manager will follow.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - The actor that you wish to query.
|
||||
- **Return:** _list of two elements - [Road option (string e.g. 'Left', 'Right', 'Straight'), Next waypoint ([carla.Waypoint](#carla.Waypoint))]_
|
||||
- <a name="carla.TrafficManager.get_port"></a>**<font color="#7fb800">get_port</font>**(<font color="#00a6ed">**self**</font>)
|
||||
Returns the port where the Traffic Manager is connected. If the object is a TM-Client, it will return the port of its TM-Server. Read the [documentation](#adv_traffic_manager.md#multiclient-and-multitm-management) to learn the difference.
|
||||
- **Return:** _uint16_
|
||||
|
@ -2452,6 +2483,13 @@ With hybrid physics on, changes the radius of the area of influence where physic
|
|||
Enables or disables the OSM mode. This mode allows the user to run TM in a map created with the [OSM feature](tuto_G_openstreetmap.md). These maps allow having dead-end streets. Normally, if vehicles cannot find the next waypoint, TM crashes. If OSM mode is enabled, it will show a warning, and destroy vehicles when necessary.
|
||||
- **Parameters:**
|
||||
- `mode_switch` (_bool_) - If __True__, the OSM mode is enabled.
|
||||
- <a name="carla.TrafficManager.set_path"></a>**<font color="#7fb800">set_path</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**path**</font>)
|
||||
Sets a list of locations for a vehicle to follow while controlled by the Traffic Manager.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - The actor that must follow the given path.
|
||||
- `path` (_list_) - The list of [carla.Locations](#carla.Locations) for the actor to follow.
|
||||
- **Warning:** <font color="#ED2F2F">_Ensure that the road topology doesn't impede the given path.
|
||||
_</font>
|
||||
- <a name="carla.TrafficManager.set_random_device_seed"></a>**<font color="#7fb800">set_random_device_seed</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**value**</font>)
|
||||
Sets a specific random seed for the Traffic Manager, thereby setting it to be deterministic.
|
||||
- **Parameters:**
|
||||
|
@ -2460,6 +2498,13 @@ Sets a specific random seed for the Traffic Manager, thereby setting it to be de
|
|||
If __True__, vehicles in large maps will respawn near the hero vehicle when they become dormant. Otherwise, they will stay dormant until they are within `actor_active_distance` of the hero vehicle again.
|
||||
- **Parameters:**
|
||||
- `mode_switch` (_bool_)
|
||||
- <a name="carla.TrafficManager.set_route"></a>**<font color="#7fb800">set_route</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**actor**</font>, <font color="#00a6ed">**path**</font>)
|
||||
Sets a list of route instructions for a vehicle to follow while controlled by the Traffic Manager. The possible route instructions are 'Left', 'Right', 'Straight'.
|
||||
- **Parameters:**
|
||||
- `actor` (_[carla.Actor](#carla.Actor)_) - The actor that must follow the given route instructions.
|
||||
- `path` (_list_) - The list of route instructions (string) for the vehicle to follow.
|
||||
- **Warning:** <font color="#ED2F2F">_Ensure that the lane topology doesn't impede the given route.
|
||||
_</font>
|
||||
- <a name="carla.TrafficManager.set_synchronous_mode"></a>**<font color="#7fb800">set_synchronous_mode</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**mode_switch**=True</font>)
|
||||
Sets the Traffic Manager to [synchronous mode](adv_traffic_manager.md#synchronous-mode). In a [multiclient situation](adv_traffic_manager.md#multiclient), only the TM-Server can tick. Similarly, in a [multiTM situation](adv_traffic_manager.md#multitm), only one TM-Server must tick. Use this method in the client that does the world tick, and right after setting the world to synchronous mode, to set which TM will be the master while in sync.
|
||||
- **Parameters:**
|
||||
|
@ -3932,47 +3977,33 @@ document.getElementById("snipets-container").innerHTML = null;
|
|||
}
|
||||
</script>
|
||||
|
||||
<div id ="carla.Sensor.listen-snipet" style="display: none;">
|
||||
<div id ="carla.World.enable_environment_objects-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Sensor.listen
|
||||
Snippet for carla.World.enable_environment_objects
|
||||
</p>
|
||||
<div id="carla.Sensor.listen-code" class="SnipetContent">
|
||||
<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
|
||||
|
||||
# This recipe applies a color conversion to the image taken by a camera sensor,
|
||||
# so it is converted to a semantic segmentation image.
|
||||
# Get the buildings in the world
|
||||
world = client.get_world()
|
||||
env_objs = world.get_environment_objects(carla.CityObjectLabel.Buildings)
|
||||
|
||||
# ...
|
||||
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))
|
||||
# ...
|
||||
# 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.Sensor.listen-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>
|
||||
<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>
|
||||
|
||||
|
@ -4015,6 +4046,129 @@ while True:
|
|||
|
||||
</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
|
||||
|
@ -4040,33 +4194,118 @@ lane_invasion_sensor = world.spawn_actor(sensor_lane_invasion_bp, transform, att
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.enable_environment_objects-snipet" style="display: none;">
|
||||
<div id ="carla.WalkerAIController.stop-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.enable_environment_objects
|
||||
Snippet for carla.WalkerAIController.stop
|
||||
</p>
|
||||
<div id="carla.World.enable_environment_objects-code" class="SnipetContent">
|
||||
<div id="carla.WalkerAIController.stop-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)
|
||||
#To destroy the pedestrians, stop them from the navigation, and then destroy the objects (actor and controller).
|
||||
|
||||
# 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}
|
||||
# stop pedestrians (list is [controller, actor, controller, actor ...])
|
||||
for i in range(0, len(all_id), 2):
|
||||
all_actors[i].stop()
|
||||
|
||||
# Toggle buildings off
|
||||
world.enable_environment_objects(objects_to_toggle, False)
|
||||
# Toggle buildings on
|
||||
world.enable_environment_objects(objects_to_toggle, True)
|
||||
# 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.World.enable_environment_objects-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
<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>
|
||||
|
||||
|
@ -4116,64 +4355,37 @@ if vehicle_actor.is_at_traffic_light():
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.Map.get_waypoint-snipet" style="display: none;">
|
||||
<div id ="carla.ActorBlueprint.set_attribute-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.Map.get_waypoint
|
||||
Snippet for carla.ActorBlueprint.set_attribute
|
||||
</p>
|
||||
<div id="carla.Map.get_waypoint-code" class="SnipetContent">
|
||||
<div id="carla.ActorBlueprint.set_attribute-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.
|
||||
# This recipe changes attributes of different type of blueprint actors.
|
||||
|
||||
# ...
|
||||
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))
|
||||
walker_bp = world.get_blueprint_library().filter('walker.pedestrian.0002')
|
||||
walker_bp.set_attribute('is_invincible', True)
|
||||
|
||||
# ...
|
||||
# Changes attribute randomly by the recommended value
|
||||
vehicle_bp = wolrd.get_blueprint_library().filter('vehicle.bmw.*')
|
||||
color = random.choice(vehicle_bp.get_attribute('color').recommended_values)
|
||||
vehicle_bp.set_attribute('color', color)
|
||||
|
||||
# ...
|
||||
|
||||
camera_bp = world.get_blueprint_library().filter('sensor.camera.rgb')
|
||||
camera_bp.set_attribute('image_size_x', 600)
|
||||
camera_bp.set_attribute('image_size_y', 600)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<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.load_map_layer-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.load_map_layer
|
||||
</p>
|
||||
<div id="carla.World.load_map_layer-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# This recipe toggles on several layers in our "_Opt" maps
|
||||
|
||||
# Load town one with only minimum layout (roads, sidewalks, traffic lights and traffic signs)
|
||||
world = client.load_world('Town01_Opt', carla.MapLayer.None)
|
||||
|
||||
# Toggle all buildings on
|
||||
world.load_map_layer(carla.MapLayer.Buildings)
|
||||
|
||||
# Toggle all foliage on
|
||||
world.load_map_layer(carla.MapLayer.Foliage)
|
||||
|
||||
# Toggle all parked vehicles on
|
||||
world.load_map_layer(carla.MapLayer.ParkedVehicles)
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.load_map_layer-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.ActorBlueprint.set_attribute-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -4250,198 +4462,31 @@ for i in range(0, len(all_actors), 2):
|
|||
|
||||
</div>
|
||||
|
||||
<div id ="carla.World.unload_map_layer-snipet" style="display: none;">
|
||||
<div id ="carla.World.load_map_layer-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.World.unload_map_layer
|
||||
Snippet for carla.World.load_map_layer
|
||||
</p>
|
||||
<div id="carla.World.unload_map_layer-code" class="SnipetContent">
|
||||
<div id="carla.World.load_map_layer-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
# This recipe toggles off several layers in our "_Opt" maps
|
||||
# This recipe toggles on 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)
|
||||
# Load town one with only minimum layout (roads, sidewalks, traffic lights and traffic signs)
|
||||
world = client.load_world('Town01_Opt', carla.MapLayer.None)
|
||||
|
||||
# Toggle all buildings off
|
||||
world.unload_map_layer(carla.MapLayer.Buildings)
|
||||
# Toggle all buildings on
|
||||
world.load_map_layer(carla.MapLayer.Buildings)
|
||||
|
||||
# Toggle all parked vehicles off
|
||||
world.unload_map_layer(carla.MapLayer.ParkedVehicles)
|
||||
# Toggle all foliage on
|
||||
world.load_map_layer(carla.MapLayer.Foliage)
|
||||
|
||||
# Toggle all parked vehicles on
|
||||
world.load_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.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.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.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.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.ActorBlueprint.set_attribute-snipet" style="display: none;">
|
||||
<p class="SnipetFont">
|
||||
Snippet for carla.ActorBlueprint.set_attribute
|
||||
</p>
|
||||
<div id="carla.ActorBlueprint.set_attribute-code" class="SnipetContent">
|
||||
|
||||
```py
|
||||
|
||||
|
||||
# This recipe changes attributes of different type of blueprint actors.
|
||||
|
||||
# ...
|
||||
walker_bp = world.get_blueprint_library().filter('walker.pedestrian.0002')
|
||||
walker_bp.set_attribute('is_invincible', True)
|
||||
|
||||
# ...
|
||||
# Changes attribute randomly by the recommended value
|
||||
vehicle_bp = wolrd.get_blueprint_library().filter('vehicle.bmw.*')
|
||||
color = random.choice(vehicle_bp.get_attribute('color').recommended_values)
|
||||
vehicle_bp.set_attribute('color', color)
|
||||
|
||||
# ...
|
||||
|
||||
camera_bp = world.get_blueprint_library().filter('sensor.camera.rgb')
|
||||
camera_bp.set_attribute('image_size_x', 600)
|
||||
camera_bp.set_attribute('image_size_y', 600)
|
||||
# ...
|
||||
|
||||
|
||||
```
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.ActorBlueprint.set_attribute-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.load_map_layer-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -641,6 +641,82 @@
|
|||
warning: >
|
||||
The `upper_bound` cannot be higher than the `actor_active_distance`. The `lower_bound` cannot be less than 25.
|
||||
# --------------------------------------
|
||||
- def_name: set_path
|
||||
params:
|
||||
- param_name: actor
|
||||
type: carla.Actor
|
||||
doc: >
|
||||
The actor that must follow the given path
|
||||
- param_name: path
|
||||
type: list
|
||||
doc: >
|
||||
The list of carla.Locations for the actor to follow
|
||||
doc: >
|
||||
Sets a list of locations for a vehicle to follow while controlled by the Traffic Manager.
|
||||
warning: >
|
||||
Ensure that the road topology doesn't impede the given path.
|
||||
# --------------------------------------
|
||||
- def_name: set_route
|
||||
params:
|
||||
- param_name: actor
|
||||
type: carla.Actor
|
||||
doc: >
|
||||
The actor that must follow the given route instructions
|
||||
- param_name: path
|
||||
type: list
|
||||
doc: >
|
||||
The list of route instructions (string) for the vehicle to follow.
|
||||
doc: >
|
||||
Sets a list of route instructions for a vehicle to follow while controlled by the Traffic Manager. The possible route instructions are 'Left', 'Right', 'Straight'.
|
||||
warning: >
|
||||
Ensure that the lane topology doesn't impede the given route.
|
||||
# --------------------------------------
|
||||
- def_name: get_next_action
|
||||
params:
|
||||
- param_name: actor
|
||||
type: carla.Actor
|
||||
doc: >
|
||||
The actor that you wish to query.
|
||||
return: list of two elements - [Road option (string e.g. 'Left', 'Right', 'Straight'), Next waypoint (carla.Waypoint)]
|
||||
doc: >
|
||||
Returns the next known road option and waypoint that an actor controlled by the Traffic Manager will follow.
|
||||
# --------------------------------------
|
||||
- def_name: get_all_actions
|
||||
params:
|
||||
- param_name: actor
|
||||
type: carla.Actor
|
||||
doc: >
|
||||
The actor that you wish to query.
|
||||
return: list of lists with each element as follows - [Road option (string e.g. 'Left', 'Right', 'Straight'), Next waypoint (carla.Waypoint)]
|
||||
doc: >
|
||||
Returns all known actions (i.e. road options and waypoints) that an actor controlled by the Traffic Manager will perform in its next steps.
|
||||
# --------------------------------------
|
||||
- def_name: random_left_lanechange_percentage
|
||||
params:
|
||||
- param_name: actor
|
||||
type: carla.Actor
|
||||
doc: >
|
||||
The actor that you wish to query.
|
||||
- param_name: percentage
|
||||
type: float
|
||||
doc: >
|
||||
The probability of lane change in percentage units (between 0 and 100)
|
||||
doc: >
|
||||
Adjust probability that in each timestep the actor will perform a left lane change, dependent on lane change availability.
|
||||
# --------------------------------------
|
||||
- def_name: random_right_lanechange_percentage
|
||||
params:
|
||||
- param_name: actor
|
||||
type: carla.Actor
|
||||
doc: >
|
||||
The actor that you wish to query.
|
||||
- param_name: percentage
|
||||
type: float
|
||||
doc: >
|
||||
The probability of lane change in percentage units (between 0 and 100)
|
||||
doc: >
|
||||
Adjust probability that in each timestep the actor will perform a right lane change, dependent on lane change availability.
|
||||
# --------------------------------------
|
||||
|
||||
- class_name: OpendriveGenerationParameters
|
||||
# - DESCRIPTION ------------------------
|
||||
|
|
Loading…
Reference in New Issue