diff --git a/CHANGELOG.md b/CHANGELOG.md index 712ca9efe..9c76ea01b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ * Fixed gravity measurement bug from IMU sensor * OpenDRIVE ingestion bugfixes * Added Dynamic Vision Sensor (DVS) camera based on ESIM simulation http://rpg.ifi.uzh.ch/esim.html + * Added API functions `get_right_vector` and `get_up_vector` + * Added parameter to enable/disable pedestrian navigation in standalone mode + * Improved mesh split in standalone mode + * Fixed large RAM usage when loading polinomial geometry from OpenDRIVE + ## CARLA 0.9.9 diff --git a/Docs/python_api.md b/Docs/python_api.md index f28677fd6..baa6b7656 100644 --- a/Docs/python_api.md +++ b/Docs/python_api.md @@ -294,7 +294,7 @@ Helper class defining a box location and its dimensions that will later be used

Instance Variables

- **extent** (_[carla.Vector3D](#carla.Vector3D)_) -Vector from the center of the box to one vertex. The value in each axis equals half the size of the box for that axis. +Vector from the center of the box to one vertex. The value in each axis equals half the size of the box for that axis. `extent.x * 2` would return the size of the box in the X-axis. - **location** (_[carla.Location](#carla.Location)_) The center of the bounding box relative to its parent actor. @@ -1382,6 +1382,8 @@ Additional with applied junction lanes. Complex situations tend to occur at junc If __True__, the mesh at junctions will be smoothed to prevent issues where roads blocked other roads. __Default is `True`__. - **enable_mesh_visibility** (_bool_) If __True__, the road mesh will be rendered. Setting this to __False__ should reduce the rendering overhead. __Default is `True`__. +- **enable_pedestrian_navigation** (_bool_) +If __True__, Pedestrian navigation will be enabled using Recast tool. For very large maps it is recomended to disable this option. __Default is `True`__. --- @@ -1451,6 +1453,12 @@ Degrees around the X-axis.
- **get_forward_vector**(**self**) Computes the vector pointing forward according to the orientation of each axis. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ +- **get_right_vector**(**self**) +Computes the vector pointing to the right according to the orientation of each axis. + - **Return:** _[carla.Vector3D](#carla.Vector3D)_ +- **get_up_vector**(**self**) +Computes the vector pointing upwards according to the orientation of each axis. + - **Return:** _[carla.Vector3D](#carla.Vector3D)_
Dunder methods
- **\__eq__**(**self**, **other**=[carla.Rotation](#carla.Rotation)) @@ -1771,7 +1779,7 @@ All possible states for traffic lights. These can either change at a specific ti --- ## carla.TrafficManager -The traffic manager is a module built on top of the CARLA API in C++. It handles any group of vehicles set to autopilot mode to populate the simulation with realistic urban traffic conditions and give the chance to user to customize some behaviours. The architecture of the traffic manager is divided in five different goal-oriented stages and a PID controller where the information flows until eventually, a [carla.VehicleControl](#carla.VehicleControl) is applied to every vehicle registered in a traffic manager. +The traffic manager is a module built on top of the CARLA API in C++. It handles any group of vehicles set to autopilot mode to populate the simulation with realistic urban traffic conditions and give the chance to user to customize some behaviours. The architecture of the traffic manager is divided in five different goal-oriented stages and a PID controller where the information flows until eventually, a [carla.VehicleControl](#carla.VehicleControl) is applied to every vehicle registered in a traffic manager. In order to learn more, visit the [documentation](adv_traffic_manager.md) regarding this module.

Methods

@@ -1801,7 +1809,7 @@ Sets the minimum distance in meters that vehicles have to keep with the rest. Th - **Parameters:** - `distance` (_float_) – Meters between vehicles. - **global_percentage_speed_difference**(**self**, **percentage**) -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. +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. - **Parameters:** - `percentage` (_float_) – Percentage difference between intended speed and the current limit. @@ -1823,7 +1831,7 @@ During the collision detection stage, which runs every frame, this method sets a - **reset_traffic_lights**(**self**) Resets every traffic light in the map to its initial state. - **vehicle_percentage_speed_difference**(**self**, **actor**, **percentage**) -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. +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. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) – Vehicle whose speed behaviour is being changed. @@ -1878,6 +1886,12 @@ Translates a 3D point from global to local coordinates using the current transfo
- **get_forward_vector**(**self**) Computes a forward vector using its rotation. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ +- **get_right_vector**(**self**) +Computes a right vector using its rotation. + - **Return:** _[carla.Vector3D](#carla.Vector3D)_ +- **get_up_vector**(**self**) +Computes an up vector using its rotation. + - **Return:** _[carla.Vector3D](#carla.Vector3D)_
Dunder methods
- **\__eq__**(**self**, **other**=[carla.Transform](#carla.Transform)) diff --git a/LibCarla/source/carla/geom/Math.cpp b/LibCarla/source/carla/geom/Math.cpp index aaf439d1f..53799abaa 100644 --- a/LibCarla/source/carla/geom/Math.cpp +++ b/LibCarla/source/carla/geom/Math.cpp @@ -135,6 +135,19 @@ namespace geom { -cp * sr}; } + Vector3D Math::GetUpVector(const Rotation &rotation) { + const float cy = std::cos(ToRadians(rotation.yaw)); + const float sy = std::sin(ToRadians(rotation.yaw)); + const float cr = std::cos(ToRadians(rotation.roll)); + const float sr = std::sin(ToRadians(rotation.roll)); + const float cp = std::cos(ToRadians(rotation.pitch)); + const float sp = std::sin(ToRadians(rotation.pitch)); + return { + -cy * sp * cr - sy * sr, + -sy * sp * cr + cy * sr, + -cp * cr}; + } + std::vector Math::GenerateRange(int a, int b) { std::vector result; if (a < b) { diff --git a/LibCarla/source/carla/geom/Math.h b/LibCarla/source/carla/geom/Math.h index e6a151075..1f6ec7ec3 100644 --- a/LibCarla/source/carla/geom/Math.h +++ b/LibCarla/source/carla/geom/Math.h @@ -113,6 +113,9 @@ namespace geom { /// Compute the unit vector pointing towards the Y-axis of @a rotation. static Vector3D GetRightVector(const Rotation &rotation); + /// Compute the unit vector pointing towards the Y-axis of @a rotation. + static Vector3D GetUpVector(const Rotation &rotation); + // Helper function to generate a vector of consecutive integers from a to b static std::vector GenerateRange(int a, int b); diff --git a/LibCarla/source/carla/geom/Rotation.h b/LibCarla/source/carla/geom/Rotation.h index 3dc0def2f..6afe21b08 100644 --- a/LibCarla/source/carla/geom/Rotation.h +++ b/LibCarla/source/carla/geom/Rotation.h @@ -55,6 +55,10 @@ namespace geom { return Math::GetRightVector(*this); } + Vector3D GetUpVector() const { + return Math::GetUpVector(*this); + } + void RotateVector(Vector3D &in_point) const { // Rotates Rz(yaw) * Ry(pitch) * Rx(roll) = first x, then y, then z. const float cy = std::cos(Math::ToRadians(yaw)); diff --git a/LibCarla/source/carla/geom/Transform.h b/LibCarla/source/carla/geom/Transform.h index 3f67f8500..02f57c14a 100644 --- a/LibCarla/source/carla/geom/Transform.h +++ b/LibCarla/source/carla/geom/Transform.h @@ -57,6 +57,10 @@ namespace geom { return rotation.GetRightVector(); } + Vector3D GetUpVector() const { + return rotation.GetUpVector(); + } + /// Applies this transformation to @a in_point (first translation then rotation). void TransformPoint(Vector3D &in_point) const { auto out_point = in_point; diff --git a/PythonAPI/carla/source/libcarla/Geom.cpp b/PythonAPI/carla/source/libcarla/Geom.cpp index c516637e5..b5f8fab0f 100644 --- a/PythonAPI/carla/source/libcarla/Geom.cpp +++ b/PythonAPI/carla/source/libcarla/Geom.cpp @@ -155,6 +155,8 @@ void export_geom() { .def_readwrite("yaw", &cg::Rotation::yaw) .def_readwrite("roll", &cg::Rotation::roll) .def("get_forward_vector", &cg::Rotation::GetForwardVector) + .def("get_right_vector", &cg::Rotation::GetRightVector) + .def("get_up_vector", &cg::Rotation::GetUpVector) .def("__eq__", &cg::Rotation::operator==) .def("__ne__", &cg::Rotation::operator!=) .def(self_ns::str(self_ns::self)) @@ -171,6 +173,8 @@ void export_geom() { return location; }, arg("in_point")) .def("get_forward_vector", &cg::Transform::GetForwardVector) + .def("get_right_vector", &cg::Transform::GetRightVector) + .def("get_up_vector", &cg::Transform::GetUpVector) .def("__eq__", &cg::Transform::operator==) .def("__ne__", &cg::Transform::operator!=) .def(self_ns::str(self_ns::self)) diff --git a/PythonAPI/docs/client.yml b/PythonAPI/docs/client.yml index de40ddeb4..2585df4e5 100644 --- a/PythonAPI/docs/client.yml +++ b/PythonAPI/docs/client.yml @@ -70,7 +70,7 @@ type: carla.OpendriveGenerationParameters default: (2.0, 50.0, 1.0, 0.6, true, true) doc: > - Additional settings for the mesh generation. If none are provided, default values will be used. + Additional settings for the mesh generation. If none are provided, default values will be used. doc: > Loads a new world with a basic 3D topology generated from the content of an OpenDRIVE file. This content is passed as a `string` parameter. It is similar to `client.load_world(map_name)` but allows for custom OpenDRIVE maps in server side. @@ -255,7 +255,7 @@ - class_name: TrafficManager # - DESCRIPTION ------------------------ doc: > - The traffic manager is a module built on top of the CARLA API in C++. It handles any group of vehicles set to autopilot mode to populate the simulation with realistic urban traffic conditions and give the chance to user to customize some behaviours. The architecture of the traffic manager is divided in five different goal-oriented stages and a PID controller where the information flows until eventually, a carla.VehicleControl is applied to every vehicle registered in a traffic manager. + The traffic manager is a module built on top of the CARLA API in C++. It handles any group of vehicles set to autopilot mode to populate the simulation with realistic urban traffic conditions and give the chance to user to customize some behaviours. The architecture of the traffic manager is divided in five different goal-oriented stages and a PID controller where the information flows until eventually, a carla.VehicleControl is applied to every vehicle registered in a traffic manager. In order to learn more, visit the [documentation](adv_traffic_manager.md) regarding this module. # - PROPERTIES ------------------------- @@ -334,7 +334,7 @@ doc: > Percentage difference between intended speed and the current limit. doc: > - 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. + 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. # -------------------------------------- @@ -392,7 +392,7 @@ doc: > Percentage difference between intended speed and the current limit. doc: > - 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. + 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. # -------------------------------------- @@ -400,7 +400,7 @@ params: return: uint16 doc: > - 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. + 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. # -------------------------------------- - def_name: set_hybrid_physics_mode params: @@ -408,9 +408,9 @@ type: bool default: False doc: > - If __True__, enables the hybrid physics. + If __True__, enables the hybrid physics. doc: > - Enables or disables the hybrid physics mode. In this mode, vehicle's farther than a certain radius from the ego vehicle will have their physics disabled. Computation cost will be reduced by not calculating vehicle dynamics. Vehicles will be teleported. + Enables or disables the hybrid physics mode. In this mode, vehicle's farther than a certain radius from the ego vehicle will have their physics disabled. Computation cost will be reduced by not calculating vehicle dynamics. Vehicles will be teleported. # -------------------------------------- - def_name: set_hybrid_mode_radius params: @@ -418,9 +418,9 @@ type: float default: 70.0 doc: > - New radius where physics are enabled. + New radius where physics are enabled. doc: > - With hybrid physics on, changes the radius of the area of influence where physics are enabled. + With hybrid physics on, changes the radius of the area of influence where physics are enabled. # -------------------------------------- - class_name: OpendriveGenerationParameters @@ -453,3 +453,7 @@ type: bool doc: > If __True__, the road mesh will be rendered. Setting this to __False__ should reduce the rendering overhead. __Default is `True`__. + - var_name: enable_pedestrian_navigation + type: bool + doc: > + If __True__, Pedestrian navigation will be enabled using Recast tool. For very large maps it is recomended to disable this option. __Default is `True`__. diff --git a/PythonAPI/docs/geom.yml b/PythonAPI/docs/geom.yml index 96c2d283c..e3136b5e7 100644 --- a/PythonAPI/docs/geom.yml +++ b/PythonAPI/docs/geom.yml @@ -4,17 +4,17 @@ - class_name: Vector2D # - DESCRIPTION ------------------------ doc: > - Helper class to perform 2D operations. + Helper class to perform 2D operations. # - PROPERTIES ------------------------- instance_variables: - var_name: x type: float doc: > - X-axis value. + X-axis value. - var_name: 'y' type: float doc: > - Y-axis value. + Y-axis value. # - METHODS ---------------------------- methods: - def_name: __init__ @@ -52,7 +52,7 @@ - param_name: other type: carla.Vector2D doc: > - Returns __True__ if values for every axis are equal. + Returns __True__ if values for every axis are equal. # -------------------------------------- - def_name: __ne__ return: bool @@ -60,18 +60,18 @@ - param_name: bool type: carla.Vector2D doc: > - Returns __True__ if the value for any axis is different. + Returns __True__ if the value for any axis is different. # -------------------------------------- - def_name: __str__ return: str doc: > - Returns the axis values for the vector parsed as string. + Returns the axis values for the vector parsed as string. # -------------------------------------- - class_name: Vector3D # - DESCRIPTION ------------------------ doc: > - Helper class to perform 3D operations. + Helper class to perform 3D operations. # - PROPERTIES ------------------------- instance_variables: - var_name: x @@ -134,12 +134,12 @@ type: carla.Vector3D return: bool doc: > - Returns __True__ if the value for any axis is different. + Returns __True__ if the value for any axis is different. # -------------------------------------- - def_name: __str__ return: str doc: > - Returns the axis values for the vector parsed as string. + Returns the axis values for the vector parsed as string. # -------------------------------------- - class_name: Location @@ -183,7 +183,7 @@ The other point to compute the distance with. return: float doc: > - Returns Euclidean distance in meters from this location to another one. + Returns Euclidean distance in meters from this location to another one. # -------------------------------------- - def_name: __eq__ return: bool @@ -191,7 +191,7 @@ - param_name: other type: carla.Location doc: > - Returns __True__ if both locations are the same point in space. + Returns __True__ if both locations are the same point in space. # -------------------------------------- - def_name: __ne__ return: bool @@ -199,12 +199,12 @@ - param_name: other type: carla.Location doc: > - Returns __True__ if both locations are different points in space. + Returns __True__ if both locations are different points in space. # -------------------------------------- - def_name: __str__ return: str doc: > - Parses the axis' values to string. + Parses the axis' values to string. # -------------------------------------- - class_name: Rotation @@ -247,13 +247,25 @@ type: float default: 0.0 doc: > - X rotation in degrees. + X rotation in degrees. # -------------------------------------- - def_name: get_forward_vector params: return: carla.Vector3D doc: > - Computes the vector pointing forward according to the orientation of each axis. + Computes the vector pointing forward according to the orientation of each axis. + # -------------------------------------- + - def_name: get_right_vector + params: + return: carla.Vector3D + doc: > + Computes the vector pointing to the right according to the orientation of each axis. + # -------------------------------------- + - def_name: get_up_vector + params: + return: carla.Vector3D + doc: > + Computes the vector pointing upwards according to the orientation of each axis. # -------------------------------------- - def_name: __eq__ return: bool @@ -261,7 +273,7 @@ - param_name: other type: carla.Rotation doc: > - Returns __True__ if both rotations represent the same orientation of each axis. + Returns __True__ if both rotations represent the same orientation of each axis. # -------------------------------------- - def_name: __ne__ params: @@ -269,27 +281,27 @@ type: carla.Rotation return: bool doc: > - Returns __True__ if both rotations represent the same orientation for every axis. - # -------------------------------------- + Returns __True__ if both rotations represent the same orientation for every axis. + # -------------------------------------- - def_name: __str__ doc: > - Parses the axis' orientations to string. + Parses the axis' orientations to string. # -------------------------------------- - class_name: Transform # - DESCRIPTION ------------------------ doc: > - Class that defines a transformation, a combination of location and rotation, without scaling. + Class that defines a transformation, a combination of location and rotation, without scaling. # - PROPERTIES ------------------------- instance_variables: - var_name: location type: carla.Location doc: > - Describes a point in the coordinate system. + Describes a point in the coordinate system. - var_name: rotation type: carla.Rotation doc: > - Describes a rotation for an object according to Unreal Engine's axis system. + Describes a rotation for an object according to Unreal Engine's axis system. # - METHODS ---------------------------- methods: - def_name: __init__ @@ -313,6 +325,16 @@ doc: > Computes a forward vector using its rotation. # -------------------------------------- + - def_name: get_right_vector + return: carla.Vector3D + doc: > + Computes a right vector using its rotation. + # -------------------------------------- + - def_name: get_up_vector + return: carla.Vector3D + doc: > + Computes an up vector using its rotation. + # -------------------------------------- - def_name: __eq__ return: bool params: @@ -332,21 +354,21 @@ - def_name: __str__ return: str doc: > - Parses both location and rotation to string. + Parses both location and rotation to string. # -------------------------------------- - class_name: BoundingBox # - DESCRIPTION ------------------------ doc: > - Helper class defining a box location and its dimensions that will later be used by carla.DebugHelper or a carla.Client to draw shapes and detect collisions. Bounding boxes normally act for object colliders. Check out this [recipe](ref_code_recipes.md#debug-bounding-box-recipe) where the user takes a snapshot of the world and then proceeds to draw bounding boxes for traffic lights. + Helper class defining a box location and its dimensions that will later be used by carla.DebugHelper or a carla.Client to draw shapes and detect collisions. Bounding boxes normally act for object colliders. Check out this [recipe](ref_code_recipes.md#debug-bounding-box-recipe) where the user takes a snapshot of the world and then proceeds to draw bounding boxes for traffic lights. # - PROPERTIES ------------------------- instance_variables: - var_name: extent type: carla.Vector3D doc: > - Vector from the center of the box to one vertex. The value in each axis equals half the size of the box for that axis. - - `extent.x * 2` would return the size of the box in the X-axis. + Vector from the center of the box to one vertex. The value in each axis equals half the size of the box for that axis. + + `extent.x * 2` would return the size of the box in the X-axis. - var_name: location type: carla.Location doc: > @@ -358,7 +380,7 @@ - param_name: location type: carla.Location doc: > - Point to center the box. + Point to center the box. - param_name: extent type: carla.Vector3D doc: > @@ -418,7 +440,7 @@ - class_name: GeoLocation # - DESCRIPTION ------------------------ doc: > - Class that contains geographical coordinates simulated data. The carla.Map can convert simulation locations by using the tag in the OpenDRIVE file. + Class that contains geographical coordinates simulated data. The carla.Map can convert simulation locations by using the tag in the OpenDRIVE file. # - PROPERTIES ------------------------- instance_variables: - var_name: latitude