2018-07-30 20:28:51 +08:00
|
|
|
<h1>Python API Reference</h1>
|
2018-07-29 01:29:31 +08:00
|
|
|
|
|
|
|
!!! important
|
|
|
|
Versions prior to 0.9.0 have a very different API. For the documentation of
|
|
|
|
the stable version please switch to the
|
|
|
|
[stable branch](https://carla.readthedocs.io/en/stable/).
|
|
|
|
|
|
|
|
## `carla.Client`
|
|
|
|
|
|
|
|
- `Client(host, port, worker_threads=0)`
|
2018-10-01 20:29:11 +08:00
|
|
|
- `set_timeout(float_seconds)`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `get_client_version()`
|
|
|
|
- `get_server_version()`
|
|
|
|
- `get_world()`
|
|
|
|
|
|
|
|
## `carla.World`
|
|
|
|
|
2018-10-17 02:12:23 +08:00
|
|
|
- `id`
|
|
|
|
- `map_name`
|
2018-10-28 00:10:00 +08:00
|
|
|
- `debug`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `get_blueprint_library()`
|
2018-10-25 04:42:50 +08:00
|
|
|
- `get_map()`
|
2018-07-29 17:28:16 +08:00
|
|
|
- `get_spectator()`
|
2018-10-15 01:00:08 +08:00
|
|
|
- `get_weather()`
|
|
|
|
- `set_weather(weather_parameters)`
|
2018-10-18 22:53:59 +08:00
|
|
|
- `get_actors()`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `spawn_actor(blueprint, transform, attach_to=None)`
|
|
|
|
- `try_spawn_actor(blueprint, transform, attach_to=None)`
|
2018-10-21 21:23:27 +08:00
|
|
|
- `wait_for_tick(seconds=1.0)`
|
2018-10-21 22:49:43 +08:00
|
|
|
- `on_tick(callback)`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
2018-10-28 00:10:00 +08:00
|
|
|
## `carla.DebugHelper`
|
|
|
|
|
2018-11-16 01:19:52 +08:00
|
|
|
- `draw_point(location, size=0.1, color=carla.Color(), life_time=-1.0, persistent_lines=True)`
|
|
|
|
- `draw_line(begin, end, thickness=0.1, color=carla.Color(), life_time=-1.0, persistent_lines=True)`
|
|
|
|
- `draw_arrow(begin, end, thickness=0.1, arrow_size=0.1, color=carla.Color(), life_time=-1.0, persistent_lines=True)`
|
|
|
|
- `draw_box(box, rotation, thickness=0.1, color=carla.Color(), life_time=-1.0, persistent_lines=True)`
|
|
|
|
- `draw_string(location, text, draw_shadow=False, color=carla.Color(), life_time=-1.0, persistent_lines=True)`
|
2018-10-28 00:10:00 +08:00
|
|
|
|
2018-07-29 01:29:31 +08:00
|
|
|
## `carla.BlueprintLibrary`
|
|
|
|
|
|
|
|
- `find(id)`
|
|
|
|
- `filter(wildcard_pattern)`
|
|
|
|
- `__getitem__(pos)`
|
|
|
|
- `__len__()`
|
|
|
|
- `__iter__()`
|
|
|
|
|
|
|
|
## `carla.ActorBlueprint`
|
|
|
|
|
|
|
|
- `id`
|
|
|
|
- `tags`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `has_tag(tag)`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `match_tags(wildcard_pattern)`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `has_attribute(key)`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `get_attribute(key)`
|
|
|
|
- `set_attribute(key, value)`
|
2018-09-30 21:28:06 +08:00
|
|
|
- `__len__()`
|
|
|
|
- `__iter__()`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
|
|
|
## `carla.ActorAttribute`
|
|
|
|
|
2018-08-29 22:23:32 +08:00
|
|
|
- `id`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `type`
|
|
|
|
- `recommended_values`
|
2018-08-29 22:23:32 +08:00
|
|
|
- `is_modifiable`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `as_bool()`
|
|
|
|
- `as_int()`
|
|
|
|
- `as_float()`
|
|
|
|
- `as_str()`
|
|
|
|
- `as_color()`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `__nonzero__()`
|
|
|
|
- `__bool__()`
|
|
|
|
- `__int__()`
|
|
|
|
- `__float__()`
|
|
|
|
- `__str__()`
|
|
|
|
|
2018-10-18 22:53:59 +08:00
|
|
|
## `carla.ActorList`
|
|
|
|
|
2018-12-16 07:05:15 +08:00
|
|
|
- `find(id)`
|
2018-10-19 03:09:54 +08:00
|
|
|
- `filter(wildcard_pattern)`
|
2018-10-18 22:53:59 +08:00
|
|
|
- `__getitem__(pos)`
|
|
|
|
- `__len__()`
|
|
|
|
- `__iter__()`
|
|
|
|
|
2018-07-29 01:29:31 +08:00
|
|
|
## `carla.Actor`
|
|
|
|
|
|
|
|
- `id`
|
|
|
|
- `type_id`
|
2018-10-25 21:41:14 +08:00
|
|
|
- `parent`
|
2018-10-22 00:27:49 +08:00
|
|
|
- `semantic_tags`
|
2018-10-07 03:32:04 +08:00
|
|
|
- `is_alive`
|
2018-11-30 23:05:30 +08:00
|
|
|
- `attributes`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `get_world()`
|
|
|
|
- `get_location()`
|
|
|
|
- `get_transform()`
|
2018-10-18 04:48:42 +08:00
|
|
|
- `get_velocity()`
|
|
|
|
- `get_acceleration()`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `set_location(location)`
|
|
|
|
- `set_transform(transform)`
|
2018-10-22 05:39:58 +08:00
|
|
|
- `set_simulate_physics(enabled=True)`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `destroy()`
|
|
|
|
|
|
|
|
## `carla.Vehicle(carla.Actor)`
|
|
|
|
|
2018-10-22 20:05:40 +08:00
|
|
|
- `bounding_box`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `apply_control(vehicle_control)`
|
2019-01-16 21:32:07 +08:00
|
|
|
- `get_control()`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `set_autopilot(enabled=True)`
|
2019-01-29 03:03:16 +08:00
|
|
|
- `get_speed_limit()`
|
|
|
|
- `get_traffic_light_state()`
|
|
|
|
- `is_at_traffic_light()`
|
|
|
|
- `get_traffic_light()`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
2018-10-22 20:35:48 +08:00
|
|
|
## `carla.TrafficLight(carla.Actor)`
|
|
|
|
|
|
|
|
- `state`
|
2019-01-29 03:03:16 +08:00
|
|
|
- `set_state(traffic_light_state)`
|
|
|
|
- `get_state()`
|
|
|
|
- `set_green_time(green_time)`
|
|
|
|
- `get_green_time()`
|
|
|
|
- `set_yellow_time(yellow_time)`
|
|
|
|
- `get_yellow_time()`
|
|
|
|
- `set_red_time(red_time)`
|
|
|
|
- `get_red_time()`
|
|
|
|
- `get_elapsed_time()`
|
|
|
|
- `freeze(True)`
|
|
|
|
- `is_frozen()`
|
2018-10-22 20:35:48 +08:00
|
|
|
|
2018-07-29 01:29:31 +08:00
|
|
|
## `carla.Sensor(carla.Actor)`
|
|
|
|
|
2018-10-08 19:17:26 +08:00
|
|
|
- `is_listening`
|
2018-07-29 01:29:31 +08:00
|
|
|
- `listen(callback_function)`
|
2018-10-08 19:17:26 +08:00
|
|
|
- `stop()`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
2018-10-22 20:35:48 +08:00
|
|
|
## `carla.SensorData`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
|
|
|
- `frame_number`
|
2018-09-30 21:28:06 +08:00
|
|
|
- `transform`
|
2018-10-22 20:35:48 +08:00
|
|
|
|
|
|
|
## `carla.Image(carla.SensorData)`
|
|
|
|
|
2018-07-29 01:29:31 +08:00
|
|
|
- `width`
|
|
|
|
- `height`
|
|
|
|
- `fov`
|
|
|
|
- `raw_data`
|
2018-10-05 07:24:07 +08:00
|
|
|
- `convert(color_converter)`
|
|
|
|
- `save_to_disk(path, color_converter=None)`
|
2018-09-30 21:28:06 +08:00
|
|
|
- `__len__()`
|
|
|
|
- `__iter__()`
|
2018-10-18 18:38:10 +08:00
|
|
|
- `__getitem__(pos)`
|
|
|
|
- `__setitem__(pos, color)`
|
2018-09-30 21:28:06 +08:00
|
|
|
|
2018-10-22 20:35:48 +08:00
|
|
|
## `carla.LidarMeasurement(carla.SensorData)`
|
2018-09-30 21:28:06 +08:00
|
|
|
|
|
|
|
- `horizontal_angle`
|
|
|
|
- `channels`
|
|
|
|
- `raw_data`
|
|
|
|
- `get_point_count(channel)`
|
2018-10-01 01:03:09 +08:00
|
|
|
- `save_to_disk(path)`
|
2018-09-30 21:28:06 +08:00
|
|
|
- `__len__()`
|
|
|
|
- `__iter__()`
|
2018-10-18 18:38:10 +08:00
|
|
|
- `__getitem__(pos)`
|
|
|
|
- `__setitem__(pos, location)`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
2018-10-22 20:35:48 +08:00
|
|
|
## `carla.CollisionEvent(carla.SensorData)`
|
|
|
|
|
|
|
|
- `actor`
|
|
|
|
- `other_actor`
|
|
|
|
- `normal_impulse`
|
|
|
|
|
2018-11-13 22:54:11 +08:00
|
|
|
## `carla.LaneInvasionEvent(carla.SensorData)`
|
|
|
|
|
|
|
|
- `actor`
|
|
|
|
- `crossed_lane_markings`
|
|
|
|
|
2019-01-23 17:51:15 +08:00
|
|
|
## `carla.GnssEvent(carla.SensorData)`
|
|
|
|
|
|
|
|
- `latitude`
|
|
|
|
- `longitude`
|
|
|
|
- `altitude`
|
|
|
|
|
2019-01-30 02:21:34 +08:00
|
|
|
## `carla.ObstacleDetectionSensorEvent(carla.SensorData)`
|
|
|
|
|
|
|
|
- `actor`
|
|
|
|
- `other_actor`
|
|
|
|
- `distance`
|
|
|
|
|
2018-07-29 01:29:31 +08:00
|
|
|
## `carla.VehicleControl`
|
|
|
|
|
|
|
|
- `throttle`
|
|
|
|
- `steer`
|
|
|
|
- `brake`
|
|
|
|
- `hand_brake`
|
|
|
|
- `reverse`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
2018-10-25 04:42:50 +08:00
|
|
|
## `carla.Map`
|
|
|
|
|
|
|
|
- `name`
|
|
|
|
- `get_spawn_points()`
|
|
|
|
- `get_waypoint(location, project_to_road=True)`
|
2018-11-15 01:15:56 +08:00
|
|
|
- `get_topology()`
|
2018-11-15 01:32:22 +08:00
|
|
|
- `generate_waypoints(distance)`
|
2018-10-25 04:42:50 +08:00
|
|
|
- `to_opendrive()`
|
2018-10-25 18:55:15 +08:00
|
|
|
- `save_to_disk(path=self.name)`
|
2018-10-25 04:42:50 +08:00
|
|
|
|
|
|
|
## `carla.Waypoint`
|
|
|
|
|
|
|
|
- `transform`
|
2018-11-15 03:41:00 +08:00
|
|
|
- `is_intersection`
|
|
|
|
- `lane_width`
|
|
|
|
- `road_id`
|
|
|
|
- `lane_id`
|
2018-10-25 04:42:50 +08:00
|
|
|
- `next(distance)`
|
|
|
|
|
2018-10-15 01:00:08 +08:00
|
|
|
## `carla.WeatherParameters`
|
|
|
|
|
|
|
|
- `cloudyness`
|
|
|
|
- `precipitation`
|
|
|
|
- `precipitation_deposits`
|
|
|
|
- `wind_intensity`
|
|
|
|
- `sun_azimuth_angle`
|
|
|
|
- `sun_altitude_angle`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
|
|
|
|
|
|
|
Static presets
|
|
|
|
|
|
|
|
- `carla.WeatherParameters.ClearNoon`
|
|
|
|
- `carla.WeatherParameters.CloudyNoon`
|
|
|
|
- `carla.WeatherParameters.WetNoon`
|
|
|
|
- `carla.WeatherParameters.WetCloudyNoon`
|
|
|
|
- `carla.WeatherParameters.MidRainyNoon`
|
|
|
|
- `carla.WeatherParameters.HardRainNoon`
|
|
|
|
- `carla.WeatherParameters.SoftRainNoon`
|
|
|
|
- `carla.WeatherParameters.ClearSunset`
|
|
|
|
- `carla.WeatherParameters.CloudySunset`
|
|
|
|
- `carla.WeatherParameters.WetSunset`
|
|
|
|
- `carla.WeatherParameters.WetCloudySunset`
|
|
|
|
- `carla.WeatherParameters.MidRainSunset`
|
|
|
|
- `carla.WeatherParameters.HardRainSunset`
|
|
|
|
- `carla.WeatherParameters.SoftRainSunset`
|
|
|
|
|
|
|
|
## `carla.Vector3D`
|
|
|
|
|
|
|
|
- `x`
|
|
|
|
- `y`
|
|
|
|
- `z`
|
|
|
|
- `__add__(other)`
|
|
|
|
- `__sub__(other)`
|
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
2018-10-15 01:00:08 +08:00
|
|
|
|
2018-07-29 01:29:31 +08:00
|
|
|
## `carla.Location`
|
|
|
|
|
|
|
|
- `x`
|
|
|
|
- `y`
|
|
|
|
- `z`
|
2018-11-16 01:19:52 +08:00
|
|
|
- `distance(other)`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `__add__(other)`
|
|
|
|
- `__sub__(other)`
|
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
|
|
|
## `carla.Rotation`
|
|
|
|
|
|
|
|
- `pitch`
|
|
|
|
- `yaw`
|
|
|
|
- `roll`
|
2019-01-17 18:27:57 +08:00
|
|
|
- `get_forward_vector()`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
|
|
|
## `carla.Transform`
|
|
|
|
|
|
|
|
- `location`
|
|
|
|
- `rotation`
|
2019-01-17 18:27:57 +08:00
|
|
|
- `transform(geom_object)`
|
|
|
|
- `get_forward_vector()`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
|
|
|
|
2018-11-16 01:19:52 +08:00
|
|
|
## `carla.BoundingBox`
|
|
|
|
|
|
|
|
- `location`
|
|
|
|
- `extent`
|
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
|
|
|
|
2018-10-22 20:35:48 +08:00
|
|
|
## `carla.Timestamp`
|
|
|
|
|
|
|
|
- `frame_count`
|
|
|
|
- `elapsed_seconds`
|
|
|
|
- `delta_seconds`
|
|
|
|
- `platform_timestamp`
|
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
2018-07-29 01:29:31 +08:00
|
|
|
|
|
|
|
## `carla.Color`
|
|
|
|
|
|
|
|
- `r`
|
|
|
|
- `g`
|
|
|
|
- `b`
|
2018-09-30 21:28:06 +08:00
|
|
|
- `a`
|
2018-10-22 20:35:48 +08:00
|
|
|
- `__eq__(other)`
|
|
|
|
- `__ne__(other)`
|
2018-10-05 07:24:07 +08:00
|
|
|
|
|
|
|
## `carla.ColorConverter`
|
|
|
|
|
2018-10-22 18:44:13 +08:00
|
|
|
- `Raw`
|
2018-10-05 07:24:07 +08:00
|
|
|
- `Depth`
|
|
|
|
- `LogarithmicDepth`
|
|
|
|
- `CityScapesPalette`
|
2018-10-22 20:35:48 +08:00
|
|
|
|
|
|
|
## `carla.ActorAttributeType`
|
|
|
|
|
|
|
|
- `Bool`
|
|
|
|
- `Int`
|
|
|
|
- `Float`
|
|
|
|
- `RGBColor`
|
|
|
|
|
|
|
|
## `carla.TrafficLightState`
|
|
|
|
|
|
|
|
- `Red`
|
|
|
|
- `Yellow`
|
|
|
|
- `Green`
|
2019-01-29 03:03:16 +08:00
|
|
|
- `Off`
|
2018-11-08 19:50:11 +08:00
|
|
|
- `Unknown`
|
2018-11-13 22:54:11 +08:00
|
|
|
|
|
|
|
## `carla.LaneMarking`
|
|
|
|
|
|
|
|
- `Other`
|
|
|
|
- `Broken`
|
|
|
|
- `Solid`
|