diff --git a/.gitignore b/.gitignore
index 942fbfc99..d922129e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ TrafficManager/build
Util/Build
Install
Plugins
+!Unreal/CarlaUE4/Plugins
/ExportedMaps
/Import/*
diff --git a/Docs/python_api.md b/Docs/python_api.md
index 050d69c11..3d7ba77d1 100644
--- a/Docs/python_api.md
+++ b/Docs/python_api.md
@@ -801,6 +801,17 @@ Returns a list of pairs of waypoints. Every tuple on the list contains first an
---
+## carla.LabelledPoint
+Class that represent a position in space with a semantic label.
+
+
Instance Variables
+- **location**
+Position in 3D space.
+- **label**
+Semantic tag of the point.
+
+---
+
## carla.Landmark
Class that defines any type of traffic landmark or sign affecting a road. These class mediates between the [OpenDRIVE 1.4 standard](http://www.opendrive.org/docs/OpenDRIVEFormatSpecRev1.4H.pdf) definition of the landmarks and their representation in the simulation. This class retrieves all the information defining a landmark in OpenDRIVE and facilitates information about which lanes does it affect and when.
Landmarks will be accessed by [carla.Waypoint](#carla.Waypoint) objects trying to retrieve the regulation of their lane. Therefore some attributes depend on the waypoint that is consulting the landmark and so, creating the object.
@@ -2702,15 +2713,34 @@ This method applies settings contained in an object to the simulation running an
- **Return:** _int_
- **Warning:** _If synchronous mode is enabled, and there is a Traffic Manager running, this must be set to sync mode too. Read [this](adv_traffic_manager.md#synchronous-mode) to learn how to do it.
_
+- **cast_ray**(**self**, **initial_location**, **final_location**)
+Casts a ray from the specified initial_location to final_location. The function then detects all geometries intersecting the ray and returns a list of [carla.LabelledPoint](#carla.LabelledPoint) in order.
+ - **Parameters:**
+ - `initial_location` (_[carla.Location](#carla.Location)_) – The initial position of the ray.
+ - `final_location` (_[carla.Location](#carla.Location)_) – The final position of the ray.
+ - **Return:** _list([carla.LabelledPoint](#carla.LabelledPoint))_
- **freeze_all_traffic_lights**(**self**, **frozen**)
Freezes or unfreezes all traffic lights in the scene. Frozen traffic lights can be modified by the user but the time will not update them until unfrozen.
- **Parameters:**
- `frozen` (_bool_)
+- **ground_projection**(**self**, **location**, **search_distance**)
+Projects the specified point downwards in the scene. The functions casts a ray from location in the direction (0,0,-1) (downwards) and returns a [carla.Labelled](#carla.Labelled) object with the first geometry this ray intersects (usually the ground). If no geometry is found in the search_distance range the function returns `None`.
+ - **Parameters:**
+ - `location` (_[carla.Location](#carla.Location)_) – The point to be projected.
+ - `search_distance` (_float_) – The maximum distance to perform the projection.
+ - **Return:** _[carla.LabelledPoint](#carla.LabelledPoint)_
- **on_tick**(**self**, **callback**)
This method is used in [__asynchronous__ mode](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/adv_synchrony_timestep/). It starts callbacks from the client for the function defined as `callback`, and returns the ID of the callback. The function will be called everytime the server ticks. It requires a [carla.WorldSnapshot](#carla.WorldSnapshot) as argument, which can be retrieved from __wait_for_tick()__. Use __remove_on_tick()__ to stop the callbacks.
- **Parameters:**
- `callback` (_[carla.WorldSnapshot](#carla.WorldSnapshot)_) – Function with a snapshot as compulsory parameter that will be called when the client receives a tick.
- **Return:** _int_
+- **project_point**(**self**, **location**, **direction**, **search_distance**)
+Projects the specified point to the desired direction in the scene. The functions casts a ray from location in a direction and returns a [carla.Labelled](#carla.Labelled) object with the first geometry this ray intersects. If no geometry is found in the search_distance range the function returns `None`.
+ - **Parameters:**
+ - `location` (_[carla.Location](#carla.Location)_) – The point to be projected.
+ - `direction` (_[carla.Vector3D](#carla.Vector3D)_) – The direction of projection.
+ - `search_distance` (_float_) – The maximum distance to perform the projection.
+ - **Return:** _[carla.LabelledPoint](#carla.LabelledPoint)_
- **remove_on_tick**(**self**, **callback_id**)
Stops the callback for `callback_id` started with __on_tick()__.
- **Parameters:**
@@ -3196,89 +3226,6 @@ document.getElementById("snipets-container").innerHTML = null;
}
-
-
-Snipet for carla.Map.get_waypoint
-
-
-
-```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))
-# ...
-
-
-```
-
-
-
-
-
-
-
-
-
-Snipet for carla.Sensor.listen
-
-
-
-```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))
-# ...
-
-
-```
-
-
-
-
-
-
-Snipet for carla.World.spawn_actor
-
-
-
-```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)
-# ...
-
-
-```
-
-
-
-
Snipet for carla.ActorBlueprint.set_attribute
@@ -3313,160 +3260,6 @@ camera_bp.set_attribute('image_size_y', 600)
-
-
-Snipet for carla.World.get_spectator
-
-
-
-```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())
-# ...
-
-
-```
-
-
-
-
-
-
-Snipet for carla.DebugHelper.draw_line
-
-
-
-```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)
-# ...
-
-
-```
-
-
-
-
-
-
-
-
-
-Snipet for carla.DebugHelper.draw_box
-
-
-
-```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)
-# ...
-
-
-
-```
-
-
-
-
-
-
-
-
-
-Snipet for carla.TrafficLight.set_state
-
-
-
-```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)
-# ...
-
-
-
-```
-
-
-
-
-
-
-
Snipet for carla.Client.apply_batch_sync
@@ -3564,6 +3357,158 @@ client.apply_batch([carla.command.DestroyActor(x) for x in all_id])
+
+
+Snipet for carla.Map.get_waypoint
+
+
+
+```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))
+# ...
+
+
+```
+
+
+
+
+
+
+
+
+
+Snipet for carla.DebugHelper.draw_line
+
+
+
+```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)
+# ...
+
+
+```
+
+
+
+
+
+
+
+
+
+Snipet for carla.TrafficLight.set_state
+
+
+
+```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)
+# ...
+
+
+
+```
+
+
+
+
+
+
+
+
+
+Snipet for carla.DebugHelper.draw_box
+
+
+
+```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)
+# ...
+
+
+
+```
+
+
+
+
+
+
+
Snipet for carla.Client.__init__
@@ -3609,6 +3554,91 @@ Snipet for carla.Client.__init__
+
+
+Snipet for carla.Sensor.listen
+
+
+
+```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))
+# ...
+
+
+```
+
+
+
+
+
+
+Snipet for carla.World.spawn_actor
+
+
+
+```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)
+# ...
+
+
+```
+
+
+
+
+
+
+Snipet for carla.World.get_spectator
+
+
+
+```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())
+# ...
+
+
+```
+
+
+
+
diff --git a/LibCarla/source/carla/client/World.cpp b/LibCarla/source/carla/client/World.cpp
index cb27e99ac..908a5df4b 100644
--- a/LibCarla/source/carla/client/World.cpp
+++ b/LibCarla/source/carla/client/World.cpp
@@ -176,5 +176,25 @@ namespace client {
_episode.Lock()->EnableEnvironmentObjects(env_objects_ids, enable);
}
+ boost::optional World::ProjectPoint(
+ geom::Location location, geom::Vector3D direction, float search_distance) const {
+ auto result = _episode.Lock()->ProjectPoint(location, direction, search_distance);
+ if (result.first) {
+ return result.second;
+ }
+ return {};
+ }
+
+ boost::optional World::GroundProjection(
+ geom::Location location, float search_distance) const {
+ const geom::Vector3D DownVector(0,0,-1);
+ return ProjectPoint(location, DownVector, search_distance);
+ }
+
+ std::vector World::CastRay(
+ geom::Location start_location, geom::Location end_location) const {
+ return _episode.Lock()->CastRay(start_location, end_location);
+ }
+
} // namespace client
} // namespace carla
diff --git a/LibCarla/source/carla/client/World.h b/LibCarla/source/carla/client/World.h
index 473b50ca6..b69f2fac5 100644
--- a/LibCarla/source/carla/client/World.h
+++ b/LibCarla/source/carla/client/World.h
@@ -19,6 +19,7 @@
#include "carla/rpc/AttachmentType.h"
#include "carla/rpc/EpisodeSettings.h"
#include "carla/rpc/EnvironmentObject.h"
+#include "carla/rpc/LabelledPoint.h"
#include "carla/rpc/VehiclePhysicsControl.h"
#include "carla/rpc/WeatherParameters.h"
#include "carla/rpc/VehicleLightStateList.h"
@@ -162,6 +163,15 @@ namespace client {
std::vector env_objects_ids,
bool enable) const;
+ boost::optional ProjectPoint(
+ geom::Location location, geom::Vector3D direction, float search_distance = 10000.f) const;
+
+ boost::optional GroundProjection(
+ geom::Location location, float search_distance = 10000.0) const;
+
+ std::vector CastRay(
+ geom::Location start_location, geom::Location end_location) const;
+
private:
detail::EpisodeProxy _episode;
diff --git a/LibCarla/source/carla/client/detail/Client.cpp b/LibCarla/source/carla/client/detail/Client.cpp
index 52d0e4bd4..c4138d23f 100644
--- a/LibCarla/source/carla/client/detail/Client.cpp
+++ b/LibCarla/source/carla/client/detail/Client.cpp
@@ -461,6 +461,18 @@ namespace detail {
_pimpl->AsyncCall("enable_environment_objects", std::move(env_objects_ids), enable);
}
+ std::pair Client::ProjectPoint(
+ geom::Location location, geom::Vector3D direction, float search_distance) const {
+ using return_t = std::pair;
+ return _pimpl->CallAndWait("project_point", location, direction, search_distance);
+ }
+
+ std::vector Client::CastRay(
+ geom::Location start_location, geom::Location end_location) const {
+ using return_t = std::vector;
+ return _pimpl->CallAndWait("cast_ray", start_location, end_location);
+ }
+
} // namespace detail
} // namespace client
} // namespace carla
diff --git a/LibCarla/source/carla/client/detail/Client.h b/LibCarla/source/carla/client/detail/Client.h
index 830c6eec1..45afcce37 100644
--- a/LibCarla/source/carla/client/detail/Client.h
+++ b/LibCarla/source/carla/client/detail/Client.h
@@ -10,6 +10,7 @@
#include "carla/NonCopyable.h"
#include "carla/Time.h"
#include "carla/geom/Transform.h"
+#include "carla/geom/Location.h"
#include "carla/rpc/Actor.h"
#include "carla/rpc/ActorDefinition.h"
#include "carla/rpc/AttachmentType.h"
@@ -17,6 +18,7 @@
#include "carla/rpc/CommandResponse.h"
#include "carla/rpc/EpisodeInfo.h"
#include "carla/rpc/EpisodeSettings.h"
+#include "carla/rpc/LabelledPoint.h"
#include "carla/rpc/LightState.h"
#include "carla/rpc/MapInfo.h"
#include "carla/rpc/EnvironmentObject.h"
@@ -297,6 +299,12 @@ namespace detail {
std::vector env_objects_ids,
bool enable) const;
+ std::pair ProjectPoint(
+ geom::Location location, geom::Vector3D direction, float search_distance) const;
+
+ std::vector CastRay(
+ geom::Location start_location, geom::Location end_location) const;
+
private:
class Pimpl;
diff --git a/LibCarla/source/carla/client/detail/Simulator.h b/LibCarla/source/carla/client/detail/Simulator.h
index 56f7c67dc..037a83468 100644
--- a/LibCarla/source/carla/client/detail/Simulator.h
+++ b/LibCarla/source/carla/client/detail/Simulator.h
@@ -23,6 +23,7 @@
#include "carla/profiler/LifetimeProfiled.h"
#include "carla/rpc/TrafficLightState.h"
#include "carla/rpc/VehicleLightStateList.h"
+#include "carla/rpc/LabelledPoint.h"
#include
@@ -241,6 +242,16 @@ namespace detail {
_client.EnableEnvironmentObjects(env_objects_ids, enable);
}
+ std::pair ProjectPoint(
+ geom::Location location, geom::Vector3D direction, float search_distance) const {
+ return _client.ProjectPoint(location, direction, search_distance);
+ }
+
+ std::vector CastRay(
+ geom::Location start_location, geom::Location end_location) const {
+ return _client.CastRay(start_location, end_location);
+ }
+
/// @}
// =========================================================================
/// @name AI
diff --git a/LibCarla/source/carla/rpc/LabelledPoint.h b/LibCarla/source/carla/rpc/LabelledPoint.h
new file mode 100644
index 000000000..acceca2bc
--- /dev/null
+++ b/LibCarla/source/carla/rpc/LabelledPoint.h
@@ -0,0 +1,32 @@
+// Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma
+// de Barcelona (UAB).
+//
+// This work is licensed under the terms of the MIT license.
+// For a copy, see .
+
+#pragma once
+
+#include "carla/MsgPack.h"
+#include "carla/rpc/Location.h"
+#include "carla/rpc/ObjectLabel.h"
+
+namespace carla {
+namespace rpc {
+
+ struct LabelledPoint {
+
+ LabelledPoint () {}
+ LabelledPoint (Location location, CityObjectLabel label)
+ : _location(location), _label(label)
+ {}
+
+ Location _location;
+
+ CityObjectLabel _label;
+
+ MSGPACK_DEFINE_ARRAY(_location, _label);
+
+ };
+
+}
+}
diff --git a/LibCarla/source/carla/rpc/ObjectLabel.h b/LibCarla/source/carla/rpc/ObjectLabel.h
index 5b7b5d30d..fedc03641 100644
--- a/LibCarla/source/carla/rpc/ObjectLabel.h
+++ b/LibCarla/source/carla/rpc/ObjectLabel.h
@@ -23,10 +23,10 @@ namespace rpc {
RoadLines = 6u,
Roads = 7u,
Sidewalks = 8u,
- TrafficSigns = 12u,
Vegetation = 9u,
Vehicles = 10u,
Walls = 11u,
+ TrafficSigns = 12u,
Sky = 13u,
Ground = 14u,
Bridge = 15u,
diff --git a/PythonAPI/carla/source/libcarla/World.cpp b/PythonAPI/carla/source/libcarla/World.cpp
index 62f2038b6..541b9f7dd 100644
--- a/PythonAPI/carla/source/libcarla/World.cpp
+++ b/PythonAPI/carla/source/libcarla/World.cpp
@@ -201,6 +201,11 @@ void export_world() {
.value("Terrain", cr::CityObjectLabel::Terrain)
;
+ class_("LabelledPoint", no_init)
+ .def_readonly("location", &cr::LabelledPoint::_location)
+ .def_readonly("label", &cr::LabelledPoint::_label)
+ ;
+
#define SPAWN_ACTOR_WITHOUT_GIL(fn) +[]( \
cc::World &self, \
const cc::ActorBlueprint &blueprint, \
@@ -247,6 +252,9 @@ void export_world() {
.def("get_level_bbs", &GetLevelBBs, (arg("actor_type")=cr::CityObjectLabel::None))
.def("get_environment_objects", &GetEnvironmentObjects)
.def("enable_environment_objects", &EnableEnvironmentObjects, (arg("env_objects_ids"), arg("enable")))
+ .def("cast_ray", CALL_RETURNING_LIST_2(cc::World, CastRay, cg::Location, cg::Location), (arg("initial_location"), arg("final_location")))
+ .def("project_point", CALL_RETURNING_OPTIONAL_3(cc::World, ProjectPoint, cg::Location, cg::Vector3D, float), (arg("location"), arg("direction"), arg("search_distance")=10000.f))
+ .def("ground_projection", CALL_RETURNING_OPTIONAL_2(cc::World, GroundProjection, cg::Location, float), (arg("location"), arg("search_distance")=10000.f))
.def(self_ns::str(self_ns::self))
;
diff --git a/PythonAPI/carla/source/libcarla/libcarla.cpp b/PythonAPI/carla/source/libcarla/libcarla.cpp
index 0752f5015..5e8754779 100644
--- a/PythonAPI/carla/source/libcarla/libcarla.cpp
+++ b/PythonAPI/carla/source/libcarla/libcarla.cpp
@@ -111,6 +111,16 @@ static boost::python::object OptionalToPythonObject(OptionalT &optional) {
return OptionalToPythonObject(optional); \
}
+#define CALL_RETURNING_OPTIONAL_2(cls, fn, T1_, T2_) +[](const cls &self, T1_ t1, T2_ t2) { \
+ auto optional = self.fn(std::forward(t1), std::forward(t2)); \
+ return OptionalToPythonObject(optional); \
+ }
+
+#define CALL_RETURNING_OPTIONAL_3(cls, fn, T1_, T2_, T3_) +[](const cls &self, T1_ t1, T2_ t2, T3_ t3) { \
+ auto optional = self.fn(std::forward(t1), std::forward(t2), std::forward(t3)); \
+ return OptionalToPythonObject(optional); \
+ }
+
#define CALL_RETURNING_OPTIONAL_WITHOUT_GIL(cls, fn) +[](const cls &self) { \
carla::PythonUtil::ReleaseGIL unlock; \
auto optional = self.fn(); \
diff --git a/PythonAPI/docs/world.yml b/PythonAPI/docs/world.yml
index 2b077ddb6..fed5cd47e 100644
--- a/PythonAPI/docs/world.yml
+++ b/PythonAPI/docs/world.yml
@@ -186,6 +186,20 @@
An attachment that expands or retracts the position of the actor, depending on its parent. This attachment is only recommended to record videos from the simulation where a smooth movement is needed. SpringArms are an Unreal Engine component so [check the UE docs](https://docs.unrealengine.com/en-US/Gameplay/HowTo/UsingCameras/SpringArmComponents/index.html) to learn more about them. Warning: The SpringArm attachment presents weird behaviors when an actor is spawned with a relative translation in the Z-axis (e.g. child_location = Location(0,0,2)).
# --------------------------------------
+ - class_name: LabelledPoint
+ # - DESCRIPTION ------------------------
+ doc: >
+ Class that represent a position in space with a semantic label.
+ # - PROPERTIES -------------------------
+ instance_variables:
+ - var_name: location
+ doc: >
+ Position in 3D space.
+ - var_name: label
+ doc: >
+ Semantic tag of the point.
+ # --------------------------------------
+
- class_name: World
# - DESCRIPTION ------------------------
doc: >
@@ -421,13 +435,59 @@
New conditions to be applied.
doc: >
Changes the weather parameteres ruling the simulation to another ones defined in an object.
- # --------------------------------------
+ # --------------------------------------
+ - def_name: cast_ray
+ return: list(carla.LabelledPoint)
+ params:
+ - param_name: initial_location
+ type: carla.Location
+ doc: >
+ The initial position of the ray.
+ - param_name: final_location
+ type: carla.Location
+ doc: >
+ The final position of the ray.
+ doc: >
+ Casts a ray from the specified initial_location to final_location. The function then detects all geometries intersecting the ray and returns a list of carla.LabelledPoint in order.
+ # --------------------------------------
+ - def_name: project_point
+ return: carla.LabelledPoint
+ params:
+ - param_name: location
+ type: carla.Location
+ doc: >
+ The point to be projected.
+ - param_name: direction
+ type: carla.Vector3D
+ doc: >
+ The direction of projection.
+ - param_name: search_distance
+ type: float
+ doc: >
+ The maximum distance to perform the projection
+ doc: >
+ Projects the specified point to the desired direction in the scene. The functions casts a ray from location in a direction and returns a carla.Labelled object with the first geometry this ray intersects. If no geometry is found in the search_distance range the function returns `None`.
+ # --------------------------------------
+ - def_name: ground_projection
+ return: carla.LabelledPoint
+ params:
+ - param_name: location
+ type: carla.Location
+ doc: >
+ The point to be projected.
+ - param_name: search_distance
+ type: float
+ doc: >
+ The maximum distance to perform the projection
+ doc: >
+ Projects the specified point downwards in the scene. The functions casts a ray from location in the direction (0,0,-1) (downwards) and returns a carla.Labelled object with the first geometry this ray intersects (usually the ground). If no geometry is found in the search_distance range the function returns `None`.
+ # --------------------------------------
- def_name: __str__
return:
string
doc: >
The content of the world is parsed and printed as a brief report of its current state.
- # --------------------------------------
+ # --------------------------------------
- class_name: DebugHelper
# - DESCRIPTION ------------------------
diff --git a/Unreal/CarlaUE4/Config/DefaultEngine.ini b/Unreal/CarlaUE4/Config/DefaultEngine.ini
index 96c4ca9c7..df2549583 100644
--- a/Unreal/CarlaUE4/Config/DefaultEngine.ini
+++ b/Unreal/CarlaUE4/Config/DefaultEngine.ini
@@ -97,13 +97,15 @@ InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10
DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)
+[/Script/WindowsTargetPlatform.WindowsTargetSettings]
+DefaultGraphicsRHI=DefaultGraphicsRHI_DX12
+
[/Script/Engine.CollisionProfile]
+Profiles=(Name="CustomSensorCollision",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="SensorObject",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore),(Channel="SensorObject"),(Channel="SensorTrace")),HelpMessage="Used for custom collision meshes for objects that has very complex meshes but we want them to appear in raycast based sensors")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="SensorObject")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="SensorTrace")
++DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Overlap,bTraceType=True,bStaticObject=False,Name="OverlapChannel")
+EditProfiles=(Name="BlockAll",CustomResponses=((Channel="SensorObject"),(Channel="SensorTrace")))
+EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="SensorObject",Response=ECR_Overlap),(Channel="SensorTrace",Response=ECR_Overlap)))
-[/Script/WindowsTargetPlatform.WindowsTargetSettings]
-DefaultGraphicsRHI=DefaultGraphicsRHI_DX12
diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp
index a76fc27db..f164213cd 100644
--- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp
+++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp
@@ -10,9 +10,11 @@
#include "Carla/OpenDrive/OpenDrive.h"
#include "Carla/Util/DebugShapeDrawer.h"
#include "Carla/Util/NavigationMesh.h"
+#include "Carla/Util/RayTracer.h"
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
#include "Carla/Walker/WalkerController.h"
#include "GameFramework/CharacterMovementComponent.h"
+#include "Carla/Game/Tagger.h"
#include
#include
@@ -25,6 +27,7 @@
#include
#include
#include
+#include "carla/rpc/LabelledPoint.h"
#include
#include
#include
@@ -46,6 +49,7 @@
#include
#include