From 959d255b4fab67dce1ab204f9504ed033d0a7416 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 23 Aug 2024 15:53:09 -0700 Subject: [PATCH 1/9] Remove eigen/include/ignition headers (#624) Signed-off-by: Steve Peters --- eigen3/include/CMakeLists.txt | 1 - eigen3/include/ignition/math/eigen3.hh | 19 ------------------- .../ignition/math/eigen3/Conversions.hh | 19 ------------------- eigen3/include/ignition/math/eigen3/Util.hh | 19 ------------------- 4 files changed, 58 deletions(-) delete mode 100644 eigen3/include/ignition/math/eigen3.hh delete mode 100644 eigen3/include/ignition/math/eigen3/Conversions.hh delete mode 100644 eigen3/include/ignition/math/eigen3/Util.hh diff --git a/eigen3/include/CMakeLists.txt b/eigen3/include/CMakeLists.txt index 992a1312e..a35a0475e 100644 --- a/eigen3/include/CMakeLists.txt +++ b/eigen3/include/CMakeLists.txt @@ -1,2 +1 @@ add_subdirectory(gz) -install(DIRECTORY ignition DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}) diff --git a/eigen3/include/ignition/math/eigen3.hh b/eigen3/include/ignition/math/eigen3.hh deleted file mode 100644 index f0a14b78e..000000000 --- a/eigen3/include/ignition/math/eigen3.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/eigen3/include/ignition/math/eigen3/Conversions.hh b/eigen3/include/ignition/math/eigen3/Conversions.hh deleted file mode 100644 index bab4a3f07..000000000 --- a/eigen3/include/ignition/math/eigen3/Conversions.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2022 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include diff --git a/eigen3/include/ignition/math/eigen3/Util.hh b/eigen3/include/ignition/math/eigen3/Util.hh deleted file mode 100644 index 962463fa3..000000000 --- a/eigen3/include/ignition/math/eigen3/Util.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2022 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include From 887e763ab875382c6f2c0a2da8f51e6de920ce72 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 23 Aug 2024 17:10:43 -0700 Subject: [PATCH 2/9] README: update main branch references to gz-math8 (#622) Signed-off-by: Steve Peters Co-authored-by: Addisu Z. Taddese --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0cf0dffad..73acc5e75 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Build | Status -- | -- -Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-math/branch/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-math/branch/main) -Ubuntu Noble | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_math-ci-main-noble-amd64)](https://build.osrfoundation.org/job/gz_math-ci-main-noble-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_math-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/gz_math-ci-main-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_math-main-win)](https://build.osrfoundation.org/job/gz_math-main-win) +Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-math/branch/gz-math8/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-math/tree/gz-math8) +Ubuntu Noble | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_math-ci-gz-math8-noble-amd64)](https://build.osrfoundation.org/job/gz_math-ci-gz-math8-noble-amd64) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_math-ci-gz-math8-homebrew-amd64)](https://build.osrfoundation.org/job/gz_math-ci-gz-math8-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_math-8-win)](https://build.osrfoundation.org/job/gz_math-8-win) Gazebo Math, a component of [Gazebo](https://gazebosim.org), provides general purpose math classes and functions designed for robotic applications. @@ -47,11 +47,11 @@ Math types. # Install -See the [installation tutorial](https://gazebosim.org/api/math/7/install.html). +See the [installation tutorial](https://gazebosim.org/api/math/8/install.html). # Usage -Please refer to the [examples directory](https://github.com/gazebosim/gz-math/raw/main/examples/). +Please refer to the [examples directory](https://github.com/gazebosim/gz-math/raw/gz-math8/examples/). # Folder Structure @@ -90,4 +90,4 @@ This library uses [Semantic Versioning](https://semver.org/). Additionally, this # License -This library is licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0). See also the [LICENSE](https://github.com/gazebosim/gz-math/blob/main/LICENSE) file. +This library is licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0). See also the [LICENSE](https://github.com/gazebosim/gz-math/blob/gz-math8/LICENSE) file. From 6438a9998d4914b67d554493da7f3fdd3cff15f3 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 23 Aug 2024 18:00:35 -0700 Subject: [PATCH 3/9] Prepare for 8.0.0 pre1 release (#625) Signed-off-by: Ian Chen --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9fc1f82a..5e1263c93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(GZ_CMAKE_VER ${gz-cmake4_VERSION_MAJOR}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -gz_configure_project(VERSION_SUFFIX) +gz_configure_project(VERSION_SUFFIX pre1) #============================================================================ # Set project-specific options From f1d6a56982c54514e3166b50807fec15786c8c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Tue, 3 Sep 2024 17:10:55 +0200 Subject: [PATCH 4/9] Tutorial cleanup (#628) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- tutorials/angle.md | 122 ---------------------------- tutorials/color.md | 2 +- tutorials/example_triangle.md | 2 +- tutorials/rotation.md | 104 ------------------------ tutorials/triangle.md | 72 ----------------- tutorials/vector.md | 145 ---------------------------------- 6 files changed, 2 insertions(+), 445 deletions(-) delete mode 100644 tutorials/angle.md delete mode 100644 tutorials/rotation.md delete mode 100644 tutorials/triangle.md delete mode 100644 tutorials/vector.md diff --git a/tutorials/angle.md b/tutorials/angle.md deleted file mode 100644 index ad468160e..000000000 --- a/tutorials/angle.md +++ /dev/null @@ -1,122 +0,0 @@ -\page angle Angle example - -This tutorial explains how to use the `Angle` class from Gazebo Math library. - -## C++ example - -### Compile the code - -Go to `gz-math/examples` and use `cmake` to compile the code: - -```{.sh} -git clone https://github.com/gazebosim/gz-math/ -b gz-math8 -cd gz-math/examples -mkdir build -cd build -cmake .. -make -``` - -When the code is compiled, run: - -```{.sh} -./angle_example -``` - -The ouput of the program: - -```{.sh} -The angle 'a' should be zero: 0 -Pi in radians: 3.14159 -Pi in degrees: 180 -Pi + PI/2 in radians: 4.71239 -Normalized to the range -Pi and Pi: -1.5708 -``` - -### Code - -The code instantiates an angle class. The default constructed angle should be zero. - -\snippet examples/angle_example.cc Create an angle - -There are some predefined angles, such as: - -\snippet examples/angle_example.cc constant pi - -By default, all values are in radians, but you can use the method `Degree` to convert to degrees. - -\snippet examples/angle_example.cc Output the angle in radians and degrees. - -The `Angle` class overloads the `+=`, and many other, math operators. - -\snippet examples/angle_example.cc The Angle class overloads the +=, and many other, math operators. - -Use the method `Normalized` to bound the value between `-PI` and `PI`. - -\snippet examples/angle_example.cc normalized - -## Ruby example - -This example will only work if the Ruby interface library was compiled and installed. For example, -on Ubuntu: - -```{.sh} -sudo apt install ruby-gz-math<#> -``` - -Modify the `RUBYLIB` environment variable to include the Gazebo Math library install path. For example, if you install to `/usr`: - -```{.sh} -export RUBYLIB=/usr/lib/ruby:$RUBYLIB -``` - -Move to the examples folder: - -```{.sh} -cd examples -``` - -Execute the code: - -```{.sh} -ruby angle_example.rb -``` - -### Code - -There are some predefined values: - -```{.rb} -printf("PI in degrees = %f\n", Gz::Math::Angle.Pi.Degree) -``` - -Create new objects: - -```{.rb} -a1 = Gz::Math::Angle.new(1.5707) -a2 = Gz::Math::Angle.new(0.7854) -``` - -Use the values in radians or degrees: - -```{.rb} -printf("a1 = %f radians, %f degrees\n", a1.Radian, a1.Degree) -printf("a2 = %f radians, %f degrees\n", a2.Radian, a2.Degree) -``` - -The `Angle` class overloads math operators. - -```{.rb} -printf("a1 * a2 = %f radians, %f degrees\n", (a1 * a2).Radian, (a1 * a2).Degree) -printf("a1 + a2 = %f radians, %f degrees\n", (a1 + a2).Radian, (a1 + a2).Degree) -printf("a1 - a2 = %f radians, %f degrees\n", (a1 - a2).Radian, (a1 - a2).Degree) -``` - -Normalize the value between `-PI` and `PI`. - -```{.rb} -a3 = Gz::Math::Angle.new(15.707) -printf("a3 = %f radians, %f degrees\n", a3.Radian, a3.Degree) -a3.Normalize -printf("a3.Normalize = %f radians, %f degrees\n", a3.Radian, a3.Degree) -``` diff --git a/tutorials/color.md b/tutorials/color.md index 92ea8a3f0..b209309b1 100644 --- a/tutorials/color.md +++ b/tutorials/color.md @@ -54,4 +54,4 @@ You can also set or read a color in HSV. \snippet examples/color_example.cc Set value from HSV -There are more functions in `Color`. Take a look at the [API](https://gazebosim.org/api/math/7/classgz_1_1math_1_1Color.html) +There are more functions in `Color`. Take a look at the [API](https://gazebosim.org/api/math/8/classgz_1_1math_1_1Color.html) diff --git a/tutorials/example_triangle.md b/tutorials/example_triangle.md index 9d931ccde..2226a12cc 100644 --- a/tutorials/example_triangle.md +++ b/tutorials/example_triangle.md @@ -69,4 +69,4 @@ The `Intersects` function checks if a line segment intersects the triangle. It a \snippet examples/triangle_example.cc intersect -There are more functions in `Triangle`. Take a look at the [API](https://gazebosim.org/api/math/7/) +There are more functions in `Triangle`. Take a look at the [API](https://gazebosim.org/api/math/8/) diff --git a/tutorials/rotation.md b/tutorials/rotation.md deleted file mode 100644 index 7bcdb0681..000000000 --- a/tutorials/rotation.md +++ /dev/null @@ -1,104 +0,0 @@ -\page rotation Rotation example - -This example explains how to use quaternions and euler angles, and how to convert between them. - -## Compiling and running the code - -Go to `gz-math/examples` and use `cmake` to compile the code: - -```{.sh} -git clone https://github.com/gazebosim/gz-math/ -b gz-math8 -cd gz-math/examples -mkdir build -cd build -cmake .. -make -``` - -When the code is compiled, you can run two different examples, one which converts from quaternion to euler angles: - -```{.sh} -Usage: - ./quaternion_to_euler - -Example - ./quaternion_to_euler 0.5 0.5 0.5 0.5 -``` - -And the other which converts from euler to quaternion: - -```{.sh} -Usage (angles specified in radians): - quaternion_from_euler - -Example - quaternion_from_euler 0 0 1.57 -``` - -The ouput of each program, respectively: - -```{.sh} -./quaternion_to_euler 0.5 0.5 0.5 0.5 -Normalizing Quaternion components: - W 0.5 - X 0.5 - Y 0.5 - Z 0.5 -to - W 0.5 - X 0.5 - Y 0.5 - Z 0.5 - -Converting to Euler angles - roll 1.570796 radians - pitch -0.000000 radians - yaw 1.570796 radians - - roll 90.000000 degrees - pitch -0.000000 degrees - yaw 90.000000 degrees - -to Rotation matrix - 0.000000 0.000000 1.000000 - 1.000000 0.000000 0.000000 - 0.000000 1.000000 0.000000 -``` - -```{.sh} -./quaternion_from_euler 0 0 1.57 -Converting Euler angles: - roll 0.000000 radians - pitch 0.000000 radians - yaw 1.570000 radians - - roll 0.000000 degrees - pitch 0.000000 degrees - yaw 89.954374 degrees - -to Quaternion - W 0.707388 - X 0.000000 - Y 0.000000 - Z 0.706825 - -to Rotation matrix - 0.000796 -1.000000 0.000000 - 1.000000 0.000796 0.000000 - 0.000000 0.000000 1.000000 -``` - -## Code - -You can create some objects to express rotations: - -\snippet examples/quaternion_from_euler.cc constructor -\snippet examples/quaternion_to_euler.cc constructor - -To access the quaterions attributes: - -\snippet examples/quaternion_from_euler.cc access quaterion - -Or to acccess the rotation matrix elements: - -\snippet examples/quaternion_from_euler.cc rotation matrix diff --git a/tutorials/triangle.md b/tutorials/triangle.md deleted file mode 100644 index a2580cce0..000000000 --- a/tutorials/triangle.md +++ /dev/null @@ -1,72 +0,0 @@ -\page triangle Triangle example - -This tutorial explains how to use the `Triangle` class from Gazebo Math library. - -## Compile the code - -Go to `gz-math/examples` and use `cmake` to compile the code: - -```{.sh} -git clone https://github.com/gazebosim/gz-math/ -b gz-math8 -cd gz-math/examples -mkdir build -cd build -cmake .. -make -``` - -When the code is compiled, run: - -```{.sh} -./triangle_example -``` - -The ouput of the program: - -```{.sh} -Vertex 1: -1 0 -Vertex 2: 0 1 -Vertex 3: 1 0 -Side 1: -1 0 0 1 -Side 2: 0 1 1 0 -Side 3: 1 0 -1 0 -Perimeter=4.82843 Area=1 -Triangle contains the point 0, 0.5 -A line from (-2, 0.5) to (2, 0.5) intersects the triangle at the -following points: - Pt1=-0.5 0.5 - Pt2=0.5 0.5 -``` - -## Code - -Create a triangle with the following vertices: - -\snippet examples/triangle_example.cc constructor - -The individual vertices are accessible through the `[]` operator. - -\snippet examples/triangle_example.cc access1 - -Each side of the triangle is also accessible via the `Side` method. Each side consists of 2 vertices, the following code will print out the X and Y values of each vertex. - -\snippet examples/triangle_example.cc access2 - -It's also possible to set each vertex individually or set all the vertices at once. - -\snippet examples/triangle_example.cc vertex1 -\snippet examples/triangle_example.cc vertex2 - -You can get the perimeter length and area of the triangle - -\snippet examples/triangle_example.cc perimeter and area - -The `Contains` function checks if a line or point is inside the triangle. - -\snippet examples/triangle_example.cc contains - -The `Intersects` function checks if a line segment intersects the triangle. It also returns the points of intersection. - -\snippet examples/triangle_example.cc intersect - -There are more functions in `Triangle`. Take a look at the [API](https://gazebosim.org/api/math/6.4/index.html) diff --git a/tutorials/vector.md b/tutorials/vector.md deleted file mode 100644 index f32df1353..000000000 --- a/tutorials/vector.md +++ /dev/null @@ -1,145 +0,0 @@ -\page vector Vector example - -This tutorial explains how to use the `Vector` classes from Gazebo Math library. - -## C++ example - -### Compile the code - -To compile the code, go to `gz-math/examples` and use `cmake`: - -```{.sh} -git clone https://github.com/gazebosim/gz-math/ -b gz-math8 -cd gz-math/examples -mkdir build -cd build -cmake .. -make -``` - -When the code is compiled, run: - -```{.sh} -./vector2_example -``` - -The ouput of the program: - -```{.sh} -Vec2: 2 4 -Vec2a: 1 2 -Vec2b: 1.2 3.4 -Vec2: x=2 y=4 -Vec2a: x=1 y=2 -Vec2b: x=1.2 y=3.4 -4 -2 8 -3 6 -1 2 -2 2 -2.23607 -``` - -### Code - -Create a `Vector2` called `vec2` of doubles using the typedef `Vector2d`. **The initial x and y values are zero**. The x and y component of `vec2` can be set at anytime. - -\snippet examples/vector2_example.cc constructor - - -The `Vector2` class is a template, so you can also create a `Vector2` using `gz::math::Vector2`: - -\snippet examples/vector2_example.cc constructor2 - -It's also possible to set initial values. Here we are using a `Vector2` of floats: - -\snippet examples/vector2_example.cc constructor3 - -We can output the contents of each vector using `std::cout`. - -\snippet examples/vector2_example.cc stdout - -You can also get access to each component in the vector using the `X()`, `Y()` accessors or the `[]` operator, The operator is clamped to the range `[0, 1]`. - -\snippet examples/vector2_example.cc access - -The `Vector2` class overloads many common operators, such as: - -\snippet examples/vector2_example.cc operators - -There are also many useful function such as finding the distance between two vectors. - -\snippet examples/vector2_example.cc distance - -**There are more functions in Vector2. Take a look at the [API](https://gazebosim.org/libs/math)** - -## Ruby examples - -This example will only work if the Ruby interface library was compiled and installed. For example, -on Ubuntu: - -```{.sh} -sudo apt install ruby-gz-math<#> -``` - -Modify the `RUBYLIB` environment variable to include the Gazebo Math library install path. For example, if you install to `/usr`: - -```{.sh} -export RUBYLIB=/usr/lib/ruby:$RUBYLIB -``` - -Move to the examples folder: - -```{.sh} -cd examples -``` - -Execute the examples: - -```{.sh} -ruby vector2_example.rb -ruby vector3_example.rb -``` - -### Code - -Create a `Vector2` of doubles using the typedef `Vector2d`. It's possible to set initial values or use another object to create a identical copy. - -```{.rb} -va = Gz::Math::Vector2d.new(1, 2) -``` - -You can get access to each component in the vector using the `X()`, `Y()` accessors. - -```{.rb} -printf("va = %f %f\n", va.X(), va.Y()) -printf("vb = %f %f\n", vb.X(), vb.Y()) -printf("vc = %f %f\n", vc.X(), vc.Y()) -``` - -The `Vector2` class overloads many common operators, such as: - -```{.rb} -vb += va -printf("vb += va: %f %f\n", vb.X(), vb.Y()) -``` - -There are also many useful functions, such as finding the distance between two vectors or normalizing a vector. - -```{.rb} -vb.Normalize -printf("vb.Normalize = %f %f\n", vb.X(), vb.Y()) -printf("vb.Distance(va) = %f\n", vb.Distance(va)) -``` - -You can create vectors with 3 dimensions using the typedef `Vector3d`: - -```{.rb} -v1 = Gz::Math::Vector3d.new(0, 0, 0) -``` - -You can also get access to each component in the vector using the `X()`, `Y()` and `Z()` accessors: - -```{.rb} -printf("v =: %f %f %f\n", v1.X(), v1.Y(), v1.Z()) -``` From accae3a655be118ccb8cab61f26c1f7af6dd4f09 Mon Sep 17 00:00:00 2001 From: Nikos Tziaros <33639811+NickTziaros@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:41:30 +0200 Subject: [PATCH 5/9] gz-math: Vector example #1371 (#629) Signed-off-by: Nikos Tziaros <33639811+NickTziaros@users.noreply.github.com> --- examples/vector3_example.py | 2 +- examples/vector3_example.rb | 2 +- tutorials/example_vector2.md | 65 +++++++++++++++++++++++++----------- 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/examples/vector3_example.py b/examples/vector3_example.py index b573da4ab..ffecc3786 100644 --- a/examples/vector3_example.py +++ b/examples/vector3_example.py @@ -23,7 +23,7 @@ import gz.math8 v1 = gz.math8.Vector3d(0, 0, 3) -print("v =: {} {} {}\n".format(v1.x(), v1.y(), v1.z())) +print("v1 = {} {} {}\n".format(v1.x(), v1.y(), v1.z())) v2 = gz.math8.Vector3d(4, 0, 0) print("v2 = {} {} {}\n".format(v2.x(), v2.y(), v2.z())) diff --git a/examples/vector3_example.rb b/examples/vector3_example.rb index 55f675a63..ca330720f 100644 --- a/examples/vector3_example.rb +++ b/examples/vector3_example.rb @@ -23,7 +23,7 @@ require 'gz/math' v1 = Gz::Math::Vector3d.new(0, 0, 0) -printf("v =: %f %f %f\n", v1.X(), v1.Y(), v1.Z()) +printf("v1 = %f %f %f\n", v1.X(), v1.Y(), v1.Z()) v2 = Gz::Math::Vector3d.new(1, 0, 0) printf("v2 = %f %f %f\n", v2.X(), v2.Y(), v2.Z()) diff --git a/tutorials/example_vector2.md b/tutorials/example_vector2.md index f16216910..b34df1e84 100644 --- a/tutorials/example_vector2.md +++ b/tutorials/example_vector2.md @@ -8,7 +8,7 @@ This tutorial explains how to use the `Vector2` class from Gazebo Math library. To compile the code, go to `gz-math/examples` and use `cmake`: -```{.sh} +```bash git clone https://github.com/gazebosim/gz-math/ -b gz-math8 cd gz-math/examples mkdir build @@ -19,13 +19,13 @@ make When the code is compiled, run: -```{.sh} +```bash ./vector2_example ``` -The ouput of the program: +The output of the program: -```{.sh} +```bash Vec2: 2 4 Vec2a: 1 2 Vec2b: 1.2 3.4 @@ -42,7 +42,7 @@ Vec2b: x=1.2 y=3.4 ### Code -Create a `Vector2` called `vec2` of doubles using the typedef `Vector2d`. **The initial x and y values are zero**. The x and y component of `vec2` can be set at anytime. +Create a `Vector2` called `vec2` of doubles using the typedef `Vector2d`. **The initial x and y values are zero**. The x and y components of `vec2` can be set at anytime. \snippet examples/vector2_example.cc constructor @@ -67,7 +67,7 @@ The `Vector2` class overloads many common operators, such as: \snippet examples/vector2_example.cc operators -There are also many useful function such as finding the distance between two vectors. +There are also many useful functions, such as finding the distance between two vectors. \snippet examples/vector2_example.cc distance @@ -78,40 +78,67 @@ There are also many useful function such as finding the distance between two vec This example will only work if the Ruby interface library was compiled and installed. For example, on Ubuntu: -```{.sh} +```bash sudo apt install ruby-gz-math<#> ``` +Be sure to replace <#> with a number value, such as 8 or 7, depending on which version you need.<#>. + Modify the `RUBYLIB` environment variable to include the Gazebo Math library install path. For example, if you install to `/usr`: -```{.sh} +```bash export RUBYLIB=/usr/lib/ruby:$RUBYLIB ``` Move to the examples folder: -```{.sh} +```bash cd examples ``` -Execute the examples: +Execute the example: -```{.sh} +```bash ruby vector2_example.rb +``` + +The output of the program: + +```bash +va = 1.000000 2.000000 +vb = 3.000000 4.000000 +vc = 3.000000 4.000000 +vb += va: 4.000000 6.000000 +vb.Normalize = 0.554700 0.832050 +vb.Distance(va) = 1.249959 +``` + +Execute the example: + +```bash ruby vector3_example.rb ``` +The output of the program: + +```bash +v1 = 0.000000 0.000000 0.000000 +v2 = 1.000000 0.000000 0.000000 +v1 + v2 = 1.000000 0.000000 0.000000 +v1.Distance(v2) = 1.000000 +``` + ### Code -Create a `Vector2` of doubles using the typedef `Vector2d`. It's possible to set initial values or use another object to create a identical copy. +Create a `Vector2` of doubles using the typedef `Vector2d`. It's possible to set initial values or use another object to create an identical copy. -```{.rb} +```bash va = Gz::Math::Vector2d.new(1, 2) ``` You can get access to each component in the vector using the `X()`, `Y()` accessors. -```{.rb} +```bash printf("va = %f %f\n", va.X(), va.Y()) printf("vb = %f %f\n", vb.X(), vb.Y()) printf("vc = %f %f\n", vc.X(), vc.Y()) @@ -119,14 +146,14 @@ printf("vc = %f %f\n", vc.X(), vc.Y()) The `Vector2` class overloads many common operators, such as: -```{.rb} +```bash vb += va printf("vb += va: %f %f\n", vb.X(), vb.Y()) ``` There are also many useful functions, such as finding the distance between two vectors or normalizing a vector. -```{.rb} +```bash vb.Normalize printf("vb.Normalize = %f %f\n", vb.X(), vb.Y()) printf("vb.Distance(va) = %f\n", vb.Distance(va)) @@ -134,12 +161,12 @@ printf("vb.Distance(va) = %f\n", vb.Distance(va)) You can create vectors with 3 dimensions using the typedef `Vector3d`: -```{.rb} +```bash v1 = Gz::Math::Vector3d.new(0, 0, 0) ``` You can also get access to each component in the vector using the `X()`, `Y()` and `Z()` accessors: -```{.rb} -printf("v =: %f %f %f\n", v1.X(), v1.Y(), v1.Z()) +```bash +printf("v1 =: %f %f %f\n", v1.X(), v1.Y(), v1.Z()) ``` From 68c2025aa96b12fc5feafd75663cf9f35f3e3a11 Mon Sep 17 00:00:00 2001 From: Antoine Van Malleghem Date: Wed, 11 Sep 2024 21:33:06 +0200 Subject: [PATCH 6/9] Fix TOC in readme (#630) Signed-off-by: Van Malleghem Antoine --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73acc5e75..df8ca2ccb 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ classes and functions designed for robotic applications. [Folder Structure](#folder-structure) -[Code of Conduct](#code-of-conduct) +[Contributing](#contributing) -[Contributing](#code-of-contributing) +[Code of Conduct](#code-of-conduct) [Versioning](#versioning) From 3b0208c6c223fd725481dd5635b5934c757007b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Thu, 12 Sep 2024 10:15:37 +0200 Subject: [PATCH 7/9] Updated rotation example windows instructions (#631) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alejandro Hernández Cordero --- tutorials/rotation_example.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tutorials/rotation_example.md b/tutorials/rotation_example.md index 0a077a62c..ecb892bd9 100644 --- a/tutorials/rotation_example.md +++ b/tutorials/rotation_example.md @@ -12,7 +12,11 @@ cd gz-math/examples mkdir build cd build cmake .. +# Linux and macOS make +# Windows +cd .. +cmake --build build --config Release ``` When the code is compiled, you can run two different examples, one which converts from quaternion to euler angles: @@ -38,7 +42,10 @@ Example The ouput of each program, respectively: ```{.sh} +# Linux and macOS ./quaternion_to_euler 0.5 0.5 0.5 0.5 +# Windows +.\build\Release\quaternion_to_euler.exe 0.5 0.5 0.5 0.5 Normalizing Quaternion components: W 0.5 X 0.5 @@ -66,7 +73,10 @@ to Rotation matrix ``` ```{.sh} +# Linux and macOS ./quaternion_from_euler 0 0 1.57 +# Windows +.\build\Release\quaternion_from_euler.exe 0 0 1.57 Converting Euler angles: roll 0.000000 radians pitch 0.000000 radians From f1702e409b2daf3dc79273868a8cf676396ba1f9 Mon Sep 17 00:00:00 2001 From: Daisuke Sato Date: Thu, 12 Sep 2024 18:22:16 +0900 Subject: [PATCH 8/9] Update Windows instructions of examples (#632) Signed-off-by: Daisuke Sato --- tutorials/example_angle.md | 7 +++++++ tutorials/example_triangle.md | 7 +++++++ tutorials/example_vector2.md | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/tutorials/example_angle.md b/tutorials/example_angle.md index 00e660272..5827504cf 100644 --- a/tutorials/example_angle.md +++ b/tutorials/example_angle.md @@ -14,13 +14,20 @@ cd gz-math/examples mkdir build cd build cmake .. +# Linux and macOS make +# Windows +cd .. +cmake --build build --config Release ``` When the code is compiled, run: ```{.sh} +# Linux and macOS ./angle_example +# Windows +.\build\Release\angle_example.exe ``` The ouput of the program: diff --git a/tutorials/example_triangle.md b/tutorials/example_triangle.md index 2226a12cc..e42ffe93d 100644 --- a/tutorials/example_triangle.md +++ b/tutorials/example_triangle.md @@ -12,13 +12,20 @@ cd gz-math/examples mkdir build cd build cmake .. +# Linux and macOS make +# Windows +cd .. +cmake --build build --config Release ``` When the code is compiled, run: ```{.sh} +# Linux and macOS ./triangle_example +# Windows +.\build\Release\triangle_example.exe ``` The ouput of the program: diff --git a/tutorials/example_vector2.md b/tutorials/example_vector2.md index b34df1e84..484b69872 100644 --- a/tutorials/example_vector2.md +++ b/tutorials/example_vector2.md @@ -14,13 +14,20 @@ cd gz-math/examples mkdir build cd build cmake .. +# Linux and macOS make +# Windows +cd .. +cmake --build build --config Release ``` When the code is compiled, run: ```bash +# Linux and macOS ./vector2_example +# Windows +.\build\Release\vector2_example.exe ``` The output of the program: From eeb17eae96b027af9497b099f706abf0637f96ec Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 26 Sep 2024 09:48:10 -0500 Subject: [PATCH 9/9] Prepare for 8.0.0 (#633) Signed-off-by: Addisu Z. Taddese --- CMakeLists.txt | 2 +- Changelog.md | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e1263c93..f9fc1f82a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(GZ_CMAKE_VER ${gz-cmake4_VERSION_MAJOR}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -gz_configure_project(VERSION_SUFFIX pre1) +gz_configure_project(VERSION_SUFFIX) #============================================================================ # Set project-specific options diff --git a/Changelog.md b/Changelog.md index 324e54232..6d50ee8d7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,15 @@ ## Gazebo Math 8.x -### Gazebo Math 8.0.0 (2024-09-XX) +### Gazebo Math 8.0.0 (2024-09-25) + +1. Miscellaneous documentation fixes + * [Pull request #632](https://github.com/gazebosim/gz-math/pull/632) + * [Pull request #631](https://github.com/gazebosim/gz-math/pull/631) + * [Pull request #630](https://github.com/gazebosim/gz-math/pull/630) + * [Pull request #628](https://github.com/gazebosim/gz-math/pull/628) + +1. Fix Vector examples + * [Pull request #629](https://github.com/gazebosim/gz-math/pull/629) 1. Added CoordinateVector3 and used it in SphericalCoordinates * [Pull request #616](https://github.com/gazebosim/gz-math/pull/616) @@ -8,11 +17,9 @@ 1. Clamping color channel values to within [0, 1] * [Pull request #613](https://github.com/gazebosim/gz-math/pull/613) -1. Implement rule of zero part 2 - * [Pull request #614](https://github.com/gazebosim/gz-math/pull/614) - -1. Use ImplPtr, fix rule of 0 part 1 +1. Use ImplPtr, Implement rule of zero * [Pull request #608](https://github.com/gazebosim/gz-math/pull/608) + * [Pull request #614](https://github.com/gazebosim/gz-math/pull/614) 1. Fix flaky Stopwatch test * [Pull request #610](https://github.com/gazebosim/gz-math/pull/610)