From 74ea12357d666b3c39e1055c686898d95a1cd0d0 Mon Sep 17 00:00:00 2001 From: Corinne <38050983+corkyw10@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:22:19 +0200 Subject: [PATCH 001/105] Removed references to CarSim being in beta stage (#4501) --- Docs/index.md | 2 +- Docs/tuto_G_carsim_integration.md | 5 +---- mkdocs.yml | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Docs/index.md b/Docs/index.md index 5e101e92537..a89f3e5cb25 100644 --- a/Docs/index.md +++ b/Docs/index.md @@ -100,7 +100,7 @@ CARLA forum [__Control walker skeletons__](tuto_G_control_walker_skeletons.md) — Animate walkers using skeletons. [__Generate maps with OpenStreetMap__](tuto_G_openstreetmap.md) — Use OpenStreetMap to generate maps for use in simulations. [__Retrieve simulation data__](tuto_G_retrieve_data.md) — A step by step guide to properly gather data using the recorder. -[__CarSim Integration (Beta)__](tuto_G_carsim_integration.md) — Tutorial on how to run a simulation using the CarSim vehicle dynamics engine. +[__CarSim Integration__](tuto_G_carsim_integration.md) — Tutorial on how to run a simulation using the CarSim vehicle dynamics engine. [__RLlib Integration__](tuto_G_rllib_integration.md) — Find out how to run your own experiment using the RLlib library. [__Chrono Integration__](tuto_G_chrono.md) — Use the Chrono integration to simulation physics [__Build Unreal Engine and CARLA in Docker__](build_docker_unreal.md) — Build Unreal Engine and CARLA in Docker diff --git a/Docs/tuto_G_carsim_integration.md b/Docs/tuto_G_carsim_integration.md index 78625e7a0ea..c828fc6f617 100644 --- a/Docs/tuto_G_carsim_integration.md +++ b/Docs/tuto_G_carsim_integration.md @@ -1,12 +1,9 @@ -# CarSim Integration (Beta) +# CarSim Integration CARLA's integration with CarSim allows vehicle controls in CARLA to be forwarded to CarSim. CarSim will do all required physics calculations of the vehicle and return the new state to CARLA. This page shows you how to generate a `.sim` file, explains how vehicle dimensions relate between CARLA and CarSim and how to run a simulation on CARLA using the CarSim integration. -!!! Warning - This feature is in beta release. This means that development of the feature is ongoing and some aspects of the feature may not work as expected. If you come across any problems feel free to open an issue on [GitHub](https://github.com/carla-simulator/carla). - * [__Before you begin__](#before-you-begin) * [__Set up CarSim__](#set-up-carsim) * [__Generate the .sim file__](#generate-the-sim-file) diff --git a/mkdocs.yml b/mkdocs.yml index 1d0161fd346..a4d293e0c78 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -71,7 +71,7 @@ nav: - 'Control walker skeletons': "tuto_G_control_walker_skeletons.md" - 'Generate maps with OpenStreetMap': 'tuto_G_openstreetmap.md' - 'Retrieve simulation data': "tuto_G_retrieve_data.md" - - 'CarSim Integration (Beta)': "tuto_G_carsim_integration.md" + - 'CarSim Integration': "tuto_G_carsim_integration.md" - 'RLlib Integration': "tuto_G_rllib_integration.md" - 'Chrono Integration': 'tuto_G_chrono.md' - 'Build Unreal and CARLA in Docker': 'build_docker_unreal.md' From fee6a749f514c7ee751253e2672ebd8d1261a9a8 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Fri, 6 Aug 2021 10:56:41 +0200 Subject: [PATCH 002/105] Exposed some vector functions to the python api --- CHANGELOG.md | 5 +++ Docs/python_api.md | 55 +++++++++++++++++++++++- PythonAPI/carla/source/libcarla/Geom.cpp | 41 ++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb8dde331a6..9f448dbf4b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Latest + + * Added API functions to 3D vectors: `squared_length`, `length`, `make_unit_vector`, `dot`, `dot_2d`, `distance`, `distance_2d`, `distance_squared`, `distance_squared_2d`, `get_vector_angle` + * Added API functions to 2D vectors: `squared_length`, `length`, `make_unit_vector` + ## CARLA 0.9.12 * Changed the resolution of the cached map in Traffic Manager from 0.1 to 5 meters diff --git a/Docs/python_api.md b/Docs/python_api.md index 1fef3aa4e54..692d0c8addb 100644 --- a/Docs/python_api.md +++ b/Docs/python_api.md @@ -2390,6 +2390,15 @@ Y-axis value. - **Parameters:** - `x` (_float_) - `y` (_float_) +- **squared_length**(**self**) +Computes the squared length of the vector. + - **Return:** _float_ +- **length**(**self**) +Computes the length of the vector. + - **Return:** _float_ +- **make_unit_vector**(**self**) +Returns a vector with the same direction and unitary length. + - **Return:** _[carla.Vector2D](#carla.Vector2D)_ ##### Dunder methods - **\__add__**(**self**, **other**=[carla.Vector2D](#carla.Vector2D)) @@ -2425,6 +2434,50 @@ Z-axis value. - `x` (_float_) - `y` (_float_) - `z` (_float_) +- **length**(**self**) +Computes the length of the vector. + - **Return:** _float_ +- **squared_length**(**self**) +Computes the squared length of the vector. + - **Return:** _float_ +- **make_unit_vector**(**self**) +Returns a vector with the same direction and unitary length. + - **Return:** _[carla.Vector3D](#carla.Vector3D)_ +- **dot**(**self**, **vector**) +Computes the dot product between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **distance**(**self**, **vector**) +Computes the distance between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **distance_squared**(**self**, **vector**) +Computes the squared distance between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **dot_2d**(**self**, **vector**) +Computes the 2-dimensional dot product between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **distance_2d**(**self**, **vector**) +Computes the 2-dimensional distance between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **distance_squared_2d**(**self**, **vector**) +Computes the 2-dimensional squared distance between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **get_vector_angle**(**self**, **vector**) +Computes the angle between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ ##### Dunder methods - **\__abs__**(**self**) @@ -4149,4 +4202,4 @@ for (let i = 0; i < buttons.length; i++) { buttons[i].addEventListener("click",function(){ButtonAction(buttons[i].id);},true); } window.onresize = WindowResize; - \ No newline at end of file + diff --git a/PythonAPI/carla/source/libcarla/Geom.cpp b/PythonAPI/carla/source/libcarla/Geom.cpp index 19cb10fb939..81ec434deeb 100644 --- a/PythonAPI/carla/source/libcarla/Geom.cpp +++ b/PythonAPI/carla/source/libcarla/Geom.cpp @@ -103,6 +103,34 @@ static auto GetInverseTransformMatrix(const carla::geom::Transform &self) { return BuildMatrix(self.GetInverseMatrix()); } +static auto Dot(const carla::geom::Vector3D &self, const carla::geom::Vector3D &other) { + return carla::geom::Math::Dot(self, other); +} + +static auto Distance(const carla::geom::Vector3D &self, const carla::geom::Vector3D &other) { + return carla::geom::Math::Distance(self, other); +} + +static auto DistanceSquared(const carla::geom::Vector3D &self, const carla::geom::Vector3D &other) { + return carla::geom::Math::DistanceSquared(self, other); +} + +static auto Dot2D(const carla::geom::Vector3D &self, const carla::geom::Vector3D &other) { + return carla::geom::Math::Dot2D(self, other); +} + +static auto Distance2D(const carla::geom::Vector3D &self, const carla::geom::Vector3D &other) { + return carla::geom::Math::Distance2D(self, other); +} + +static auto DistanceSquared2D(const carla::geom::Vector3D &self, const carla::geom::Vector3D &other) { + return carla::geom::Math::DistanceSquared2D(self, other); +} + +static auto GetVectorAngle(const carla::geom::Vector3D &self, const carla::geom::Vector3D &other) { + return carla::geom::Math::GetVectorAngle(self, other); +} + void export_geom() { using namespace boost::python; namespace cg = carla::geom; @@ -115,6 +143,9 @@ void export_geom() { .def(init((arg("x")=0.0f, arg("y")=0.0f))) .def_readwrite("x", &cg::Vector2D::x) .def_readwrite("y", &cg::Vector2D::y) + .def("squared_length", &cg::Vector2D::SquaredLength) + .def("length", &cg::Vector2D::Length) + .def("make_unit_vector", &cg::Vector2D::MakeUnitVector) .def("__eq__", &cg::Vector2D::operator==) .def("__ne__", &cg::Vector2D::operator!=) .def(self += self) @@ -139,6 +170,16 @@ void export_geom() { .def_readwrite("x", &cg::Vector3D::x) .def_readwrite("y", &cg::Vector3D::y) .def_readwrite("z", &cg::Vector3D::z) + .def("length", &cg::Vector3D::Length) + .def("squared_length", &cg::Vector3D::SquaredLength) + .def("make_unit_vector", &cg::Vector3D::MakeUnitVector) + .def("dot", &Dot, (arg("vector"))) + .def("dot_2d", &Dot2D, (arg("vector"))) + .def("distance", &Distance, (arg("vector"))) + .def("distance_2d", &Distance2D, (arg("vector"))) + .def("distance_squared", &DistanceSquared, (arg("vector"))) + .def("distance_squared_2d", &DistanceSquared2D, (arg("vector"))) + .def("get_vector_angle", &GetVectorAngle, (arg("vector"))) .def("__eq__", &cg::Vector3D::operator==) .def("__ne__", &cg::Vector3D::operator!=) .def("__abs__", &cg::Vector3D::Abs) From f90c2c612311baa1fc5a80800e4945813e58f7ef Mon Sep 17 00:00:00 2001 From: Guillermo Date: Fri, 6 Aug 2021 12:24:14 +0200 Subject: [PATCH 003/105] Added ymls and Cross C++ function --- Docs/python_api.md | 490 +++++++++++------------ LibCarla/source/carla/geom/Math.h | 4 + PythonAPI/carla/source/libcarla/Geom.cpp | 5 + PythonAPI/docs/geom.yml | 98 ++++- 4 files changed, 349 insertions(+), 248 deletions(-) diff --git a/Docs/python_api.md b/Docs/python_api.md index 692d0c8addb..be121def953 100644 --- a/Docs/python_api.md +++ b/Docs/python_api.md @@ -2390,15 +2390,15 @@ Y-axis value. - **Parameters:** - `x` (_float_) - `y` (_float_) -- **squared_length**(**self**) -Computes the squared length of the vector. - - **Return:** _float_ -- **length**(**self**) -Computes the length of the vector. - - **Return:** _float_ -- **make_unit_vector**(**self**) -Returns a vector with the same direction and unitary length. - - **Return:** _[carla.Vector2D](#carla.Vector2D)_ +- **length**(**self**) +Computes the length of the vector. + - **Return:** _float_ +- **make_unit_vector**(**self**) +Returns a vector with the same direction and unitary length. + - **Return:** _[carla.Vector3D](#carla.Vector3D)_ +- **squared_length**(**self**) +Computes the squared length of the vector. + - **Return:** _float_ ##### Dunder methods - **\__add__**(**self**, **other**=[carla.Vector2D](#carla.Vector2D)) @@ -2434,50 +2434,50 @@ Z-axis value. - `x` (_float_) - `y` (_float_) - `z` (_float_) -- **length**(**self**) -Computes the length of the vector. - - **Return:** _float_ -- **squared_length**(**self**) -Computes the squared length of the vector. - - **Return:** _float_ -- **make_unit_vector**(**self**) -Returns a vector with the same direction and unitary length. - - **Return:** _[carla.Vector3D](#carla.Vector3D)_ -- **dot**(**self**, **vector**) -Computes the dot product between two vectors. - - **Parameters:** - - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - - **Return:** _float_ -- **distance**(**self**, **vector**) -Computes the distance between two vectors. - - **Parameters:** - - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - - **Return:** _float_ -- **distance_squared**(**self**, **vector**) -Computes the squared distance between two vectors. - - **Parameters:** - - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - - **Return:** _float_ -- **dot_2d**(**self**, **vector**) -Computes the 2-dimensional dot product between two vectors. - - **Parameters:** - - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - - **Return:** _float_ -- **distance_2d**(**self**, **vector**) -Computes the 2-dimensional distance between two vectors. - - **Parameters:** - - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - - **Return:** _float_ -- **distance_squared_2d**(**self**, **vector**) -Computes the 2-dimensional squared distance between two vectors. - - **Parameters:** - - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - - **Return:** _float_ -- **get_vector_angle**(**self**, **vector**) -Computes the angle between two vectors. - - **Parameters:** - - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - - **Return:** _float_ +- **cross**(**self**, **vector**) +Computes the cross product between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _[carla.Vector3D](#carla.Vector3D)_ +- **distance**(**self**, **vector**) +Computes the distance between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **distance_2d**(**self**, **vector**) +Computes the 2-dimensional distance between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **distance_squared**(**self**, **vector**) +Computes the squared distance between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **distance_squared_2d**(**self**, **vector**) +Computes the 2-dimensional squared distance between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **dot**(**self**, **vector**) +Computes the dot product between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **dot_2d**(**self**, **vector**) +Computes the 2-dimensional dot product between two vectors. + - **Parameters:** + - `vector` (_[carla.Vector3D](#carla.Vector3D)_) + - **Return:** _float_ +- **length**(**self**) +Computes the length of the vector. + - **Return:** _float_ +- **make_unit_vector**(**self**) +Returns a vector with the same direction and unitary length. + - **Return:** _[carla.Vector3D](#carla.Vector3D)_ +- **squared_length**(**self**) +Computes the squared length of the vector. + - **Return:** _float_ ##### Dunder methods - **\__abs__**(**self**) @@ -3740,90 +3740,6 @@ print("R lane marking change: " + str(waypoint.right_lane_marking.lane_change)) -