From 7c0f0f1784e2dd05eb0cda4fe110c4297a5c52d0 Mon Sep 17 00:00:00 2001 From: claireyywang Date: Fri, 17 Apr 2020 16:55:37 -0700 Subject: [PATCH 01/25] move hgignore to gitignore Signed-off-by: claireyywang --- .hgignore => .gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .hgignore => .gitignore (100%) diff --git a/.hgignore b/.gitignore similarity index 100% rename from .hgignore rename to .gitignore From 8161fe448438d8877c03af9da155081140a8afa9 Mon Sep 17 00:00:00 2001 From: claireyywang Date: Fri, 17 Apr 2020 16:56:25 -0700 Subject: [PATCH 02/25] remove hg syntax and add comments Signed-off-by: claireyywang --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ebd4abe1b..62b9898cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -syntax: glob - +# CMake folders build build_* + +# OS generated files .DS_Store *.swp From 53efe3b68e62ccaa7df358d7d90ac519bc460d84 Mon Sep 17 00:00:00 2001 From: chapulina Date: Tue, 21 Apr 2020 11:59:06 -0700 Subject: [PATCH 03/25] [ign-math6] Update BitBucket links (#110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ign-math6] Update BitBucket links Signed-off-by: Louise Poubel * Update include/ignition/math/Material.hh Co-Authored-By: Alejandro Hernández Cordero Co-authored-by: Alejandro Hernández Cordero --- CONTRIBUTING.md | 2 +- Changelog.md | 210 ++++++++++++------------- README.md | 16 +- appveyor.yml | 5 +- bitbucket-pipelines.yml | 2 +- include/ignition/math/Material.hh | 2 +- src/SplinePrivate.hh | 2 +- test/integration/ExamplesBuild_TEST.cc | 2 +- 8 files changed, 120 insertions(+), 121 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6877dd263..147239ce5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -See the [Ignition Robotics contributing guide](https://bitbucket.org/ignitionrobotics/ign-gazebo/src/default/CONTRIBUTING.md). +See the [Ignition Robotics contributing guide](https://ignitionrobotics.org/docs/all/contributing). diff --git a/Changelog.md b/Changelog.md index 508e5a056..57235bbfa 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,59 +3,59 @@ ## Ignition Math 6.x.x 1. Added a Gauss-Markov Process class. - * [Pull request 342](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/342) + * [BitBucket pull request 342](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/342) 1. Fix bug in Inertial addition of off-diagonal moment of inertia terms with pose offsets. - * [Pull request 344](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/344) + * [BitBucket pull request 344](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/344) 1. Create FAKE_INSTALL target so example compilation can be tested without doing a real install. - * Angle: [Pull request 335](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/335) + * Angle: [BitBucket pull request 335](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/335) 1. Updating documentation. - * Angle: [Pull request 325](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/325) + * Angle: [BitBucket pull request 325](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/325) 1. GraphAlgorithms: add ToUndirected(DirectedGraph) that copies to an UndirectedGraph. - * [Pull request 332](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/332) + * [BitBucket pull request 332](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/332) 1. Doxygen fixes for graph classes - * [Pull request 331](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/331) + * [BitBucket pull request 331](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/331) ## Ignition Math 6.4.0 1. Added a function that rounds up a number to the nearest multiple of another number. - * [Pull request 318](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/318) + * [BitBucket pull request 318](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/318) ### Ignition Math 6.3.0 1. Added Odometry class that computes odometry for a two wheeled vehicle. - * [Pull request 313](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/313) + * [BitBucket pull request 313](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/313) 1. Added RollingMean class. - * [Pull request 314](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/314) + * [BitBucket pull request 314](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/314) ### Ignition Math 6.2.0 1. eigen3: Use linear() instead of rotation() to prevent computation of SVD - * [Pull request 311](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/311) + * [BitBucket pull request 311](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/311) 1. Change definition of Pose3 `*` operator to fix multiplication order - * [Pull request 301](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/301) - * [Issue 60](https://bitbucket.org/ignitionrobotics/ign-math/issues/60) + * [BitBucket pull request 301](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/301) + * [Issue 60](https://github.com/ignitionrobotics/ign-math/issues/60) ### Ignition Math 6.1.0 1. eigen3: add conversion functions for Eigen::AlignedBox3d <=> ignition::math::AxisAlignedBox - * [Pull request 302](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/302) + * [BitBucket pull request 302](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/302) ### Ignition Math 6.0.0 1. Helper function that converts from `std::chrono::steady_clock::duration` to {seconds, nanoseconds}. - * [Pull request XXX](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/XXX) + * [BitBucket pull request XXX](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/XXX) 1. Upgrade to c++17. - * [Pull request 268](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/268) + * [BitBucket pull request 268](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/268) ## Ignition Math 5.x @@ -64,66 +64,66 @@ ### Ignition Math 5.1.0 (2019-09-11) 1. GraphAlgorithms: add ToUndirected(DirectedGraph) that copies to an UndirectedGraph. - * [Pull request 332](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/332) + * [BitBucket pull request 332](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/332) 1. Doxygen fixes for graph classes - * [Pull request 331](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/331) + * [BitBucket pull request 331](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/331) 1. eigen3: Use linear() instead of rotation() to prevent computation of SVD - * [Pull request 312](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/312) + * [BitBucket pull request 312](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/312) 1. Change definition of Pose3 `*` operator to fix multiplication order - * [Pull request 301](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/301) - * [Issue 60](https://bitbucket.org/ignitionrobotics/ign-math/issues/60) + * [BitBucket pull request 301](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/301) + * [Issue 60](https://github.com/ignitionrobotics/ign-math/issues/60) 1. eigen3: add conversion functions for Eigen::AlignedBox3d <=> ignition::math::AxisAlignedBox - * [Pull request 302](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/302) + * [BitBucket pull request 302](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/302) ### Ignition Math 5.0.0 (2018-12-12) 1. Added a Stopwatch class - * [Pull request 279](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/279) + * [BitBucket pull request 279](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/279) 1. Added material properties to OrientedBox - * [Pull request 269](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/269) + * [BitBucket pull request 269](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/269) 1. Added a Cylinder class. - * [Pull request 250](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/250) + * [BitBucket pull request 250](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/250) 1. The `Box` class has been changed to a templatized class that is not axis-aligned. The previous `Box` functionality is now in the `AxisAlignedBox` class. - * [Pull request 257](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/257) + * [BitBucket pull request 257](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/257) 1. Added eigen3 component with functions for converting between Eigen and ign-math types. - * [Pull request 256](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/256) + * [BitBucket pull request 256](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/256) 1. Added a `MassMatrix3::SetFromCylinder` function that uses a `Material` to specify a density. - * [Pull request 248](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/248) + * [BitBucket pull request 248](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/248) 1. Added a Sphere class. - * [Pull request 255](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/255) + * [BitBucket pull request 255](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/255) 1. Added a `MassMatrix3::SetFromSphere` function that uses a `Material` to specify a density. - * [Pull request 247](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/247) + * [BitBucket pull request 247](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/247) 1. Added a `MassMatrix3::SetFromBox` function that uses a `Material` to specify a density. - * [Pull request 246](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/246) + * [BitBucket pull request 246](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/246) 1. Deprecated mutator functions in MassMatrix3 that lacked a `Set` prefix. - * [Pull request 262](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/262) + * [BitBucket pull request 262](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/262) 1. Updated the MassMatrix3::ValidMoments(), MassMatrix3::IsValid(), MassMatrix3::IsPositive(), and Inertial::SetMassMatrix functions to accept a tolerance parameter. - * [Pull request 264](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/264) + * [BitBucket pull request 264](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/264) 1. Add MassMatrix3::IsNearPositive and use it in MassMatrix3::IsValid, use >= instead of > in MassMatrix3::ValidMoments - * [Pull request 278](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/278) + * [BitBucket pull request 278](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/278) ## Ignition Math 4.x @@ -131,68 +131,68 @@ specify a density. 1. Add Graph::EdgeFromVertices function that return an edge, if one exists, between two vertices. - * [Pull request 254](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/254) + * [BitBucket pull request 254](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/254) 1. Added multiply assign operator to Matrix4. - * [Pull request 252](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/252) + * [BitBucket pull request 252](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/252) 1. Add Plane copy constructor and fix cppcheck on artful - * [Pull request 230](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/230) + * [BitBucket pull request 230](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/230) 1. Added MovingWindowFilter, a copy from Ignition Common. This version will replace the version found in Ignition Common. - * [Pull request 239](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/239) + * [BitBucket pull request 239](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/239) 1. Added a Material class, which holds information about materials like wood, steel, and iron. - * [Pull request 243](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/243) + * [BitBucket pull request 243](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/243) ### Ignition Math 4.0.0 (2017-12-26) 1. Use std::stoi and std::stod in math::parse* functions to reduce code - * [Pull request 224](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/224) - * [Issue 50](https://bitbucket.org/ignitionrobotics/ign-math/issues/50) + * [BitBucket pull request 224](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/224) + * [Issue 50](https://github.com/ignitionrobotics/ign-math/issues/50) 1. Fixing const-correctness for operator* of Pose3 - * [Pull request 205](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/205) + * [BitBucket pull request 205](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/205) 1. Deprecate Matrix4::Translate and replace by Matrix4::SetTranslation - * [Pull request 222](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/222) + * [BitBucket pull request 222](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/222) 1. Use ignition-cmake to simplify build scripts - * [Pull request 200](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/200) + * [BitBucket pull request 200](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/200) 1. Make constructor SemanticVersion(string) explicit - * [Pull request 203](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/203) + * [BitBucket pull request 203](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/203) 1. Switch to C++14 - * [Pull request 180](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/180) + * [BitBucket pull request 180](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/180) 1. Removed the box 'extent' field. The default constructor now sets a box's corners to extrema in order to indicate an uninitialized box. - * [Pull request 172](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/172) - * [Issue 72](https://bitbucket.org/ignitionrobotics/ign-math/issues/72) - * [Issue 53](https://bitbucket.org/ignitionrobotics/ign-math/issues/53) + * [BitBucket pull request 172](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/172) + * [Issue 72](https://github.com/ignitionrobotics/ign-math/issues/72) + * [Issue 53](https://github.com/ignitionrobotics/ign-math/issues/53) 1. Added graph utilites: 1. Added a Vertex class: - * [Pull request 170](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/170) + * [BitBucket pull request 170](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/170) 1. Added an Edge class: - * [Pull request 174](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/174) + * [BitBucket pull request 174](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/174) 1. Added a Graph class: - * [Pull request 175](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/175) + * [BitBucket pull request 175](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/175) 1. Added a GraphAlgorithms class: - * [Pull request 177](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/177) + * [BitBucket pull request 177](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/177) 1. Added a function to calculate connected components in undirected graphs: - * [Pull request 190](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/190) + * [BitBucket pull request 190](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/190) 1. Improved the performance of `graph::InDegree()` and `graph::IncidentsTo()`. - * [Pull request 188](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/188) - * [Issue 79](https://bitbucket.org/ignitionrobotics/ign-math/issues/79) + * [BitBucket pull request 188](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/188) + * [Issue 79](https://github.com/ignitionrobotics/ign-math/issues/79) 1. Added Inline Versioned Namespace - * [Pull request 216](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/216/) + * [BitBucket pull request 216](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/216/) ## Ignition Math 3.x @@ -203,68 +203,68 @@ specify a density. ### Ignition Math 3.3.0 (2017-11-27) 1. Fixed frustum falsely saying it contained AABB in some cases - * [Pull request 193](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/193) - * [Issue 78](https://bitbucket.org/ignitionrobotics/ign-math/issues/78) + * [BitBucket pull request 193](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/193) + * [Issue 78](https://github.com/ignitionrobotics/ign-math/issues/78) 1. Create consistent bracket operators across all Vector# types - * [Pull request 181](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/181) + * [BitBucket pull request 181](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/181) 1. Change name to the generic BUILDING_DLL macro to avoid conflicts - * [Pull request 173](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/173) + * [BitBucket pull request 173](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/173) 1. Fix some compiler warnings - * [Pull request 196](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/196) + * [BitBucket pull request 196](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/196) 1. Suppress gtest warnings - * [Pull request 199](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/199) + * [BitBucket pull request 199](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/199) 1. Move private headers to src folder - * [Pull request 198](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/198) + * [BitBucket pull request 198](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/198) 1. Update configure.bat - * [Pull request 206](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/206) + * [BitBucket pull request 206](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/206) ### Ignition Math 3.2.0 (2017-05-15) 1. Construct on first use in Rand class - * [Pull request 165](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/165) + * [BitBucket pull request 165](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/165) 1. Extended Spline API: derivative interpolation, arc length calculation and tangent forcing. - * [Pull request 162](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/162) + * [BitBucket pull request 162](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/162) ### Ignition Math 3.1.0 (2017-04-11) 1. Added signum functions to Helpers.hh. * Contribution from Martin Pecka - * [Pull request 153](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/153) + * [BitBucket pull request 153](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/153) ### Ignition Math 3.0.0 (2017-01-05) 1. Deprecate many IGN_* macros in favor of static const variables in Helpers.hh - * [Pull request 138](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/138) - * [Pull request 137](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/137) + * [BitBucket pull request 138](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/138) + * [BitBucket pull request 137](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/137) 1. Removed exceptions. Return values should be evaluated to determine if errors have occured. - * [Pull request 132](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/132) + * [BitBucket pull request 132](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/132) 1. Added `operator=(const Quaternion &_q)` to `Matrix3`. - * [Pull request 111](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/111) + * [BitBucket pull request 111](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/111) 1. Fix xenial cppcheck - * [Pull request xxx](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/xxx) + * [BitBucket pull request xxx](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/xxx) 1. Require cmake 2.8.12 - * [Pull request 76](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/76) + * [BitBucket pull request 76](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/76) 1. Migrate to relocatable CMake package. Contribution from Silvio Traversaro. - * [Pull request 67](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/67) + * [BitBucket pull request 67](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/67) 1. Fix logic of installation of CMake configuration files in Windows. Contribution from Silvio Traversaro. - * [Pull request 63](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/63) + * [BitBucket pull request 63](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/63) ## Ignition Math 2.x @@ -273,33 +273,33 @@ specify a density. ## Ignition Math 2.9 (2017-11-22) 1. Fixed frustum falsely saying it contained AABB in some cases - * [Pull request 193](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/193) + * [BitBucket pull request 193](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/193) 1. Added Color - * [Pull request 150](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/150) + * [BitBucket pull request 150](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/150) 1. Backport updated configure.bat to ign-math2 and fix cppcheck warnings - * [Pull request 207](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/207) + * [BitBucket pull request 207](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/207) ### Ignition Math 2.8 ### Ignition Math 2.8.0 1. Added OrientedBox - * [Pull request 146](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/146) + * [BitBucket pull request 146](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/146) 1. Added an assignment operator to the Frustum class. - * [Pull request 144](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/144) + * [BitBucket pull request 144](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/144) ### Ignition Math 2.7 ### Ignition Math 2.7.0 1. Add static const variables as alternative to macros in Helpers.hh - * [Pull request 137](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/137) + * [BitBucket pull request 137](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/137) 1. Add new methods for floating numbers: lessOrEqual and greaterOrEqual - * [Pull request 134](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/134) + * [BitBucket pull request 134](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/134) ### Ignition Math 2.6 @@ -307,35 +307,35 @@ specify a density. 1. Added copy constructor, equality operators and assignment operators to SphericalCoordinates class. - * [Pull request 131](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/131) + * [BitBucket pull request 131](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/131) 1. Fix Euler angle conversion of quaternions near singularities - * [Pull request 129](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/129) + * [BitBucket pull request 129](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/129) 1. Backport triangle3, helper functions, equality helper to work with 387 fp unit (Contribution from Rich Mattes). - * [Pull request 125](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/125) - * [Pull request 58](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/58) - * [Pull request 56](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/56) + * [BitBucket pull request 125](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/125) + * [BitBucket pull request 58](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/58) + * [BitBucket pull request 56](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/56) 1. Added Matrix4::LookAt - * [Pull request 124](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/124) + * [BitBucket pull request 124](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/124) 1. Set Inertial Rotations - * [Pull request 121](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/121) + * [BitBucket pull request 121](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/121) 1. Added SemanticVersion class - * [Pull request 120](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/120) + * [BitBucket pull request 120](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/120) ### Ignition Math 2.5 ### Ignition Math 2.5.0 1. Added PID class - * [Pull request 117](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/117) + * [BitBucket pull request 117](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/117) 1. Added SphericalCoordinate class - * [Pull request 108](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/108) + * [BitBucket pull request 108](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/108) ### Ignition Math 2.4 @@ -343,36 +343,36 @@ specify a density. 1. Combine inertial properties of different objects, returning the equivalent inertial properties as if the objects were welded together. - * [Pull request 115](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/115) + * [BitBucket pull request 115](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/115) #### Ignition Math 2.4.0 1. New MassMatrix3 class - * [Pull request 112](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/112) + * [BitBucket pull request 112](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/112) 1. MassMatrix3 helper functions - * [Pull request 110](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/110) + * [BitBucket pull request 110](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/110) 1. Added Temperature class * A contribution from Shintaro Noda - * [Pull request 113](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/113) + * [BitBucket pull request 113](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/113) ### Ignition Math 2.3.0 1. Added simple volumes formulas - * [Pull request 84](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/84) + * [BitBucket pull request 84](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/84) 1. Add Length and SquaredLength for Vector2 with test - * [Pull request 73](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/73) + * [BitBucket pull request 73](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/73) 1. Add Equal function with numerical tolerance argument - * [Pull request 75](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/75) + * [BitBucket pull request 75](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/75) 1. First part of MassMatrix3 class, mostly accessors and modifiers - * [Pull request 77](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/77) + * [BitBucket pull request 77](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/77) 1. Add Transpose methods for Matrix3,4 with test - * [Pull request 74](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/74) + * [BitBucket pull request 74](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/74) 1. Multiplication improvements for Vector/Matrix classes - * [Pull request 69](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/69) + * [BitBucket pull request 69](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/69) 1. Scalar +,- operators for Vector[234] - * [Pull request 71](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/71) + * [BitBucket pull request 71](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/71) 1. Add Determinant method for Matrix[34] - * [Pull request 72](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/72) + * [BitBucket pull request 72](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/72) 1. Fixes for compiling and running tests on Windows 7/Visual Studio 2013 Contribution from Silvio Traversaro. - * [Pull request 62](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/62) + * [BitBucket pull request 62](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-request/62) diff --git a/README.md b/README.md index ea4c5dc4b..edd2fdea1 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ **Maintainer:** nate AT openrobotics DOT org -[![Bitbucket open issues](https://img.shields.io/bitbucket/issues-raw/ignitionrobotics/ign-math.svg)](https://bitbucket.org/ignitionrobotics/ign-math/issues) -[![Bitbucket open pull requests](https://img.shields.io/bitbucket/pr-raw/ignitionrobotics/ign-math.svg)](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests) +[![GitHub open issues](https://img.shields.io/github/issues-raw/ignitionrobotics/ign-math.svg)](https://github.com/ignitionrobotics/ign-math/issues) +[![GitHub open pull requests](https://img.shields.io/github/issues-pr-raw/ignitionrobotics/ign-math.svg)](https://github.com/ignitionrobotics/ign-math/pulls) [![Discourse topics](https://img.shields.io/discourse/https/community.gazebosim.org/topics.svg)](https://community.gazebosim.org) [![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](https://www.apache.org/licenses/LICENSE-2.0) @@ -95,7 +95,7 @@ The optional Eigen component of Ignition Math requires: 1. Clone the repository ``` - hg clone https://bitbucket.org/ignitionrobotics/ign-math + git clone https://github.com/ignitionrobotics/ign-math ``` 2. Configure and build @@ -112,7 +112,7 @@ The optional Eigen component of Ignition Math requires: # Usage -Please refer to the [examples directory](https://bitbucket.org/ignitionrobotics/ign-math/raw/default/examples/?at=default). +Please refer to the [examples directory](https://github.com/ignitionrobotics/ign-math/raw/master/examples/). # Documentation @@ -129,7 +129,7 @@ You can also generate the documentation from a clone of this repository by follo 2. Clone the repository ``` - hg clone https://bitbucket.org/ignitionrobotics/ign-math + git clone https://github.com/ignitionrobotics/ign-math ``` 3. Configure and build the documentation. @@ -184,12 +184,12 @@ ign-math # Contributing Please see -[CONTRIBUTING.md](https://bitbucket.org/ignitionrobotics/ign-gazebo/src/406665896aa40bb42f14cf61d48b3d94f2fc5dd8/CONTRIBUTING.md?at=default&fileviewer=file-view-default). +[CONTRIBUTING.md](https://github.com/ignitionrobotics/ign-gazebo/blob/master/CONTRIBUTING.md). # Code of Conduct Please see -[CODE_OF_CONDUCT.md](https://bitbucket.org/ignitionrobotics/ign-gazebo/src/406665896aa40bb42f14cf61d48b3d94f2fc5dd8/CODE_OF_CONDUCT.md?at=default&fileviewer=file-view-default). +[CODE_OF_CONDUCT.md](https://github.com/ignitionrobotics/ign-gazebo/blob/master/CODE_OF_CONDUCT.md). # Versioning @@ -197,4 +197,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://bitbucket.org/ignitionrobotics/ign-math/src/default/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/ignitionrobotics/ign-math/blob/master/LICENSE) file. diff --git a/appveyor.yml b/appveyor.yml index 43cda5c81..cddd68942 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,10 +9,9 @@ environment: CTEST_OUTPUT_ON_FAILURE: 1 install: - - hg summary - - hg clone https://bitbucket.org/ignitionrobotics/ign-cmake + - git clone https://github.com/ignitionrobotics/ign-cmake - cd ign-cmake - - hg up ign-cmake2 + - git checkout ign-cmake2 - md build - cd build - cmake .. -DBUILD_TESTING:BOOL=False diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 809438ce2..18927e3e0 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -31,7 +31,7 @@ pipelines: - make # Make sure documentation generation generated no warnings. - make doc - - bash <(curl -s https://bitbucket.org/ignitionrobotics/ign-cmake/raw/9db5e5487bc4b979b2f602d0b43b7074e010a0c8/tools/doc_check.sh) + - bash <(curl -s https://github.com/ignitionrobotics/ign-cmake/raw/master/tools/doc_check.sh) - make test - make coverage # Use a special version of codecov for handling gcc8 output. diff --git a/include/ignition/math/Material.hh b/include/ignition/math/Material.hh index ac768dd76..89bde08ea 100644 --- a/include/ignition/math/Material.hh +++ b/include/ignition/math/Material.hh @@ -41,7 +41,7 @@ namespace ignition /// enum. /// /// This class will replace the - /// [MaterialDensity class](https://bitbucket.org/ignitionrobotics/ign-common/src/ign-common1/include/ignition/common/MaterialDensity.hh) + /// [MaterialDensity class](https://github.com/ignitionrobotics/ign-common/blob/ign-common1/include/ignition/common/MaterialDensity.hh) /// found in the Ignition Common library, which was at version 1 at the /// time of this writing. /// diff --git a/src/SplinePrivate.hh b/src/SplinePrivate.hh index 5b1613dea..ef82e2959 100644 --- a/src/SplinePrivate.hh +++ b/src/SplinePrivate.hh @@ -67,7 +67,7 @@ namespace ignition { // Workaround to compare the two vector of vectors in MSVC 2013 // and MSVC 2015. See - // https://bitbucket.org/ignitionrobotics/ign-math/issues/70 + // https://github.com/ignitionrobotics/ign-math/issues/70 if (this->derivatives.size() != _other.derivatives.size()) return false; diff --git a/test/integration/ExamplesBuild_TEST.cc b/test/integration/ExamplesBuild_TEST.cc index fc23d03a2..8ae5f5e07 100644 --- a/test/integration/ExamplesBuild_TEST.cc +++ b/test/integration/ExamplesBuild_TEST.cc @@ -34,7 +34,7 @@ // Helper functions copied from -// https://bitbucket.org/ignitionrobotics/ign-common/raw/default/src/Filesystem_TEST.cc +// https://github.com/ignitionrobotics/ign-common/raw/master/src/Filesystem_TEST.cc #ifndef _WIN32 #include // NOLINT(build/include_order) From c2726425418f93a0ea384815c7eab55749a7d0ea Mon Sep 17 00:00:00 2001 From: Addisu Taddese Date: Tue, 28 Apr 2020 17:01:53 -0500 Subject: [PATCH 04/25] Make alpha optional when parsing a Color from an input stream (#106) * Make alpha optional when parsing a Color from an input stream Signed-off-by: Addisu Z. Taddese Co-authored-by: Steven Peters --- Changelog.md | 3 +++ include/ignition/math/Color.hh | 18 ++++++++++++++-- src/Color_TEST.cc | 38 ++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 57235bbfa..de5093e89 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,9 @@ ## Ignition Math 6.x.x +1. Make alpha optional when parsing a Color from an input stream. + * [Pull request 106](https://github.com/ignitionrobotics/ign-math/pull/106) + 1. Added a Gauss-Markov Process class. * [BitBucket pull request 342](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/342) diff --git a/include/ignition/math/Color.hh b/include/ignition/math/Color.hh index aa912c2c7..faf7a084f 100644 --- a/include/ignition/math/Color.hh +++ b/include/ignition/math/Color.hh @@ -247,13 +247,27 @@ namespace ignition } /// \brief Stream insertion operator - /// \param[in] _in the input stream + /// \param[in] _in the input stream. If the input stream does not include + /// an alpha value, a default alpha value of 1.0 will be used. /// \param[in] _pt public: friend std::istream &operator>> (std::istream &_in, Color &_pt) { // Skip white spaces _in.setf(std::ios_base::skipws); - _in >> _pt.r >> _pt.g >> _pt.b >> _pt.a; + _in >> _pt.r >> _pt.g >> _pt.b; + // Since alpha is optional, check if it's there before parsing + while (!_in.eof() && std::isspace(_in.peek())) + { + _in.get(); + } + if (!_in.eof()) + { + _in >> _pt.a; + } + else + { + _pt.a = 1.0; + } return _in; } diff --git a/src/Color_TEST.cc b/src/Color_TEST.cc index e78322d68..7618684d9 100644 --- a/src/Color_TEST.cc +++ b/src/Color_TEST.cc @@ -336,6 +336,44 @@ TEST(Color, OperatorStreamOut) EXPECT_EQ(stream.str(), "0.1 0.2 0.3 0.5"); } +///////////////////////////////////////////////// +TEST(Color, OperatorStreamIn) +{ + math::Color c(0.1f, 0.2f, 0.3f, 0.5f); + math::Color test; + std::stringstream ss("0.1 0.2 0.3 0.5"); + ss >> test; + EXPECT_EQ(c, test); +} + +///////////////////////////////////////////////// +TEST(Color, OperatorStreamInWithoutAlpha) +{ + math::Color c(0.1f, 0.2f, 0.3f, 1.0f); + { + math::Color test; + std::stringstream ss("0.1 0.2 0.3"); + ss.exceptions(std::stringstream::failbit); + EXPECT_NO_THROW(ss >> test); + EXPECT_EQ(c, test); + } + { + math::Color test; + std::stringstream ss("0.1 0.2 \t0.3 \t"); + ss.exceptions(std::stringstream::failbit); + EXPECT_NO_THROW(ss >> test); + EXPECT_EQ(c, test); + } + + { + math::Color test(0.5f, 0.6f, 0.7f, 0.8f); + std::stringstream ss("0.1 0.2 \t0.3 \t"); + ss.exceptions(std::stringstream::failbit); + EXPECT_NO_THROW(ss >> test); + EXPECT_EQ(c, test); + } +} + ///////////////////////////////////////////////// TEST(Color, HSV) { From 45ff350f0a075c05fb78dfd615d6d3806181d3aa Mon Sep 17 00:00:00 2001 From: chapulina Date: Mon, 4 May 2020 14:35:27 -0700 Subject: [PATCH 05/25] [ign-math6] Workflow updates (#117) Signed-off-by: Louise Poubel --- .github/CODEOWNERS | 5 +++++ .github/ci-bionic/after_make.sh | 14 ++++++++++++++ .github/workflows/ci-bionic.yml | 18 ++++++++++++++++++ .github/workflows/pr-collection-labeler.yml | 13 +++++++++++++ .github/workflows/triage.yml | 19 +++++++++++++++++++ README.md | 8 ++++---- bitbucket-pipelines.yml | 4 ++-- codecov.yml | 2 -- 8 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ci-bionic/after_make.sh create mode 100644 .github/workflows/ci-bionic.yml create mode 100644 .github/workflows/pr-collection-labeler.yml create mode 100644 .github/workflows/triage.yml delete mode 100644 codecov.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..1b91d8d00 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,5 @@ +# More info: +# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners + +* @scpeters +tutorials/* @maryaB-osr diff --git a/.github/ci-bionic/after_make.sh b/.github/ci-bionic/after_make.sh new file mode 100644 index 000000000..2587aee10 --- /dev/null +++ b/.github/ci-bionic/after_make.sh @@ -0,0 +1,14 @@ +#!/bin/sh -l + +set -x + +# Install +make install + +# Compile examples +cd ../examples +mkdir build +cd build +cmake .. +make +./graph_example diff --git a/.github/workflows/ci-bionic.yml b/.github/workflows/ci-bionic.yml new file mode 100644 index 000000000..48871e647 --- /dev/null +++ b/.github/workflows/ci-bionic.yml @@ -0,0 +1,18 @@ +name: Ubuntu Bionic CI + +on: [push, pull_request] + +jobs: + bionic-ci: + runs-on: ubuntu-latest + name: Ubuntu Bionic CI + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Bionic CI + id: ci + uses: ignition-tooling/ubuntu-bionic-ci-action@master + with: + apt-dependencies: 'ruby-dev swig libeigen3-dev libignition-cmake2-dev' + codecov-token: ${{ secrets.CODECOV_TOKEN }} + script-after-make: ../.github/ci-bionic/after_make.sh diff --git a/.github/workflows/pr-collection-labeler.yml b/.github/workflows/pr-collection-labeler.yml new file mode 100644 index 000000000..99e9730bc --- /dev/null +++ b/.github/workflows/pr-collection-labeler.yml @@ -0,0 +1,13 @@ +name: PR Collection Labeler + +on: pull_request + +jobs: + pr_collection_labeler: + runs-on: ubuntu-latest + steps: + - name: Add collection labels + if: github.event.action == 'opened' + uses: ignition-tooling/pr-collection-labeler@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml new file mode 100644 index 000000000..69c16ac81 --- /dev/null +++ b/.github/workflows/triage.yml @@ -0,0 +1,19 @@ +on: + issues: + types: [opened] + pull_request: + types: [opened] +name: Ticket opened +jobs: + assign: + name: Add ticket to inbox + runs-on: ubuntu-latest + steps: + - name: Add ticket to inbox + uses: technote-space/create-project-card-action@v1 + with: + PROJECT: Core development + COLUMN: Inbox + GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} + CHECK_ORG_PROJECT: true + diff --git a/README.md b/README.md index edd2fdea1..34ec97ce2 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Build | Status -- | -- -Test coverage | [![codecov](https://codecov.io/bb/ignitionrobotics/ign-math/branch/default/graph/badge.svg)](https://codecov.io/bb/ignitionrobotics/ign-math) -Ubuntu Bionic | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_math-ci-default-bionic-amd64)](https://build.osrfoundation.org/job/ignition_math-ci-default-bionic-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_math-ci-default-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_math-ci-default-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_math-ci-default-windows7-amd64)](https://build.osrfoundation.org/job/ignition_math-ci-default-windows7-amd64) +Test coverage | [![codecov](https://codecov.io/gh/ignitionrobotics/ign-math/branch/master/graph/badge.svg)](https://codecov.io/gh/ignitionrobotics/ign-math) +Ubuntu Bionic | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_math-ci-master-bionic-amd64)](https://build.osrfoundation.org/job/ignition_math-ci-master-bionic-amd64) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_math-ci-master-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_math-ci-master-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_math-ci-master-windows7-amd64)](https://build.osrfoundation.org/job/ignition_math-ci-master-windows7-amd64) Ignition Math, a component of [Ignition Robotics](https://ignitionrobotics.org), provides general purpose math diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 18927e3e0..ae9709f47 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -5,7 +5,7 @@ pipelines: - step: script: - apt-get update - - apt-get -y install cmake build-essential curl git mercurial cppcheck ruby-dev swig g++-8 libeigen3-dev doxygen + - apt-get -y install cmake build-essential curl git cppcheck ruby-dev swig g++-8 libeigen3-dev doxygen - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 - gcc -v - g++ -v @@ -31,7 +31,7 @@ pipelines: - make # Make sure documentation generation generated no warnings. - make doc - - bash <(curl -s https://github.com/ignitionrobotics/ign-cmake/raw/master/tools/doc_check.sh) + - bash <(curl -s https://github.com/ignitionrobotics/ign-cmake/raw/master/tools/doc_check.sh) - make test - make coverage # Use a special version of codecov for handling gcc8 output. diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 6f25123af..000000000 --- a/codecov.yml +++ /dev/null @@ -1,2 +0,0 @@ -codecov: - branch: default From c9484fd28f9168f7d2bcc611f466fd2736466720 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Sat, 30 May 2020 11:28:59 -0700 Subject: [PATCH 06/25] Add operator + for AxisAlignedBox and Vector3 Signed-off-by: Louise Poubel --- include/ignition/math/AxisAlignedBox.hh | 5 +++++ src/AxisAlignedBox.cc | 6 ++++++ src/AxisAlignedBox_TEST.cc | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/include/ignition/math/AxisAlignedBox.hh b/include/ignition/math/AxisAlignedBox.hh index 6277725c7..d6ac5668e 100644 --- a/include/ignition/math/AxisAlignedBox.hh +++ b/include/ignition/math/AxisAlignedBox.hh @@ -127,6 +127,11 @@ namespace ignition /// \return The new box public: AxisAlignedBox operator-(const Vector3d &_v); + /// \brief Add a vector to the min and max values + /// \param _v The vector to use during addition + /// \return The new box + public: AxisAlignedBox operator+(const Vector3d &_v); + /// \brief Output operator /// \param[in] _out Output stream /// \param[in] _b AxisAlignedBox to output to the stream diff --git a/src/AxisAlignedBox.cc b/src/AxisAlignedBox.cc index c6aba4394..1bf91cc2f 100644 --- a/src/AxisAlignedBox.cc +++ b/src/AxisAlignedBox.cc @@ -158,6 +158,12 @@ AxisAlignedBox AxisAlignedBox::operator-(const Vector3d &_v) return AxisAlignedBox(this->dataPtr->min - _v, this->dataPtr->max - _v); } +////////////////////////////////////////////////// +AxisAlignedBox AxisAlignedBox::operator+(const Vector3d &_v) +{ + return AxisAlignedBox(this->dataPtr->min + _v, this->dataPtr->max + _v); +} + ////////////////////////////////////////////////// bool AxisAlignedBox::Intersects(const AxisAlignedBox &_box) const { diff --git a/src/AxisAlignedBox_TEST.cc b/src/AxisAlignedBox_TEST.cc index 9720e7971..4ac638168 100644 --- a/src/AxisAlignedBox_TEST.cc +++ b/src/AxisAlignedBox_TEST.cc @@ -208,6 +208,17 @@ TEST(AxisAlignedBoxTest, Minus) EXPECT_EQ(box2.Max(), box1.Max() - sub); } +///////////////////////////////////////////////// +TEST(AxisAlignedBoxTest, Plus) +{ + AxisAlignedBox box1(1, 2, 3, 4, 5, 6); + Vector3d add(1, 1, 1); + + AxisAlignedBox box2 = box1 + add; + EXPECT_EQ(box2.Min(), box1.Min() + add); + EXPECT_EQ(box2.Max(), box1.Max() + add); +} + ///////////////////////////////////////////////// TEST(AxisAlignedBoxTest, PlusEmpty) { From d1b5e86eac62e7a87960826afe0f3b61e0c5f774 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Sat, 30 May 2020 11:51:37 -0700 Subject: [PATCH 07/25] Changelog entry for #122. Signed-off-by: Steve Peters --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index de5093e89..feaa9b41d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,9 @@ ## Ignition Math 6.x.x +1. Add operator + for AxisAlignedBox and Vector3. + * [Pull request 122](https://github.com/ignitionrobotics/ign-math/pull/122) + 1. Make alpha optional when parsing a Color from an input stream. * [Pull request 106](https://github.com/ignitionrobotics/ign-math/pull/106) From ca49e983bc3939b6626e78f036ff5ea9bf10d270 Mon Sep 17 00:00:00 2001 From: iche033 Date: Mon, 15 Jun 2020 11:26:49 -0700 Subject: [PATCH 08/25] Implement AxisAlignedBox Volume function (#126) * Add AxisAlignedBox::Volume imp Signed-off-by: Ian Chen * changelog Signed-off-by: Ian Chen --- Changelog.md | 3 +++ src/AxisAlignedBox.cc | 5 +++++ src/AxisAlignedBox_TEST.cc | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/Changelog.md b/Changelog.md index feaa9b41d..3eedb8723 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,9 @@ ## Ignition Math 6.x.x +1. Implement AxisAlignedBox Volume function + * [Pull request 126](https://github.com/ignitionrobotics/ign-math/pull/126) + 1. Add operator + for AxisAlignedBox and Vector3. * [Pull request 122](https://github.com/ignitionrobotics/ign-math/pull/122) diff --git a/src/AxisAlignedBox.cc b/src/AxisAlignedBox.cc index 1bf91cc2f..f917633bd 100644 --- a/src/AxisAlignedBox.cc +++ b/src/AxisAlignedBox.cc @@ -284,6 +284,11 @@ std::tuple AxisAlignedBox::Intersect( dir.Normalize(); return this->Intersect(Line3d(_origin + dir * _min, _origin + dir * _max)); } +///////////////////////////////////////////////// +double AxisAlignedBox::Volume() const +{ + return this->XLength() * this->YLength() * this->ZLength(); +} ///////////////////////////////////////////////// // Find the intersection of a line from v0 to v1 and an diff --git a/src/AxisAlignedBox_TEST.cc b/src/AxisAlignedBox_TEST.cc index 4ac638168..4e7edfa6f 100644 --- a/src/AxisAlignedBox_TEST.cc +++ b/src/AxisAlignedBox_TEST.cc @@ -252,6 +252,12 @@ TEST_F(ExampleAxisAlignedBox, Merge) Vector3d(2, 2, 3))); } +///////////////////////////////////////////////// +TEST_F(ExampleAxisAlignedBox, Volume) +{ + EXPECT_DOUBLE_EQ(1.0, box.Volume()); +} + ///////////////////////////////////////////////// TEST(AxisAlignedBoxTest, OperatorEqual) { @@ -577,3 +583,13 @@ TEST(AxisAlignedBoxTest, Intersect) Vector3d(-0.707107, 0, -0.707107), 0, 1000)), dist, 1e-5); EXPECT_EQ(pt, Vector3d(1, 0, 0.3)); } + +///////////////////////////////////////////////// +TEST(AxisAlignedBoxTest, Volume) +{ + AxisAlignedBox box; + EXPECT_DOUBLE_EQ(0.0, box.Volume()); + + AxisAlignedBox box2(math::Vector3d(-1, -2, -3), math::Vector3d(1, 2, 3)); + EXPECT_DOUBLE_EQ(48.0, box2.Volume()); +} From 1e6f11df2f7ac80d23b9c79cf71c48aa5ef696fa Mon Sep 17 00:00:00 2001 From: Pedro Alcantara Date: Thu, 2 Jul 2020 01:40:28 -0300 Subject: [PATCH 09/25] Add setter/getter for Pose's each element - Issue 35 (#125) Signed-off-by: pxalcantara --- include/ignition/math/Pose3.hh | 72 ++++++++++++++++++++++++++++++++++ src/Pose_TEST.cc | 47 +++++++++++++++++++++- 2 files changed, 117 insertions(+), 2 deletions(-) diff --git a/include/ignition/math/Pose3.hh b/include/ignition/math/Pose3.hh index e04dfaa0f..5ab512cbd 100644 --- a/include/ignition/math/Pose3.hh +++ b/include/ignition/math/Pose3.hh @@ -368,6 +368,51 @@ namespace ignition return this->p; } + /// \brief Get the X value of the position. + /// \return Value X of the origin of the pose. + /// \note The return is made by value since + /// Vector3.X() is already a reference. + public: inline const T X() const + { + return this->p.X(); + } + + /// \brief Set X value of the position. + public: inline void SetX(T x) + { + this->p.X() = x; + } + + /// \brief Get the Y value of the position. + /// \return Value Y of the origin of the pose. + /// \note The return is made by value since + /// Vector3.Y() is already a reference. + public: inline const T Y() const + { + return this->p.Y(); + } + + /// \brief Set the Y value of the position. + public: inline void SetY(T y) + { + this->p.Y() = y; + } + + /// \brief Get the Z value of the position. + /// \return Value Z of the origin of the pose. + /// \note The return is made by value since + /// Vector3.Z() is already a reference. + public: inline const T Z() const + { + return this->p.Z(); + } + + /// \brief Set the Z value of the position. + public: inline void SetZ(T z) + { + this->p.Z() = z; + } + /// \brief Get the rotation. /// \return Quaternion representation of the rotation. public: inline const Quaternion &Rot() const @@ -382,6 +427,33 @@ namespace ignition return this->q; } + /// \brief Get the Roll value of the rotation. + /// \return Roll value of the orientation. + /// \note The return is made by value since + /// Quaternion.Roll() is already a reference. + public: inline const T Roll() const + { + return this->q.Roll(); + } + + /// \brief Get the Pitch value of the rotation. + /// \return Pitch value of the orientation. + /// \note The return is made by value since + /// Quaternion.Pitch() is already a reference. + public: inline const T Pitch() const + { + return this->q.Pitch(); + } + + /// \brief Get the Yaw value of the rotation. + /// \return Yaw value of the orientation. + /// \note The return is made by value since + /// Quaternion.Yaw() is already a reference. + public: inline const T Yaw() const + { + return this->q.Yaw(); + } + /// \brief Stream insertion operator /// \param[in] _out output stream /// \param[in] _pose pose to output diff --git a/src/Pose_TEST.cc b/src/Pose_TEST.cc index cb38c86d2..a41c2840b 100644 --- a/src/Pose_TEST.cc +++ b/src/Pose_TEST.cc @@ -140,10 +140,10 @@ TEST(PoseTest, Pose) ///////////////////////////////////////////////// TEST(PoseTest, ConstPose) { - const math::Pose3d pose(0, 1, 2, 0, 0, 0); + const math::Pose3d pose(0, 1, 2, 1, 0, 0); EXPECT_TRUE(pose.Pos() == math::Vector3d(0, 1, 2)); - EXPECT_TRUE(pose.Rot() == math::Quaterniond(0, 0, 0)); + EXPECT_TRUE(pose.Rot() == math::Quaterniond(1, 0, 0)); } ///////////////////////////////////////////////// @@ -155,3 +155,46 @@ TEST(PoseTest, OperatorStreamOut) EXPECT_EQ(stream.str(), "0.1 1.2 2.3 0 0.1 1"); } +///////////////////////////////////////////////// +TEST(PoseTest, MutablePose) +{ + math::Pose3d pose(0, 1, 2, 0, 0, 0); + + EXPECT_TRUE(pose.Pos() == math::Vector3d(0, 1, 2)); + EXPECT_TRUE(pose.Rot() == math::Quaterniond(0, 0, 0)); + + pose.Pos() = math::Vector3d(10, 20, 30); + pose.Rot() = math::Quaterniond(1, 2, 1); + + EXPECT_TRUE(pose.Pos() == math::Vector3d(10, 20, 30)); + EXPECT_TRUE(pose.Rot() == math::Quaterniond(1, 2, 1)); +} + +///////////////////////////////////////////////// +TEST(PoseTest, ConstPoseElements) +{ + const math::Pose3d pose(0, 1, 2, 1, 1, 2); + EXPECT_DOUBLE_EQ(pose.X(), 0); + EXPECT_DOUBLE_EQ(pose.Y(), 1); + EXPECT_DOUBLE_EQ(pose.Z(), 2); + EXPECT_DOUBLE_EQ(pose.Roll(), 1); + EXPECT_DOUBLE_EQ(pose.Pitch(), 1); + EXPECT_DOUBLE_EQ(pose.Yaw(), 2); +} + +///////////////////////////////////////////////// +TEST(PoseTest, SetPoseElements) +{ + math::Pose3d pose(1, 2, 3, 1.57, 1, 2); + EXPECT_DOUBLE_EQ(pose.X(), 1); + EXPECT_DOUBLE_EQ(pose.Y(), 2); + EXPECT_DOUBLE_EQ(pose.Z(), 3); + + pose.SetX(10); + pose.SetY(12); + pose.SetZ(13); + + EXPECT_DOUBLE_EQ(pose.X(), 10); + EXPECT_DOUBLE_EQ(pose.Y(), 12); + EXPECT_DOUBLE_EQ(pose.Z(), 13); +} From 754b0d9e1528f7734c6c370cb07be70d6fd8d81b Mon Sep 17 00:00:00 2001 From: catskul Date: Thu, 14 May 2020 18:28:54 -0400 Subject: [PATCH 10/25] fix: add header for numeric_limits for libstdc++ such that ign-math can build on ubuntu 16.04 (#119) Signed-off-by: Andrew Somerville --- src/RollingMean.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/RollingMean.cc b/src/RollingMean.cc index 8b56bbc7b..3510d0619 100644 --- a/src/RollingMean.cc +++ b/src/RollingMean.cc @@ -16,6 +16,7 @@ */ #include +#include #include #include "ignition/math/RollingMean.hh" From 11864fd2685497518e24bec042df41db9b29b753 Mon Sep 17 00:00:00 2001 From: Pedro Alcantara Date: Tue, 7 Jul 2020 15:47:13 -0300 Subject: [PATCH 11/25] [Issue #71] Update vector2 fuctions from vector3 (#130) Signed-off-by: pxalcantara --- include/ignition/math/Vector2.hh | 16 ++++++++++++++++ src/Vector2_TEST.cc | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/ignition/math/Vector2.hh b/include/ignition/math/Vector2.hh index cda2cbcba..9810fdc89 100644 --- a/include/ignition/math/Vector2.hh +++ b/include/ignition/math/Vector2.hh @@ -65,6 +65,13 @@ namespace ignition /// \brief Destructor public: virtual ~Vector2() {} + /// \brief Return the sum of the values + /// \return the sum + public: T Sum() const + { + return this->data[0] + this->data[1]; + } + /// \brief Calc distance to the given point /// \param[in] _pt The point to measure to /// \return the distance @@ -101,6 +108,15 @@ namespace ignition } } + /// \brief Returns a normalized vector + /// \return unit length vector + public: Vector2 Normalized() const + { + Vector2 result = *this; + result.Normalize(); + return result; + } + /// \brief Set the contents of the vector /// \param[in] _x value along x /// \param[in] _y value along y diff --git a/src/Vector2_TEST.cc b/src/Vector2_TEST.cc index 9c1cd7477..b6a6b3d67 100644 --- a/src/Vector2_TEST.cc +++ b/src/Vector2_TEST.cc @@ -124,6 +124,38 @@ TEST(Vector2Test, Vector2) EXPECT_DOUBLE_EQ(7, v[1]); } +///////////////////////////////////////////////// +TEST(Vector2Test, TestSum) +{ + math::Vector2 vec1(0, 0); + math::Vector2 vec2(1.0, 2.5); + math::Vector2 vec3(-2, -4); + + int sum1 = vec1.Sum(); + float sum2 = vec2.Sum(); + int sum3 = vec3.Sum(); + + EXPECT_EQ(sum1, 0); + EXPECT_FLOAT_EQ(sum2, 3.5); + EXPECT_EQ(sum3, -6); +} + +///////////////////////////////////////////////// +TEST(Vector2Test, TestNormalized) +{ + math::Vector2d vec1(0, 0); + math::Vector2d vec2(1, 2); + + math::Vector2d vec3 = vec1.Normalized(); + + // O zero vector should be equal to the normalized vector + EXPECT_EQ(vec1, vec3); + EXPECT_NE(vec2, vec3); + + vec3 = vec2.Normalized(); + EXPECT_EQ(vec3, math::Vector2d(0.447213, 0.894427)); +} + ///////////////////////////////////////////////// TEST(Vector2Test, NoException) { From 0270a513662f8cca7ed0ceedc9275fffe54695c6 Mon Sep 17 00:00:00 2001 From: Lucas Fernando Andrade Costa <44685107+luccosta@users.noreply.github.com> Date: Mon, 20 Jul 2020 18:49:49 -0300 Subject: [PATCH 12/25] Add Vector4 functions to match Vector3 (#132) This implements the functions Min(), Min(Vector4), Max() and Max(Vector4) in Vector4 API, similar to the existing same functions in Vector3. Signed-off-by: Lucas Fernando --- include/ignition/math/Vector4.hh | 38 ++++++++++++++++++++++++++++++++ src/Vector4_TEST.cc | 32 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/include/ignition/math/Vector4.hh b/include/ignition/math/Vector4.hh index 4453d65ba..7091ce8fa 100644 --- a/include/ignition/math/Vector4.hh +++ b/include/ignition/math/Vector4.hh @@ -17,6 +17,8 @@ #ifndef IGNITION_MATH_VECTOR4_HH_ #define IGNITION_MATH_VECTOR4_HH_ +#include + #include #include #include @@ -126,6 +128,42 @@ namespace ignition this->data[3] = _w; } + /// \brief Set this vector's components to the maximum of itself and the + /// passed in vector + /// \param[in] _v the maximum clamping vector + public: void Max(const Vector4 &_v) + { + this->data[0] = std::max(_v[0], this->data[0]); + this->data[1] = std::max(_v[1], this->data[1]); + this->data[2] = std::max(_v[2], this->data[2]); + this->data[3] = std::max(_v[3], this->data[3]); + } + + /// \brief Set this vector's components to the minimum of itself and the + /// passed in vector + /// \param[in] _v the minimum clamping vector + public: void Min(const Vector4 &_v) + { + this->data[0] = std::min(_v[0], this->data[0]); + this->data[1] = std::min(_v[1], this->data[1]); + this->data[2] = std::min(_v[2], this->data[2]); + this->data[3] = std::min(_v[3], this->data[3]); + } + + /// \brief Get the maximum value in the vector + /// \return the maximum element + public: T Max() const + { + return *std::max_element(this->data, this->data+4); + } + + /// \brief Get the minimum value in the vector + /// \return the minimum element + public: T Min() const + { + return *std::min_element(this->data, this->data+4); + } + /// \brief Assignment operator /// \param[in] _v the vector /// \return a reference to this vector diff --git a/src/Vector4_TEST.cc b/src/Vector4_TEST.cc index 9c7c67976..b14cb8515 100644 --- a/src/Vector4_TEST.cc +++ b/src/Vector4_TEST.cc @@ -156,6 +156,38 @@ TEST(Vector4dTest, NoException) EXPECT_DOUBLE_EQ(v[4], 4.0); } +///////////////////////////////////////////////// +TEST(Vector4dTest, Max) +{ + math::Vector4d vec1(0.1, 0.2, 0.3, 0.2); + math::Vector4d vec2(0.2, 0.3, 0.4, 0.3); + math::Vector4d vec3(0.1, 0.2, 0.3, 0.4); + + EXPECT_DOUBLE_EQ(vec1.Max(), 0.3); + + vec1.Max(vec2); + EXPECT_EQ(vec1, math::Vector4d(0.2, 0.3, 0.4, 0.3)); + + vec1.Max(vec3); + EXPECT_EQ(vec1, math::Vector4d(0.2, 0.3, 0.4, 0.4)); +} + +///////////////////////////////////////////////// +TEST(Vector4dTest, Min) +{ + math::Vector4d vec1(0.1, 0.2, 0.3, 0.4); + math::Vector4d vec2(0.2, 0.3, 0.4, 0.3); + math::Vector4d vec3(0.05, 0.1, 0.2, 0.2); + + EXPECT_DOUBLE_EQ(vec1.Min(), 0.1); + + vec1.Min(vec2); + EXPECT_EQ(vec1, math::Vector4d(0.1, 0.2, 0.3, 0.3)); + + vec1.Min(vec3); + EXPECT_EQ(vec1, math::Vector4d(0.05, 0.1, 0.2, 0.2)); +} + ///////////////////////////////////////////////// // Test Equal function with specified tolerance TEST(Vector2Test, EqualTolerance) From d50d0945d50333c246a14b11df2ae6b5e1d99137 Mon Sep 17 00:00:00 2001 From: Lucas Fernando Andrade Costa <44685107+luccosta@users.noreply.github.com> Date: Mon, 27 Jul 2020 15:12:05 -0300 Subject: [PATCH 13/25] Add Abs, Dot and AbsDot and respective tests to Vector4 (#135) * Add Abs, Dot and AbsDot and respective tests to Vector4 Signed-off-by: Lucas Fernando * Requested test addition for completion Signed-off-by: Lucas Fernando --- include/ignition/math/Vector4.hh | 37 ++++++++++++++++++++++++++++++++ src/Vector4_TEST.cc | 11 ++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/ignition/math/Vector4.hh b/include/ignition/math/Vector4.hh index 7091ce8fa..8223f5745 100644 --- a/include/ignition/math/Vector4.hh +++ b/include/ignition/math/Vector4.hh @@ -115,6 +115,43 @@ namespace ignition } } + /// \brief Return the dot product of this vector and another vector + /// \param[in] _v the vector + /// \return the dot product + public: T Dot(const Vector4 &_v) const + { + return this->data[0] * _v[0] + + this->data[1] * _v[1] + + this->data[2] * _v[2] + + this->data[3] * _v[3]; + } + + /// \brief Return the absolute dot product of this vector and + /// another vector. This is similar to the Dot function, except the + /// absolute value of each component of the vector is used. + /// + /// result = abs(x1 * x2) + abs(y1 * y2) + abs(z1 * z2) + abs(w1 * w2) + /// + /// \param[in] _v the vector + /// \return The absolute dot product + public: T AbsDot(const Vector4 &_v) const + { + return std::abs(this->data[0] * _v[0]) + + std::abs(this->data[1] * _v[1]) + + std::abs(this->data[2] * _v[2]) + + std::abs(this->data[3] * _v[3]); + } + + /// \brief Get the absolute value of the vector + /// \return a vector with positive elements + public: Vector4 Abs() const + { + return Vector4(std::abs(this->data[0]), + std::abs(this->data[1]), + std::abs(this->data[2]), + std::abs(this->data[3])); + } + /// \brief Set the contents of the vector /// \param[in] _x value along x axis /// \param[in] _y value along y axis diff --git a/src/Vector4_TEST.cc b/src/Vector4_TEST.cc index b14cb8515..e988d356f 100644 --- a/src/Vector4_TEST.cc +++ b/src/Vector4_TEST.cc @@ -61,6 +61,17 @@ TEST(Vector4dTest, Vector4d) v.Set(2, 4, 6, 8); EXPECT_EQ(v, math::Vector4d(2, 4, 6, 8)); + // ::DotProd + EXPECT_TRUE(math::equal(60.0, v.Dot(math::Vector4d(1, 2, 3, 4)), 1e-2)); + + // ::AbsDotProd + v1.Set(-1, -2, -3, -4); + EXPECT_TRUE(math::equal(60.0, v.AbsDot(v1), 1e-2)); + + // ::GetAbs + EXPECT_TRUE(v1.Abs() == math::Vector4d(1, 2, 3, 4)); + EXPECT_TRUE(v.Abs() == math::Vector4d(2, 4, 6, 8)); + // ::operator= vector4 v = v1; EXPECT_EQ(v, v1); From a14af069792d6b3f70caec8d6270b6702c5987de Mon Sep 17 00:00:00 2001 From: Felipe Ximenes Date: Tue, 28 Jul 2020 22:45:49 -0300 Subject: [PATCH 14/25] Create abs, absDot and Correct functions for Vector2d (#143) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Abs() => Get the absolute value of the vector - AbsDot() => The absolute dot product - Correct() => Corrects any nan values Create unit test for all functions. These functions intend to solve issue #71 Co-authored-by: Alejandro Hernández Cordero Signed-off-by: Felipe Ximenes --- include/ignition/math/Vector2.hh | 33 ++++++++++++++++++++++++++++++++ src/Vector2_TEST.cc | 31 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/include/ignition/math/Vector2.hh b/include/ignition/math/Vector2.hh index 9810fdc89..c7d7bb199 100644 --- a/include/ignition/math/Vector2.hh +++ b/include/ignition/math/Vector2.hh @@ -134,6 +134,39 @@ namespace ignition return (this->data[0] * _v[0]) + (this->data[1] * _v[1]); } + /// \brief Get the absolute value of the vector + /// \return a vector with positive elements + public: Vector2 Abs() const + { + return Vector2(std::abs(this->data[0]), + std::abs(this->data[1])); + } + + /// \brief Return the absolute dot product of this vector and + /// another vector. This is similar to the Dot function, except the + /// absolute value of each component of the vector is used. + /// + /// result = abs(x1 * x2) + abs(y1 * y2) + /// + /// \param[in] _v The vector + /// \return The absolute dot product + public: T AbsDot(const Vector2 &_v) const + { + return std::abs(this->data[0] * _v[0]) + + std::abs(this->data[1] * _v[1]); + } + + /// \brief Corrects any nan values + public: inline void Correct() + { + // std::isfinite works with floating point values, + // need to explicit cast to avoid ambiguity in vc++. + if (!std::isfinite(static_cast(this->data[0]))) + this->data[0] = 0; + if (!std::isfinite(static_cast(this->data[1]))) + this->data[1] = 0; + } + /// \brief Assignment operator /// \param[in] _v a value for x and y element /// \return this diff --git a/src/Vector2_TEST.cc b/src/Vector2_TEST.cc index b6a6b3d67..f6957bfc8 100644 --- a/src/Vector2_TEST.cc +++ b/src/Vector2_TEST.cc @@ -48,6 +48,10 @@ TEST(Vector2Test, Vector2) v.Set(4, 5); EXPECT_TRUE(v == math::Vector2d(4, 5)); + // operator GetAbs + v.Set(-1, -2); + EXPECT_TRUE(v.Abs() == math::Vector2d(1, 2)); + // ::operator= v = math::Vector2d(6, 7); EXPECT_TRUE(v == math::Vector2d(6, 7)); @@ -189,6 +193,33 @@ TEST(Vector2Test, Dot) EXPECT_DOUBLE_EQ(v.Dot(math::Vector2d(0, 1)), 2.0); } +////////////////////////////////////////////// +TEST(Vector2Test, Correct) +{ + math::Vector2d vec1(0, NAN); + math::Vector2d vec2(INFINITY, -1); + math::Vector2d vec3(10, -2); + + vec1.Correct(); + vec2.Correct(); + vec3.Correct(); + + EXPECT_EQ(vec1, math::Vector2d(0, 0)); + EXPECT_EQ(vec2, math::Vector2d(0, -1)); + EXPECT_EQ(vec3, math::Vector2d(10, -2)); +} + +///////////////////////////////////////////////// +TEST(Vector2Test, AbsDot) +{ + math::Vector2d v(1, -2); + + EXPECT_DOUBLE_EQ(v.AbsDot(math::Vector2d(3, 4)), 11.0); + EXPECT_DOUBLE_EQ(v.AbsDot(math::Vector2d(0, 0)), 0.0); + EXPECT_DOUBLE_EQ(v.AbsDot(math::Vector2d(1, 0)), 1.0); + EXPECT_DOUBLE_EQ(v.AbsDot(math::Vector2d(0, 1)), 2.0); +} + ///////////////////////////////////////////////// TEST(Vector2Test, OperatorStreamOut) { From 8a73032b4cf2379d3635dfd70a5b284d22b59bb2 Mon Sep 17 00:00:00 2001 From: Lucas Fernando Andrade Costa <44685107+luccosta@users.noreply.github.com> Date: Fri, 31 Jul 2020 12:17:18 -0300 Subject: [PATCH 15/25] Vector4 Ruby tests - Vector4.i and Vector4_TEST.rb (#137) * Upload of Vector4 ruby tests and interface Signed-off-by: Lucas Fernando --- src/CMakeLists.txt | 3 +- src/Vector4.i | 73 +++++++++++ src/Vector4_TEST.rb | 300 ++++++++++++++++++++++++++++++++++++++++++++ src/ign_math.i | 1 + 4 files changed, 376 insertions(+), 1 deletion(-) create mode 100644 src/Vector4.i create mode 100644 src/Vector4_TEST.rb diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 657d6ca2f..a6d2885eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,7 +26,8 @@ if (SWIG_FOUND) GaussMarkovProcess Rand Vector2 - Vector3) + Vector3 + Vector4) endif() ################################################# diff --git a/src/Vector4.i b/src/Vector4.i new file mode 100644 index 000000000..d5f2bbf7b --- /dev/null +++ b/src/Vector4.i @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2016 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. + * +*/ + +#ifdef SWIGRUBY +%begin %{ +#define HAVE_ISFINITE 1 +%} +#endif + +%module vector4 +%{ +#include +%} + +namespace ignition +{ + namespace math + { + template + class Vector4 + { + public: static const Vector4 Zero; + public: static const Vector4 One; + public: Vector4(); + public: Vector4(const T &_x, const T &_y, const T &_z, const T &_w); + public: Vector4(const Vector4 &_v); + public: virtual ~Vector4(); + public: T Distance(const Vector4 &_pt) const; + public: T Length() const; + public: T SquaredLength() const; + public: void Normalize(); + public: inline void Set(T _x = 0, T _y = 0, T _z = 0, T _w = 0); + public: Vector4 operator+(const Vector4 &_v) const; + public: inline Vector4 operator+(const T _s) const; + public: inline Vector4 operator-() const; + public: inline Vector4 operator-(const Vector4 &_pt) const; + public: inline Vector4 operator-(const T _s) const; + public: const Vector4 operator/(const Vector4 &_pt) const; + public: const Vector4 operator/(T _v) const; + public: Vector4 operator*(const Vector4 &_p) const; + public: inline Vector4 operator*(T _s) const; + public: bool operator==(const Vector4 &_v) const; + public: bool Equal(const Vector4 &_v, const T &_tol) const; + public: bool IsFinite() const; + public: inline T X() const; + public: inline T Y() const; + public: inline T Z() const; + public: inline T W() const; + public: inline void X(const T &_v); + public: inline void Y(const T &_v); + public: inline void Z(const T &_v); + public: inline void W(const T &_v); + }; + + %template(Vector4i) Vector4; + %template(Vector4d) Vector4; + %template(Vector4f) Vector4; + } +} diff --git a/src/Vector4_TEST.rb b/src/Vector4_TEST.rb new file mode 100644 index 000000000..1d750133d --- /dev/null +++ b/src/Vector4_TEST.rb @@ -0,0 +1,300 @@ +# Copyright (C) 2016 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. + +#!/usr/bin/env ruby + +require 'test/unit/ui/console/testrunner' +require 'test/unit' +require 'math' + + +class Vector4_TEST < Test::Unit::TestCase + def test_construction + v = Ignition::Math::Vector4d.new + + # ::operator== vector4 + assert(true, + "Vector4d::Zero should equal [0, 0, 0, 0]") + + # ::Distance, ::Length() + v.Set(1, 2, 3, 4) + assert(v.Length() == v.Distance(Ignition::Math::Vector4d.Zero), + "Vector4d::Lenth() should equal Vector4d::Distance(zero)") + + # ::operator/ vector4 + v.Set(4, 4, 4, 4) + v = v / Ignition::Math::Vector4d.new(1, 2, 2, 4) + assert(v == Ignition::Math::Vector4d.new(4, 2, 2, 1), + "v / Vector4d(1, 2, 2, 4) should equal Vector4d(4, 2, 2, 1)") + + # ::operator / double + v = v / 2 + assert(v == Ignition::Math::Vector4d.new(2, 1, 1, 0.5), + "v / 2 should equal Vector4d(2, 1, 1, .5)") + + # ::operator * vector4 + v = v * Ignition::Math::Vector4d.new(2, 3, 3, 4) + assert(v == Ignition::Math::Vector4d.new(4, 3, 3, 2), + "v * Vector4d(2, 3, 3, 4) should equal Vector4d(4, 3, 3, 2)") + + # operator /= + v.Set(1, 2, 2, 4) + v /= Ignition::Math::Vector4d.new(1, 4, 8, 4) + assert(v == Ignition::Math::Vector4d.new(1, 0.5, 0.25, 1)) + + # operator *= + v.Set(1, 2, 2, 4) + v *= Ignition::Math::Vector4d.new(2, 0.5, 0.25, 0.1) + assert(v == Ignition::Math::Vector4d.new(2, 1, 0.5, 0.4)) + + # Test the static defines. + assert(Ignition::Math::Vector4d.Zero == + Ignition::Math::Vector4d.new(0, 0, 0, 0), + "Vector4d::Zero should equal [0, 0, 0, 0]") + + assert(Ignition::Math::Vector4d.One == + Ignition::Math::Vector4d.new(1, 1, 1, 1), + "Vector4d::One should equal [1, 1, 1, 1]") + end + + def test_distance + vec1 = Ignition::Math::Vector4d.new(0, 0, 0, 0) + vec2 = Ignition::Math::Vector4d.new(1, 2, 3, 4) + + dist = vec1.Distance(vec2) + assert((dist - 5.47722557505).abs() < 1e-6, + "Vector4 distance should be near 5,47722557505") + end + + def test_squared_length + vec1 = Ignition::Math::Vector4d.new(0, 0, 0, 0) + vec2 = Ignition::Math::Vector4d.new(1, 2, 3, 4) + + sum1 = vec1.SquaredLength() + sum2 = vec2.SquaredLength() + + assert(sum1 == 0, "Vector4 sum1 should equal 0") + assert(sum2 == 30, "Vector4 sum2 should equal 30") + end + + def test_length + # Zero vector + assert(Ignition::Math::Vector4d.Zero.Length() == 0.0, + "Vector4 length of [0, 0, 0, 0] should equal 0") + assert(Ignition::Math::Vector4d.Zero.SquaredLength() == 0.0, + "Vector4 squared length of [0, 0, 0, 0] should equal 0") + + # One vector + assert((Ignition::Math::Vector4d.One.Length() - + Math.sqrt(4.0)).abs() < 1e-10, + "Vector4 length of [1, 1, 1, 1] should equal sqrt(4.0)") + + assert(Ignition::Math::Vector4d.One.SquaredLength() == 4.0, + "Vector4 squared lenght of [1, 1, 1, 1] should equal 4.0") + + # Arbitrary vector + v = Ignition::Math::Vector4d.new(0.1, -4.2, 2.5, -1.2) + assert((v.Length() - 5.03388517946).abs() < 1e-10, + "Vector4 v length should equal 5.03388517946") + + assert((v.SquaredLength() - 25.34).abs() < 1e-10 , + "Vector4 v squared length should equal 25.34") + end + + def test_normalize + vec1 = Ignition::Math::Vector4d.new(0, 0, 0, 0) + vec2 = Ignition::Math::Vector4d.new(1, 2, 3, 4) + + vec3 = vec1 + vec3.Normalize() + assert(vec3 == vec1, "Vector4 vec3 should equal vec1") + assert(vec1 == Ignition::Math::Vector4d.Zero, + "Vector4 should equal [0, 0, 0, 0]") + + vec3 = vec2 + vec2.Normalize() + assert(vec2.Equal(Ignition::Math::Vector4d.new(0.182575, 0.365150, 0.547725, 0.730300), 1e-5), + "Vector4 vec3 should equal [0.182575, 0.365150, 0.547725, 0.730300]") + end + + def test_add + vec1 = Ignition::Math::Vector4d.new(0.1, 0.2, 0.4, 0.8) + vec2 = Ignition::Math::Vector4d.new(1.1, 2.2, 3.4, 4.3) + + vec3 = vec1 + vec3 += vec2 + + assert(vec1 + vec2 == Ignition::Math::Vector4d.new(1.2, 2.4, 3.8, 5.1), + "Vector4 vec1 + vec2 should equal [1.2, 2.4, 3.8, 4.9]") + assert(vec3 == Ignition::Math::Vector4d.new(1.2, 2.4, 3.8, 5.1), + "Vector4 vec3 should equal [1.2, 2.4, 3.8, 4.9]") + + # Addition with zeros + + # Scalar left and right + assert(vec1 + 0 == vec1, "Vector4 vec1+0 should equal vec1") + + # Vector left and right + assert(Ignition::Math::Vector4d.Zero + vec1 == vec1, + "Vector4 Zero + vec1 should equal vec1") + assert(vec1 + Ignition::Math::Vector4d.Zero == vec1, + "Vector4 vec1 + Zero should equal vec1") + + # Addition assignment + vec4 = vec1 + vec4 += 0 + assert(vec4 == vec1, "Vector4 vec4 should equal vec1") + vec4 += Ignition::Math::Vector4d.Zero + assert(vec4 == vec1, "Vector4 vec4 should equal vec1") + + # Add non-trivial scalar values left and right + assert(vec1 + 2.5 == Ignition::Math::Vector4d.new(2.6, 2.7, 2.9, 3.3), + "Vector4 vec1 + 2.5 should equal [2.6, 2.7, 2.9, 3.3]") + + vec1 = vec4 + vec4 += 2.5 + assert(vec4 == Ignition::Math::Vector4d.new(2.6, 2.7, 2.9, 3.3), + "Vector4 vec4 should equal [2.6, 2.7, 2.9, 3.3]") + end + + def test_sub + vec1 = Ignition::Math::Vector4d.new(0.1, 0.2, 0.4, 0.8) + vec2 = Ignition::Math::Vector4d.new(1.1, 2.2, 3.4, 4.3) + + vec3 = vec2 + vec3 -= vec1 + + assert(vec2 - vec1 === Ignition::Math::Vector4d.new(1.0, 2.0, 3.0, 3.5), + "Vector4 vec2 - vec1 should equal [1.0, 2.0, 3.0, 3.5]") + assert(vec3 == Ignition::Math::Vector4d.new(1.0, 2.0, 3.0, 3.5), + "Vector4 vec3 should equal [1.0, 2.0, 3.0, 3.5]") + + # Subtraction with zeros + + # Scalar left and right + assert(vec1 - 0 == vec1, "Vector4 vec1 - 0 should equal vec1") + + # Vector left and right + assert(Ignition::Math::Vector4d.Zero - vec1 == -vec1, + "Vector4 Zero - vec1 should equal -vec1") + assert(vec1 - Ignition::Math::Vector4d.Zero == vec1, + "Vector4 vec1 - Zero should equal vec1") + + # Subtraction assignment + vec4 = vec1 + vec4 -= 0 + assert(vec4 == vec1, "Vector4 vec4 should equal vec1") + vec4 -= Ignition::Math::Vector4d.Zero + assert(vec4 == vec1, "Vector4 vec4 should equal vec1") + + # Subtract non-trivial scalar values left and right + assert(vec1 - 2.5 == -Ignition::Math::Vector4d.new(2.4, 2.3, 2.1, 1.7), + "Vecetor3 vec1 - 2.5 should equal [2.4, 2.3, 2.1, 1.7]") + + vec4 = vec1 + vec4 -= 2.5 + assert(vec4 == -Ignition::Math::Vector4d.new(2.4, 2.3, 2.1, 1.7), + "Vector4 vec4 - 2.5 should equal [2.4, 2.3, 2.1, 1.7]") + end + + def test_divide + vec1 = Ignition::Math::Vector4d.new(0.1, 0.2, 0.4, 0.8) + + vec3 = vec1 / 2.0 + assert(vec3 == Ignition::Math::Vector4d.new(0.05, 0.1, 0.2, 0.4), + "Vector4 vec3 should equal [0.05, 0.1, 0.2, 0.4]") + + vec3 /= 4.0 + assert(vec3 == Ignition::Math::Vector4d.new(0.0125, 0.025, 0.05, 0.1), + "Vector4 vec3 should qual [0.0125, 0.025, 0.05, 0.1]") + end + + def test_multiply + v = Ignition::Math::Vector4d.new(0.1, 0.2, 0.3, 0.4) + + vec3 = v * 2.0 + assert(vec3 == Ignition::Math::Vector4d.new(0.2, 0.4, 0.6, 0.8), + "Vector4 vec3 should equal[0.2, 0.4, 0.6, 0.8]") + + vec3 *= 4.0 + assert(vec3 == Ignition::Math::Vector4d.new(0.8, 1.6, 2.4, 3.2), + "Vector4 vec3 should equal [0.8, 1.6, 2.4, 3.2]") + + # Multiply by zero + + # Scalar left and right + assert(v * 0 == Ignition::Math::Vector4d.Zero, + "Vector4 v * 0 should equal Zero") + + # Element-wise vector multiplication + assert(v * Ignition::Math::Vector4d.Zero == Ignition::Math::Vector4d.Zero, + "Vector4 v * Zero should equal Zero") + + # Multiply by one + + # Scalar left and right + assert(v * 1 == v, "Vector4 v * 1 should equal v") + + # Element-wise vector multiplication + assert(v * Ignition::Math::Vector4d.One == v, + "Vector4 v * One should equal v") + + # Multiply by non-trivial scalar value + + scalar = 2.5 + expect = Ignition::Math::Vector4d.new(0.25, 0.5, 0.75, 1.0) + assert(v * scalar == expect, + "Vector4 v * scalar should equal [0.25, 0.5, 0.75, 1.0]") + + # Multiply by itself element-wise + assert(v*v == Ignition::Math::Vector4d.new(0.01, 0.04, 0.09, 0.16), + "Vector4 v * v should euqal [0.01, 0.04, 0.09, 0.16]") + end + + def test_not_equal + vec1 = Ignition::Math::Vector4d.new(0.1, 0.2, 0.3, 0.4) + vec2 = Ignition::Math::Vector4d.new(0.2, 0.2, 0.3, 0.4) + vec3 = Ignition::Math::Vector4d.new(0.1, 0.2, 0.3, 0.4) + + assert(vec1 != vec2, "Vector4 vec1 should not equal vec2") + assert(!(vec1 != vec3), "Vector4 vec1 should equal vec3" ) + end + + def test_equal + assert(!Ignition::Math::Vector4d.Zero.Equal( + Ignition::Math::Vector4d.One, 1e-6), + "Vector4 Zero should not equal 1 with tolerance of 1e-6") + assert(!Ignition::Math::Vector4d.Zero.Equal( + Ignition::Math::Vector4d.One, 1e-3), + "Vector4 Zero should not equal 1 with tolerance of 1e-3") + assert(!Ignition::Math::Vector4d.Zero.Equal( + Ignition::Math::Vector4d.One, 1e-1), + "Vector4 Zero should not equal 1 with tolerance of 1e-1") + + assert(Ignition::Math::Vector4d.Zero.Equal( + Ignition::Math::Vector4d.One, 1), + "Vector4 Zero should equal 1 with tolerance of 1") + assert(Ignition::Math::Vector4d.Zero.Equal( + Ignition::Math::Vector4d.One, 1.1), + "Vector4 Zero should equal 1 with tolerance of 1.1") + end + + def test_finite + vec1 = Ignition::Math::Vector4d.new(0.1, 0.2, 0.3, 0.4) + + assert(vec1.IsFinite(), "Vector4 vec1 should be be finite") + end +end + +exit Test::Unit::UI::Console::TestRunner.run(Vector4_TEST).passed? ? 0 : -1 diff --git a/src/ign_math.i b/src/ign_math.i index f0a229c89..651220b6d 100644 --- a/src/ign_math.i +++ b/src/ign_math.i @@ -3,3 +3,4 @@ %include "Rand.i" %include "Vector2.i" %include "Vector3.i" +%include "Vector4.i" From 68f1418f830e7aa9ab66ee599261f4d0b491d43a Mon Sep 17 00:00:00 2001 From: Lucas Fernando Andrade Costa <44685107+luccosta@users.noreply.github.com> Date: Fri, 31 Jul 2020 23:14:21 -0300 Subject: [PATCH 16/25] Sum normalized functions (#140) Signed-off-by: Lucas Fernando Co-authored-by: Michael Carroll --- include/ignition/math/Vector4.hh | 16 ++++++++++++++++ src/Vector4_TEST.cc | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/ignition/math/Vector4.hh b/include/ignition/math/Vector4.hh index 8223f5745..0568fc436 100644 --- a/include/ignition/math/Vector4.hh +++ b/include/ignition/math/Vector4.hh @@ -115,6 +115,15 @@ namespace ignition } } + /// \brief Return a normalized vector + /// \return unit length vector + public: Vector4 Normalized() const + { + Vector4 result = *this; + result.Normalize(); + return result; + } + /// \brief Return the dot product of this vector and another vector /// \param[in] _v the vector /// \return the dot product @@ -201,6 +210,13 @@ namespace ignition return *std::min_element(this->data, this->data+4); } + /// \brief Return the sum of the values + /// \return the sum + public: T Sum() const + { + return this->data[0] + this->data[1] + this->data[2] + this->data[3]; + } + /// \brief Assignment operator /// \param[in] _v the vector /// \return a reference to this vector diff --git a/src/Vector4_TEST.cc b/src/Vector4_TEST.cc index e988d356f..dc65da4ea 100644 --- a/src/Vector4_TEST.cc +++ b/src/Vector4_TEST.cc @@ -57,6 +57,11 @@ TEST(Vector4dTest, Vector4d) v.Normalize(); EXPECT_EQ(v, math::Vector4d(0.182574, 0.365148, 0.547723, 0.730297)); + // ::Normalized + v.Set(1, 2, 3, 4); + EXPECT_EQ(v.Normalized(), + math::Vector4d(0.182574, 0.365148, 0.547723, 0.730297)); + // ::Set v.Set(2, 4, 6, 8); EXPECT_EQ(v, math::Vector4d(2, 4, 6, 8)); @@ -210,6 +215,16 @@ TEST(Vector2Test, EqualTolerance) EXPECT_TRUE(math::Vector4d::Zero.Equal(math::Vector4d::One, 1.1)); } +///////////////////////////////////////////////// +TEST(Vector4dTest, Sum) +{ + math::Vector4d vec1(1.5, 2.5, 3.5, -4.5); + + EXPECT_TRUE(math::equal(math::Vector4d::Zero.Sum(), 0.0, 1e-6)); + EXPECT_TRUE(math::equal(math::Vector4d::One.Sum(), 4.0, 1e-6)); + EXPECT_TRUE(math::equal(vec1.Sum(), 3.0, 1e-6)); +} + ///////////////////////////////////////////////// TEST(Vector4dTest, Add) { From c513cdeae13e86db88dee95236515d669f8d5e24 Mon Sep 17 00:00:00 2001 From: Lucas Fernando Andrade Costa <44685107+luccosta@users.noreply.github.com> Date: Sun, 2 Aug 2020 23:52:53 -0300 Subject: [PATCH 17/25] Document Ruby Tests (#145) Add install prerequisites and test subsection Ruby Tests Signed-off-by: Lucas Fernando Co-authored-by: Louise Poubel Signed-off-by: Louise Poubel --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 34ec97ce2..82f76f495 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,20 @@ The optional Eigen component of Ignition Math requires: sudo apt-get install libeigen3-dev ``` +The optional Ruby tests of Ignition Math require: + + * [Ruby](https://www.ruby-lang.org/). Refer to the [Ruby Documentation](https://www.ruby-lang.org/downloads/) for installation instructions. On Ubuntu systems `apt-get` can be used to install Ubuntu Package `ruby-dev`: + + ``` + sudo apt-get install ruby-dev + ``` + + * [Swig](http://www.swig.org/). Refer to the [Swig Documentation](http://www.swig.org/download.html) for installation instructions. On Ubuntu systems `apt-get` can be used to install Swig: + + ``` + sudo apt-get install swig + ``` + ### Building from source 1. Clone the repository @@ -162,6 +176,28 @@ Follow these steps to run tests and static code analysis in your clone of this r make codecheck ``` +## Ruby Tests + +### Usage + +The C++ classes are available in Ruby code by interface files (`.i`) used by swig to build a C++ extension module. + +The interfaces and Ruby test codes are in the `src` folder. To use a C++ class in Ruby you need to: + +1. Create an interface file describing the class as in Swig and Ruby reference at [The Ruby-to-C/C++ Mapping](http://www.swig.org/Doc1.3/Ruby.html#Ruby_nn11) + +2. Include the interface file in `/src/ing_math.i` + +3. Create the Ruby file and import the class as in Swig and Ruby reference at [C++ Classes](http://www.swig.org/Doc1.3/Ruby.html#Ruby_nn18) + +### Tests + +`make test` already runs all tests, including the ones made in Ruby, but you can run a Ruby test individually using + +``` +ctest -R Ruby_TEST.rb +``` + # Folder Structure Refer to the following table for information about important directories and files in this repository. From c43f4788c60cd9fbaef09b5d6ef24cf263be1419 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Mon, 3 Aug 2020 08:14:20 -0700 Subject: [PATCH 18/25] Update actions CI (#139) Signed-off-by: Louise Poubel Co-authored-by: Michael Carroll --- .github/{ci-bionic => ci}/after_make.sh | 4 +++ .github/ci/packages.apt | 4 +++ .github/workflows/ci-bionic.yml | 18 ------------- .github/workflows/ci.yml | 27 +++++++++++++++++++ include/ignition/math/Filter.hh | 6 ++--- include/ignition/math/MassMatrix3.hh | 1 - include/ignition/math/SignalStats.hh | 36 ++++++++++++------------- src/Frustum_TEST.cc | 14 +++++----- src/Helpers_TEST.cc | 4 +-- src/RotationSpline_TEST.cc | 1 - 10 files changed, 65 insertions(+), 50 deletions(-) rename .github/{ci-bionic => ci}/after_make.sh (80%) create mode 100644 .github/ci/packages.apt delete mode 100644 .github/workflows/ci-bionic.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/ci-bionic/after_make.sh b/.github/ci/after_make.sh similarity index 80% rename from .github/ci-bionic/after_make.sh rename to .github/ci/after_make.sh index 2587aee10..ff9d2f8ba 100644 --- a/.github/ci-bionic/after_make.sh +++ b/.github/ci/after_make.sh @@ -2,6 +2,8 @@ set -x +BUILD_DIR=`pwd` + # Install make install @@ -12,3 +14,5 @@ cd build cmake .. make ./graph_example + +cd $BUILD_DIR diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt new file mode 100644 index 000000000..ac2ae40d2 --- /dev/null +++ b/.github/ci/packages.apt @@ -0,0 +1,4 @@ +libeigen3-dev +libignition-cmake2-dev +ruby-dev +swig diff --git a/.github/workflows/ci-bionic.yml b/.github/workflows/ci-bionic.yml deleted file mode 100644 index 48871e647..000000000 --- a/.github/workflows/ci-bionic.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Ubuntu Bionic CI - -on: [push, pull_request] - -jobs: - bionic-ci: - runs-on: ubuntu-latest - name: Ubuntu Bionic CI - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Bionic CI - id: ci - uses: ignition-tooling/ubuntu-bionic-ci-action@master - with: - apt-dependencies: 'ruby-dev swig libeigen3-dev libignition-cmake2-dev' - codecov-token: ${{ secrets.CODECOV_TOKEN }} - script-after-make: ../.github/ci-bionic/after_make.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..5d9be4dd1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: Ubuntu CI + +on: [push] + +jobs: + bionic-ci: + runs-on: ubuntu-latest + name: Ubuntu Bionic CI + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Compile and test + id: ci + uses: ignition-tooling/action-ignition-ci@master + with: + codecov-token: ${{ secrets.CODECOV_TOKEN }} + focal-ci: + runs-on: ubuntu-latest + name: Ubuntu Focal CI + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Compile and test + id: ci + uses: ignition-tooling/action-ignition-ci@focal + with: + codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/include/ignition/math/Filter.hh b/include/ignition/math/Filter.hh index c97020143..f88d3c8d9 100644 --- a/include/ignition/math/Filter.hh +++ b/include/ignition/math/Filter.hh @@ -78,7 +78,7 @@ namespace ignition } // Documentation Inherited. - public: virtual void Fc(double _fc, double _fs) + public: virtual void Fc(double _fc, double _fs) override { b1 = exp(-2.0 * IGN_PI * _fc / _fs); a0 = 1.0 - b1; @@ -168,7 +168,7 @@ namespace ignition } // Documentation Inherited. - public: void Fc(double _fc, double _fs) + public: void Fc(double _fc, double _fs) override { this->Fc(_fc, _fs, 0.5); } @@ -191,7 +191,7 @@ namespace ignition /// \brief Set the current filter's output. /// \param[in] _val New filter's output. - public: virtual void Set(const T &_val) + public: virtual void Set(const T &_val) override { this->y0 = this->y1 = this->y2 = this->x1 = this->x2 = _val; } diff --git a/include/ignition/math/MassMatrix3.hh b/include/ignition/math/MassMatrix3.hh index 55e1cb0a0..ddc5b58b1 100644 --- a/include/ignition/math/MassMatrix3.hh +++ b/include/ignition/math/MassMatrix3.hh @@ -984,7 +984,6 @@ namespace ignition + std::pow(cos(phi11c.Radian()) - cos(phi12c.Radian()), 2); if (errc < err) { - err = errc; phi1 = phi11c.Radian(); signsPhi23.Set(-1, -1); } diff --git a/include/ignition/math/SignalStats.hh b/include/ignition/math/SignalStats.hh index 5a0417a8b..12edc293a 100644 --- a/include/ignition/math/SignalStats.hh +++ b/include/ignition/math/SignalStats.hh @@ -85,14 +85,14 @@ namespace ignition class IGNITION_MATH_VISIBLE SignalMaximum : public SignalStatistic { // Documentation inherited. - public: virtual double Value() const; + public: virtual double Value() const override; /// \brief Get a short version of the name of this statistical measure. /// \return "max" - public: virtual std::string ShortName() const; + public: virtual std::string ShortName() const override; // Documentation inherited. - public: virtual void InsertData(const double _data); + public: virtual void InsertData(const double _data) override; }; /// \} @@ -101,14 +101,14 @@ namespace ignition class IGNITION_MATH_VISIBLE SignalMean : public SignalStatistic { // Documentation inherited. - public: virtual double Value() const; + public: virtual double Value() const override; /// \brief Get a short version of the name of this statistical measure. /// \return "mean" - public: virtual std::string ShortName() const; + public: virtual std::string ShortName() const override; // Documentation inherited. - public: virtual void InsertData(const double _data); + public: virtual void InsertData(const double _data) override; }; /// \} @@ -117,14 +117,14 @@ namespace ignition class IGNITION_MATH_VISIBLE SignalMinimum : public SignalStatistic { // Documentation inherited. - public: virtual double Value() const; + public: virtual double Value() const override; /// \brief Get a short version of the name of this statistical measure. /// \return "min" - public: virtual std::string ShortName() const; + public: virtual std::string ShortName() const override; // Documentation inherited. - public: virtual void InsertData(const double _data); + public: virtual void InsertData(const double _data) override; }; /// \} @@ -134,14 +134,14 @@ namespace ignition class IGNITION_MATH_VISIBLE SignalRootMeanSquare : public SignalStatistic { // Documentation inherited. - public: virtual double Value() const; + public: virtual double Value() const override; /// \brief Get a short version of the name of this statistical measure. /// \return "rms" - public: virtual std::string ShortName() const; + public: virtual std::string ShortName() const override; // Documentation inherited. - public: virtual void InsertData(const double _data); + public: virtual void InsertData(const double _data) override; }; /// \} @@ -153,14 +153,14 @@ namespace ignition class IGNITION_MATH_VISIBLE SignalMaxAbsoluteValue : public SignalStatistic { // Documentation inherited. - public: virtual double Value() const; + public: virtual double Value() const override; /// \brief Get a short version of the name of this statistical measure. /// \return "maxAbs" - public: virtual std::string ShortName() const; + public: virtual std::string ShortName() const override; // Documentation inherited. - public: virtual void InsertData(const double _data); + public: virtual void InsertData(const double _data) override; }; /// \} @@ -170,14 +170,14 @@ namespace ignition class IGNITION_MATH_VISIBLE SignalVariance : public SignalStatistic { // Documentation inherited. - public: virtual double Value() const; + public: virtual double Value() const override; /// \brief Get a short version of the name of this statistical measure. /// \return "var" - public: virtual std::string ShortName() const; + public: virtual std::string ShortName() const override; // Documentation inherited. - public: virtual void InsertData(const double _data); + public: virtual void InsertData(const double _data) override; }; /// \} diff --git a/src/Frustum_TEST.cc b/src/Frustum_TEST.cc index e274f2bd0..65be6ee47 100644 --- a/src/Frustum_TEST.cc +++ b/src/Frustum_TEST.cc @@ -193,7 +193,7 @@ TEST(FrustumTest, PyramidYAxis) // Field of view Angle(IGN_DTOR(45)), // Aspect ratio - 320.0/320.0, + 1.0, // Pose Pose3d(0, 0, 0, 0, 0, IGN_PI*0.5)); @@ -223,7 +223,7 @@ TEST(FrustumTest, PyramidZAxis) // Field of view Angle(IGN_DTOR(45)), // Aspect ratio - 320.0/320.0, + 1.0, // Pose Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0)); @@ -254,7 +254,7 @@ TEST(FrustumTest, NearFar) // Field of view Angle(IGN_DTOR(45)), // Aspect ratio - 320.0/320.0, + 1.0, // Pose Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0)); @@ -279,7 +279,7 @@ TEST(FrustumTest, FOV) // Field of view Angle(IGN_DTOR(45)), // Aspect ratio - 320.0/320.0, + 1.0, // Pose Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0)); @@ -301,11 +301,11 @@ TEST(FrustumTest, AspectRatio) // Field of view Angle(IGN_DTOR(45)), // Aspect ratio - 320.0/320.0, + 1.0, // Pose Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0)); - EXPECT_DOUBLE_EQ(frustum.AspectRatio(), 320.0/320.0); + EXPECT_DOUBLE_EQ(frustum.AspectRatio(), 1); frustum.SetAspectRatio(1.3434); @@ -323,7 +323,7 @@ TEST(FrustumTest, Pose) // Field of view Angle(IGN_DTOR(45)), // Aspect ratio - 320.0/320.0, + 1.0, // Pose Pose3d(0, 0, 0, 0, IGN_PI*0.5, 0)); diff --git a/src/Helpers_TEST.cc b/src/Helpers_TEST.cc index 093dc5f22..e0d6fdfe3 100644 --- a/src/Helpers_TEST.cc +++ b/src/Helpers_TEST.cc @@ -102,14 +102,14 @@ TEST(HelpersTest, FixNaN) { EXPECT_DOUBLE_EQ(math::fixnan(1.0 / 0.0), 0.0); EXPECT_DOUBLE_EQ(math::fixnan(-1.0 / 0.0), 0.0); - EXPECT_DOUBLE_EQ(math::fixnan(0.0 / 0.0), 0.0); + EXPECT_DOUBLE_EQ(math::fixnan(1.0 / 0.0), 0.0); EXPECT_DOUBLE_EQ(math::fixnan(42.0), 42.0); EXPECT_DOUBLE_EQ(math::fixnan(-42.0), -42.0); EXPECT_FLOAT_EQ(math::fixnan(1.0f / 0.0f), 0.0f); EXPECT_FLOAT_EQ(math::fixnan(-1.0f / 0.0f), 0.0f); - EXPECT_FLOAT_EQ(math::fixnan(0.0f / 0.0f), 0.0f); + EXPECT_FLOAT_EQ(math::fixnan(1.0f / 0.0f), 0.0f); EXPECT_FLOAT_EQ(math::fixnan(42.0f), 42.0f); EXPECT_FLOAT_EQ(math::fixnan(-42.0f), -42.0f); diff --git a/src/RotationSpline_TEST.cc b/src/RotationSpline_TEST.cc index 57a1e6bfa..cf5b2816f 100644 --- a/src/RotationSpline_TEST.cc +++ b/src/RotationSpline_TEST.cc @@ -94,7 +94,6 @@ TEST(RotationSplineTest, RecalcTangents) EXPECT_EQ(s.Interpolate(0, 0.5), math::Quaterniond(0.987225, 0.077057, 0.11624, 0.077057)); - math::Quaterniond q = s.Interpolate(1, 0.5); EXPECT_EQ(s.Interpolate(1, 0.5), math::Quaterniond(0.987225, 0.077057, 0.11624, 0.077057)); } From 1a7ae9fcf604ff575059aed4548d51de1480c0ec Mon Sep 17 00:00:00 2001 From: Lucas Fernando Andrade Costa <44685107+luccosta@users.noreply.github.com> Date: Fri, 7 Aug 2020 13:55:28 -0300 Subject: [PATCH 19/25] Round, Rounded, Correct, Distance(x, y, z, w) and operator< addition to Vector 4 (#146) * Round, Rounded, Correct, Distance(x, y, z, w) and operator< addition to Vector4 Signed-off-by: Lucas Fernando * Correct test Signed-off-by: Lucas Fernando Co-authored-by: Louise Poubel --- include/ignition/math/Vector4.hh | 54 ++++++++++++++++++++++++++++++++ src/Vector4_TEST.cc | 20 ++++++++++++ 2 files changed, 74 insertions(+) diff --git a/include/ignition/math/Vector4.hh b/include/ignition/math/Vector4.hh index 0568fc436..3ad31c7d7 100644 --- a/include/ignition/math/Vector4.hh +++ b/include/ignition/math/Vector4.hh @@ -84,6 +84,17 @@ namespace ignition (this->data[3]-_pt[3])*(this->data[3]-_pt[3])); } + /// \brief Calc distance to the given point + /// \param[in] _x value along x + /// \param[in] _y value along y + /// \param[in] _z value along z + /// \param[in] _w value along w + /// \return the distance + public: T Distance(T _x, T _y, T _z, T _w) const + { + return this->Distance(Vector4(_x, _y, _z, _w)); + } + /// \brief Returns the length (magnitude) of the vector /// \return The length public: T Length() const @@ -101,6 +112,39 @@ namespace ignition + std::pow(this->data[3], 2); } + /// \brief Round to near whole number. + public: void Round() + { + this->data[0] = nearbyint(this->data[0]); + this->data[1] = nearbyint(this->data[1]); + this->data[2] = nearbyint(this->data[2]); + this->data[3] = nearbyint(this->data[3]); + } + + /// \brief Get a rounded version of this vector + /// \return a rounded vector + public: Vector4 Rounded() const + { + Vector4 result = *this; + result.Round(); + return result; + } + + /// \brief Corrects any nan values + public: inline void Correct() + { + // std::isfinite works with floating point values, + // need to explicit cast to avoid ambiguity in vc++. + if (!std::isfinite(static_cast(this->data[0]))) + this->data[0] = 0; + if (!std::isfinite(static_cast(this->data[1]))) + this->data[1] = 0; + if (!std::isfinite(static_cast(this->data[2]))) + this->data[2] = 0; + if (!std::isfinite(static_cast(this->data[3]))) + this->data[3] = 0; + } + /// \brief Normalize the vector length public: void Normalize() { @@ -639,6 +683,16 @@ namespace ignition this->data[3] = _v; } + /// \brief Less than operator. + /// \param[in] _pt Vector to compare. + /// \return True if this vector's X(), Y(), Z() or W() value is less + /// than the given vector's corresponding values. + public: bool operator<(const Vector4 &_pt) const + { + return this->data[0] < _pt[0] || this->data[1] < _pt[1] || + this->data[2] < _pt[2] || this->data[3] < _pt[3]; + } + /// \brief Stream insertion operator /// \param[in] _out output stream /// \param[in] _pt Vector4 to output diff --git a/src/Vector4_TEST.cc b/src/Vector4_TEST.cc index dc65da4ea..f0e867e1b 100644 --- a/src/Vector4_TEST.cc +++ b/src/Vector4_TEST.cc @@ -43,8 +43,10 @@ TEST(Vector4dTest, Vector4d) math::Vector4d v(v1); EXPECT_EQ(v, v1); + // ::Distance EXPECT_TRUE(math::equal(v.Distance( math::Vector4d(0, 0, 0, 0)), 5.4772, 1e-3)); + EXPECT_TRUE(math::equal(v.Distance(1, 2, 3, 4), 0.0)); // ::Length() v.Set(1, 2, 3, 4); @@ -53,7 +55,21 @@ TEST(Vector4dTest, Vector4d) // ::SquaredLength() EXPECT_TRUE(math::equal(v.SquaredLength(), 30.0)); + // ::Rounded + v.Set(1.23, 2.34, 3.55, 8.49); + EXPECT_TRUE(v.Rounded() == math::Vector4d(1, 2, 4, 8)); + + // ::Round + v.Round(); + EXPECT_TRUE(v == math::Vector4d(1, 2, 4, 8)); + + // ::Correct + v.Set(1, 1, std::nan("1"), 1); + v.Correct(); + EXPECT_TRUE(v == math::Vector4d(1, 1, 0, 1)); + // ::Normalize + v.Set(1, 2, 3, 4); v.Normalize(); EXPECT_EQ(v, math::Vector4d(0.182574, 0.365148, 0.547723, 0.730297)); @@ -145,6 +161,10 @@ TEST(Vector4dTest, Vector4d) // ::operator != vector4 EXPECT_NE(v, math::Vector4d()); + // ::operator < vector4 + v.Set(1, 2, 3, 4); + EXPECT_TRUE(v < math::Vector4d(4, 3, 2, 1)); + // ::IsFinite EXPECT_TRUE(v.IsFinite()); From 6e80a49a17172bd24a39bf7316166f86413374cc Mon Sep 17 00:00:00 2001 From: Pedro Alcantara Date: Mon, 10 Aug 2020 13:48:17 -0300 Subject: [PATCH 20/25] Add Max and Min function to Vector2.hh (#133) * Add function Max(Vector2) and test. Signed-off-by: pxalcantara * Add Max() function and test. Signed-off-by: pxalcantara * Add Min(Vector2) function and test. Signed-off-by: pxalcantara * Add Min() function and test. Signed-off-by: pxalcantara * Change doxygen and Max, Min comparison. Signed-off-by: pxalcantara * add Max, Min function to Vector2.i Signed-off-by: pxalcantara * add Max test to .rb file Signed-off-by: pxalcantara * correct lint error Signed-off-by: pxalcantara * Add test_Min to Vector2_TEST.rb Signed-off-by: pxalcantara --- include/ignition/math/Vector2.hh | 34 ++++++++++++++++++++++++++++++++ src/Vector2.i | 4 ++++ src/Vector2_TEST.cc | 34 ++++++++++++++++++++++++++++++++ src/Vector2_TEST.rb | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+) diff --git a/include/ignition/math/Vector2.hh b/include/ignition/math/Vector2.hh index c7d7bb199..74621d945 100644 --- a/include/ignition/math/Vector2.hh +++ b/include/ignition/math/Vector2.hh @@ -17,6 +17,8 @@ #ifndef IGNITION_MATH_VECTOR2_HH_ #define IGNITION_MATH_VECTOR2_HH_ +#include + #include #include @@ -167,6 +169,38 @@ namespace ignition this->data[1] = 0; } + /// \brief Set this vector's components to the maximum of itself and the + /// passed in vector + /// \param[in] _v the maximum clamping vector + public: void Max(const Vector2 &_v) + { + this->data[0] = std::max(_v[0], this->data[0]); + this->data[1] = std::max(_v[1], this->data[1]); + } + + /// \brief Set this vector's components to the minimum of itself and the + /// passed in vector + /// \param[in] _v the minimum clamping vector + public: void Min(const Vector2 &_v) + { + this->data[0] = std::min(_v[0], this->data[0]); + this->data[1] = std::min(_v[1], this->data[1]); + } + + /// \brief Get the maximum value in the vector + /// \return the maximum element + public: T Max() const + { + return std::max(this->data[0], this->data[1]); + } + + /// \brief Get the minimum value in the vector + /// \return the minimum element + public: T Min() const + { + return std::min(this->data[0], this->data[1]); + } + /// \brief Assignment operator /// \param[in] _v a value for x and y element /// \return this diff --git a/src/Vector2.i b/src/Vector2.i index 589c3f155..af1393f39 100644 --- a/src/Vector2.i +++ b/src/Vector2.i @@ -46,6 +46,10 @@ namespace ignition public: void Normalize(); public: void Set(T _x, T _y); public: T Dot(const Vector2 &_v) const; + public: void Max(const Vector2 &_v); + public: void Min(const Vector2 &_v); + public: T Max() const; + public: T Min() const; public: Vector2 operator+(const Vector2 &_v) const; public: inline Vector2 operator+(const T _s) const; public: inline Vector2 operator-() const; diff --git a/src/Vector2_TEST.cc b/src/Vector2_TEST.cc index f6957bfc8..b5cd52694 100644 --- a/src/Vector2_TEST.cc +++ b/src/Vector2_TEST.cc @@ -160,6 +160,40 @@ TEST(Vector2Test, TestNormalized) EXPECT_EQ(vec3, math::Vector2d(0.447213, 0.894427)); } +///////////////////////////////////////////////// +TEST(Vector2Test, Max) +{ + math::Vector2d vec1(0.1, 0.2); + math::Vector2d vec2(0.3, 0.5); + math::Vector2d vec3(0.4, 0.2); + + EXPECT_DOUBLE_EQ(vec1.Max(), 0.2); + EXPECT_DOUBLE_EQ(vec3.Max(), 0.4); + + vec1.Max(vec2); + EXPECT_EQ(vec1, math::Vector2d(0.3, 0.5)); + + vec1.Max(vec3); + EXPECT_EQ(vec1, math::Vector2d(0.4, 0.5)); +} + +///////////////////////////////////////////////// +TEST(Vector2Test, Min) +{ + math::Vector2d vec1(0.3, 0.5); + math::Vector2d vec2(0.1, 0.2); + math::Vector2d vec3(0.05, 0.1); + + EXPECT_DOUBLE_EQ(vec1.Min(), 0.3); + EXPECT_DOUBLE_EQ(vec3.Min(), 0.05); + + vec1.Min(vec2); + EXPECT_EQ(vec1, math::Vector2d(0.1, 0.2)); + + vec1.Min(vec3); + EXPECT_EQ(vec1, math::Vector2d(0.05, 0.1)); +} + ///////////////////////////////////////////////// TEST(Vector2Test, NoException) { diff --git a/src/Vector2_TEST.rb b/src/Vector2_TEST.rb index 58bbd8ee5..a53b32d18 100644 --- a/src/Vector2_TEST.rb +++ b/src/Vector2_TEST.rb @@ -108,6 +108,40 @@ def test_equal_tolerance "Zero should equal 1 with 1.1 tolerance") end + def test_max + vec1 = Ignition::Math::Vector2d.new(0.1, 0.2) + vec2 = Ignition::Math::Vector2d.new(0.3, 0.5) + vec3 = Ignition::Math::Vector2d.new(0.4, 0.2) + + assert((vec1.Max() - 0.2).abs() < 1e-10, + "Vector2 vec1.Max should equal 0.2") + + vec1.Max(vec2) + assert(vec1 == Ignition::Math::Vector2d.new(0.3, 0.5), + "Vector2 vec1 should equal [0.3, 0.5]") + + vec1.Max(vec3) + assert(vec1 == Ignition::Math::Vector2d.new(0.4, 0.5), + "Vector2 vec1 should equal [0.4, 0.5]") + end + + def test_min + vec1 = Ignition::Math::Vector2d.new(0.3, 0.5) + vec2 = Ignition::Math::Vector2d.new(0.1, 0.2) + vec3 = Ignition::Math::Vector2d.new(0.05, 0.1) + + assert((vec1.Min() - 0.3).abs() < 1e-10, + "Vector2 vec1.Min should equal 0.3") + + vec1.Min(vec2) + assert(vec1 == Ignition::Math::Vector2d.new(0.1, 0.2), + "Vector2 vec1 should equal [0.1, 0.2]") + + vec1.Max(vec3) + assert(vec1 == Ignition::Math::Vector2d.new(0.05, 0.1), + "Vector2 vec1 should equal [0.05, 0.1]") + end + def test_dot v = Ignition::Math::Vector2d.new(1, 2) From e7fffec3c0aaf98da9a8077dd594c83b289abf32 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 18 Aug 2020 12:26:14 -0700 Subject: [PATCH 21/25] Fix Vector2 Ruby tests (#148) Signed-off-by: Louise Poubel --- src/Vector2.i | 3 +++ src/Vector2_TEST.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Vector2.i b/src/Vector2.i index af1393f39..63ae8adee 100644 --- a/src/Vector2.i +++ b/src/Vector2.i @@ -46,6 +46,9 @@ namespace ignition public: void Normalize(); public: void Set(T _x, T _y); public: T Dot(const Vector2 &_v) const; + public: Vector2 Abs() const; + public: T AbsDot(const Vector2 &_v) const; + public: inline void Correct(); public: void Max(const Vector2 &_v); public: void Min(const Vector2 &_v); public: T Max() const; diff --git a/src/Vector2_TEST.rb b/src/Vector2_TEST.rb index a53b32d18..653a47d86 100644 --- a/src/Vector2_TEST.rb +++ b/src/Vector2_TEST.rb @@ -112,10 +112,10 @@ def test_max vec1 = Ignition::Math::Vector2d.new(0.1, 0.2) vec2 = Ignition::Math::Vector2d.new(0.3, 0.5) vec3 = Ignition::Math::Vector2d.new(0.4, 0.2) - + assert((vec1.Max() - 0.2).abs() < 1e-10, "Vector2 vec1.Max should equal 0.2") - + vec1.Max(vec2) assert(vec1 == Ignition::Math::Vector2d.new(0.3, 0.5), "Vector2 vec1 should equal [0.3, 0.5]") @@ -129,17 +129,17 @@ def test_min vec1 = Ignition::Math::Vector2d.new(0.3, 0.5) vec2 = Ignition::Math::Vector2d.new(0.1, 0.2) vec3 = Ignition::Math::Vector2d.new(0.05, 0.1) - + assert((vec1.Min() - 0.3).abs() < 1e-10, "Vector2 vec1.Min should equal 0.3") - + vec1.Min(vec2) assert(vec1 == Ignition::Math::Vector2d.new(0.1, 0.2), "Vector2 vec1 should equal [0.1, 0.2]") - vec1.Max(vec3) - assert(vec1 == Ignition::Math::Vector2d.new(0.05, 0.1), - "Vector2 vec1 should equal [0.05, 0.1]") + vec3.Max(vec2) + assert(vec3 == Ignition::Math::Vector2d.new(0.1, 0.2), + "Vector2 vec3 should equal [0.1, 0.2]") end def test_dot From 9ff0f1cc0cf5cbf2aba481382b6afdc2b0563aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Thu, 27 Aug 2020 19:17:42 +0200 Subject: [PATCH 22/25] Fix IGNITION_MATH_XX_VERSION (#151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- include/ignition/math/config.hh.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ignition/math/config.hh.in b/include/ignition/math/config.hh.in index 8513e6734..6666cb962 100644 --- a/include/ignition/math/config.hh.in +++ b/include/ignition/math/config.hh.in @@ -1,16 +1,16 @@ /* Config.hh. Generated by CMake for @PROJECT_NAME_NO_VERSION@. */ /* Version number */ -#define IGNITION_MATH_MAJOR_VERSION ${PROJECT_MAJOR_VERSION} -#define IGNITION_MATH_MINOR_VERSION ${PROJECT_MINOR_VERSION} -#define IGNITION_MATH_PATCH_VERSION ${PROJECT_PATCH_VERSION} +#define IGNITION_MATH_MAJOR_VERSION ${PROJECT_VERSION_MAJOR} +#define IGNITION_MATH_MINOR_VERSION ${PROJECT_VERSION_MINOR} +#define IGNITION_MATH_PATCH_VERSION ${PROJECT_VERSION_PATCH} #define IGNITION_MATH_VERSION "${PROJECT_VERSION}" #define IGNITION_MATH_VERSION_FULL "${PROJECT_VERSION_FULL}" #define IGNITION_MATH_VERSION_NAMESPACE v${PROJECT_VERSION_MAJOR} -#define IGNITION_MATH_VERSION_HEADER "Ignition math, version ${PROJECT_VERSION_FULL}\nCopyright (C) 2014 Open Source Robotics Foundation.\nReleased under the Apache 2.0 License.\n\n" +#define IGNITION_MATH_VERSION_HEADER "Ignition ${IGN_DESIGNATION}, version ${PROJECT_VERSION_FULL}\nCopyright (C) 2014 Open Source Robotics Foundation.\nReleased under the Apache 2.0 License.\n\n" #cmakedefine IGNITION_MATH_BUILD_TYPE_PROFILE 1 #cmakedefine IGNITION_MATH_BUILD_TYPE_DEBUG 1 From d5dc70f5a2925c408fce48025121f3aed9385f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Thu, 3 Sep 2020 09:47:28 +0200 Subject: [PATCH 23/25] Added functions to convert between time_point and secNsec (#150) * Added functions to convert between time_point and secNsec Signed-off-by: ahcorde * Add function to convert a time_point in a string Signed-off-by: ahcorde * Simplify math in timepoint convertions Signed-off-by: ahcorde * make linters happy Signed-off-by: ahcorde * make linters happy Signed-off-by: ahcorde * make linters happy Signed-off-by: ahcorde * Fixed test Signed-off-by: ahcorde * Added test for timePointToString Signed-off-by: ahcorde * Added documentation feedback Signed-off-by: ahcorde * Fix macOS build Cast to system_clock::duration where necessary. Signed-off-by: Steve Peters * Fixed test and added a note with the precision on different OS Signed-off-by: ahcorde * Change std::chrono::system_clock for std::chrono::steady_clock Signed-off-by: ahcorde * Removed comment Signed-off-by: ahcorde * Added feedback Signed-off-by: ahcorde * alphabetize headers in helpers.hh Signed-off-by: ahcorde Co-authored-by: John Shepherd Co-authored-by: Steve Peters --- include/ignition/math/Helpers.hh | 98 ++++++++++++++++++++++++++++++-- src/Helpers_TEST.cc | 68 ++++++++++++++++++++++ 2 files changed, 162 insertions(+), 4 deletions(-) diff --git a/include/ignition/math/Helpers.hh b/include/ignition/math/Helpers.hh index e4f1c9722..60ba91869 100644 --- a/include/ignition/math/Helpers.hh +++ b/include/ignition/math/Helpers.hh @@ -17,16 +17,18 @@ #ifndef IGNITION_MATH_FUNCTIONS_HH_ #define IGNITION_MATH_FUNCTIONS_HH_ +#include #include #include -#include +#include +#include +#include #include +#include #include -#include -#include #include #include -#include +#include #include #include "ignition/math/Export.hh" @@ -727,8 +729,46 @@ namespace ignition } } + /// \brief Convert a std::chrono::steady_clock::time_point to a seconds and + /// nanoseconds pair. + // and on macOS, microsecond precision. + /// \param[in] _time The time point to convert. + /// \return A pair where the first element is the number of seconds and + /// the second is the number of nanoseconds. + inline std::pair timePointToSecNsec( + const std::chrono::steady_clock::time_point &_time) + { + auto now_ns = std::chrono::duration_cast( + _time.time_since_epoch()); + auto now_s = std::chrono::duration_cast( + _time.time_since_epoch()); + int64_t seconds = now_s.count(); + int64_t nanoseconds = std::chrono::duration_cast + (now_ns - now_s).count(); + return {seconds, nanoseconds}; + } + + /// \brief Convert seconds and nanoseconds to + /// std::chrono::steady_clock::time_point. + // and on macOS, microsecond precision. + /// \param[in] _sec The seconds to convert. + /// \param[in] _nanosec The nanoseconds to convert. + /// \return A std::chrono::steady_clock::time_point based on the number of + /// seconds and the number of nanoseconds. + inline std::chrono::steady_clock::time_point secNsecToTimePoint( + const uint64_t &_sec, const uint64_t &_nanosec) + { + auto duration = std::chrono::seconds(_sec) + std::chrono::nanoseconds( + _nanosec); + std::chrono::steady_clock::time_point result; + using std::chrono::duration_cast; + result += duration_cast(duration); + return result; + } + /// \brief Convert a std::chrono::steady_clock::duration to a seconds and /// nanoseconds pair. + // and on macOS, microsecond precision. /// \param[in] _dur The duration to convert. /// \return A pair where the first element is the number of seconds and /// the second is the number of nanoseconds. @@ -740,6 +780,56 @@ namespace ignition return {s.count(), ns.count()}; } + // TODO(anyone): Replace this with std::chrono::days. + /// This will exist in C++-20 + typedef std::chrono::duration> days; + + /// \brief break down durations + /// NOTE: the template arguments must be properly ordered according + /// to magnitude and there can be no duplicates. + /// This function uses the braces initializer to split all the templated + /// duration. The initializer will be called recursievely due the `...` + /// \param[in] d Duration to break down + /// \return A tuple based on the durations specified + template + std::tuple breakDownDurations(DurationIn d) { + std::tuple retval; + using discard = int[]; + (void)discard{0, (void(( + (std::get(retval) = + std::chrono::duration_cast(d)), + (d -= std::chrono::duration_cast( + std::get(retval))))), 0)...}; + return retval; + } + + /// \brief Convert a std::chrono::steady_clock::time_point to a string + /// \param[in] _point The std::chrono::steady_clock::time_point to convert. + /// \return A string formatted with the time_point + inline std::string timePointToString( + const std::chrono::steady_clock::time_point &_point) + { + auto duration = _point - secNsecToTimePoint(0, 0); + auto cleanDuration = breakDownDurations( + duration); + std::ostringstream output_string; + output_string << std::setw(2) << std::setfill('0') + << std::get<0>(cleanDuration).count() << " " + << std::setw(2) << std::setfill('0') + << std::get<1>(cleanDuration).count() << ":" + << std::setw(2) << std::setfill('0') + << std::get<2>(cleanDuration).count() << ":" + << std::setfill('0') << std::setw(6) + << std::fixed << std::setprecision(3) + << std::get<3>(cleanDuration).count() + + std::get<4>(cleanDuration).count()/1000.0; + return output_string.str(); + } + // Degrade precision on Windows, which cannot handle 'long double' // values properly. See the implementation of Unpair. // 32 bit ARM processors also define 'long double' to be the same diff --git a/src/Helpers_TEST.cc b/src/Helpers_TEST.cc index e0d6fdfe3..6bebc2f2a 100644 --- a/src/Helpers_TEST.cc +++ b/src/Helpers_TEST.cc @@ -518,6 +518,74 @@ TEST(HelpersTest, Pair) } } +///////////////////////////////////////////////// +TEST(HelpersTest, timePointToSecNsec) +{ + std::pair parts = math::timePointToSecNsec( + math::secNsecToTimePoint(0, 0)); + EXPECT_EQ(parts.first, 0); + EXPECT_EQ(parts.second, 0); + + std::chrono::steady_clock::time_point point; + point += std::chrono::nanoseconds(1000); + parts = math::timePointToSecNsec(point); + + EXPECT_EQ(parts.first, 0); + EXPECT_EQ(parts.second, 1000); + + point = math::secNsecToTimePoint(0, 0); + point += std::chrono::seconds(60); + point += std::chrono::nanoseconds(57989); + parts = math::timePointToSecNsec(point); + + EXPECT_EQ(parts.first, 60); + EXPECT_EQ(parts.second, 57989); +} + +///////////////////////////////////////////////// +TEST(HelpersTest, secNsecToTimePoint) +{ + using std::chrono::duration_cast; + using std::chrono::nanoseconds; + using std::chrono::steady_clock; + + std::chrono::steady_clock::time_point point = + math::secNsecToTimePoint(0, 0); + point += std::chrono::hours(24); + + std::chrono::steady_clock::time_point s = + math::secNsecToTimePoint(24*60*60, 0); + EXPECT_EQ(s, point); + + point = math::secNsecToTimePoint(0, 0); + point += std::chrono::nanoseconds(1000); + s = math::secNsecToTimePoint(0, 1000); + EXPECT_EQ(s, point); +} + +///////////////////////////////////////////////// +TEST(HelpersTest, timePointToString) +{ + std::chrono::steady_clock::time_point time_clock = + math::secNsecToTimePoint(0, 0); + std::string s = math::timePointToString(time_clock); + + EXPECT_STREQ(s.c_str(), std::string("00 00:00:00.000").c_str()); + + std::chrono::steady_clock::time_point point; + point += std::chrono::hours(24); + + s = math::timePointToString(point); + EXPECT_STREQ(s.c_str(), std::string("01 00:00:00.000").c_str()); + + point = math::secNsecToTimePoint(0, 0); + point += std::chrono::minutes(1); + point += std::chrono::seconds(23); + point += std::chrono::milliseconds(125); + s = math::timePointToString(point); + EXPECT_STREQ(s.c_str(), std::string("00 00:01:23.125").c_str()); +} + ///////////////////////////////////////////////// TEST(HelpersTest, durationToSecNsec) { From 87d340688bd58ed098fa2bcb37561e5e390e8873 Mon Sep 17 00:00:00 2001 From: John Shepherd Date: Fri, 4 Sep 2020 13:37:24 -0700 Subject: [PATCH 24/25] Add string to time function (#152) Signed-off-by: John Shepherd --- include/ignition/math/Helpers.hh | 126 +++++++++++++++++++++++++++++++ src/Helpers_TEST.cc | 126 +++++++++++++++++++++++++++++++ 2 files changed, 252 insertions(+) diff --git a/include/ignition/math/Helpers.hh b/include/ignition/math/Helpers.hh index 60ba91869..1b1c47dca 100644 --- a/include/ignition/math/Helpers.hh +++ b/include/ignition/math/Helpers.hh @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -830,6 +831,131 @@ namespace ignition return output_string.str(); } + /// \brief Convert a string to a std::chrono::steady_clock::time_point + /// \param[in] _timeString The string to convert in general format + /// "dd hh:mm:ss.nnn" where n is millisecond value + /// \return A std::chrono::steady_clock::time_point containing the + /// string's time value + inline std::chrono::steady_clock::time_point stringToTimePoint( + const std::string &_timeString) + { + std::chrono::steady_clock::time_point timePoint = + math::secNsecToTimePoint(-1, 0); + + if (_timeString.empty()) + return timePoint; + + // The following regex takes a time string in the general format of + // "dd hh:mm:ss.nnn" where n is milliseconds, if just one number is + // provided, it is assumed to be seconds + std::regex time_regex( + "^([0-9]+ ){0,1}" // day: + // Any positive integer + + "(?:([1-9]:|[0-1][0-9]:|2[0-3]:){0,1}" // hour: + // 1 - 9: + // 01 - 19: + // 20 - 23: + + "([0-9]:|[0-5][0-9]:)){0,1}" // minute: + // 0 - 9: + // 00 - 59: + + "(?:([0-9]|[0-5][0-9]){0,1}" // second: + // 0 - 9 + // 00 - 59 + + "(\\.[0-9]{1,3}){0,1})$"); // millisecond: + // .0 - .9 + // .00 - .99 + // .000 - 0.999 + std::smatch matches; + + // `matches` should always be a size of 6 as there are 6 matching + // groups in the regex. + // 1. The whole regex + // 2. The days + // 3. The hours + // 4. The minutes + // 5. The seconds + // 6. The milliseconds + // We can also index them as such below. + // Note that the space will remain in the day match, the colon + // will remain in the hour and minute matches, and the period will + // remain in the millisecond match + if (!std::regex_search(_timeString, matches, time_regex) || + matches.size() != 6) + return timePoint; + + uint64_t numberDays = 0; + uint64_t numberHours = 0; + uint64_t numberMinutes = 0; + uint64_t numberSeconds = 0; + uint64_t numberMilliseconds = 0; + std::string dayString = matches[1]; + std::string hourString = matches[2]; + std::string minuteString = matches[3]; + std::string secondString = matches[4]; + std::string millisecondString = matches[5]; + + // Days are the only unbounded number, so check first to see if stoi + // runs successfully + if (!dayString.empty()) + { + // Erase the space + dayString.erase(dayString.length() - 1); + try + { + numberDays = std::stoi(dayString); + } + catch (const std::out_of_range &oor) + { + return timePoint; + } + } + + if (!hourString.empty()) + { + // Erase the colon + hourString.erase(hourString.length() - 1); + numberHours = std::stoi(hourString); + } + + if (!minuteString.empty()) + { + // Erase the colon + minuteString.erase(minuteString.length() - 1); + numberMinutes = std::stoi(minuteString); + } + + if (!secondString.empty()) + { + numberSeconds = std::stoi(secondString); + } + + if (!millisecondString.empty()) + { + // Erase the period + millisecondString.erase(0, 1); + + // Multiplier because "4" = 400 ms, "04" = 40 ms, and "004" = 4 ms + numberMilliseconds = std::stoi(millisecondString) * + static_cast(1000 / pow(10, millisecondString.length())); + } + + // TODO(anyone): Replace below day conversion with std::chrono::days. + /// This will exist in C++-20 + timePoint = math::secNsecToTimePoint(0, 0); + auto duration = std::chrono::milliseconds(numberMilliseconds) + + std::chrono::seconds(numberSeconds) + + std::chrono::minutes(numberMinutes) + + std::chrono::hours(numberHours) + + std::chrono::hours(24 * numberDays); + timePoint += duration; + + return timePoint; + } + // Degrade precision on Windows, which cannot handle 'long double' // values properly. See the implementation of Unpair. // 32 bit ARM processors also define 'long double' to be the same diff --git a/src/Helpers_TEST.cc b/src/Helpers_TEST.cc index 6bebc2f2a..28bde3719 100644 --- a/src/Helpers_TEST.cc +++ b/src/Helpers_TEST.cc @@ -586,6 +586,132 @@ TEST(HelpersTest, timePointToString) EXPECT_STREQ(s.c_str(), std::string("00 00:01:23.125").c_str()); } +///////////////////////////////////////////////// +TEST(HelpersTest, stringToTimePoint) +{ + std::chrono::steady_clock::time_point zeroTime = + math::secNsecToTimePoint(0, 0); + std::chrono::steady_clock::time_point negTime = + math::secNsecToTimePoint(-1, 0); + + std::string time = "0 00:00:00.000"; + std::chrono::steady_clock::time_point resultTime = + math::stringToTimePoint(time); + std::chrono::steady_clock::time_point point = zeroTime; + + EXPECT_EQ(resultTime, point); + + time = "10 0"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::hours(10 * 24); + + EXPECT_EQ(resultTime, point); + + time = "7"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::seconds(7); + + EXPECT_EQ(resultTime, point); + + time = "7:10"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::minutes(7); + point += std::chrono::seconds(10); + + EXPECT_EQ(resultTime, point); + + time = "17:10"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::minutes(17); + point += std::chrono::seconds(10); + + EXPECT_EQ(resultTime, point); + + time = "7:10.4"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::minutes(7); + point += std::chrono::seconds(10); + point += std::chrono::milliseconds(400); + + EXPECT_EQ(resultTime, point); + + time = "7:10.45"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::minutes(7); + point += std::chrono::seconds(10); + point += std::chrono::milliseconds(450); + + EXPECT_EQ(resultTime, point); + + time = "7:10.456"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::minutes(7); + point += std::chrono::seconds(10); + point += std::chrono::milliseconds(456); + + EXPECT_EQ(resultTime, point); + + time = "2 23:18:25.902"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::hours(2 * 24); + point += std::chrono::hours(23); + point += std::chrono::minutes(18); + point += std::chrono::seconds(25); + point += std::chrono::milliseconds(902); + + EXPECT_EQ(resultTime, point); + + time = ".9"; + resultTime = math::stringToTimePoint(time); + point = zeroTime; + point += std::chrono::milliseconds(900); + + EXPECT_EQ(resultTime, point); + + time = "bad time"; + resultTime = math::stringToTimePoint(time); + + EXPECT_EQ(resultTime, negTime); + + time = ""; + resultTime = math::stringToTimePoint(time); + + EXPECT_EQ(resultTime, negTime); + + time = "60"; + resultTime = math::stringToTimePoint(time); + + EXPECT_EQ(resultTime, negTime); + + time = "60:12"; + resultTime = math::stringToTimePoint(time); + + EXPECT_EQ(resultTime, negTime); + + time = "12:12.9999"; + resultTime = math::stringToTimePoint(time); + + EXPECT_EQ(resultTime, negTime); + + time = "25:12:12.99"; + resultTime = math::stringToTimePoint(time); + + EXPECT_EQ(resultTime, negTime); + + time = "999999999999999 5:12:12.5"; + resultTime = math::stringToTimePoint(time); + + EXPECT_EQ(resultTime, negTime); +} + ///////////////////////////////////////////////// TEST(HelpersTest, durationToSecNsec) { From bf1e3e27c07ed36e2f98b19f4616c21cb6f075d0 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Fri, 4 Sep 2020 20:12:32 -0700 Subject: [PATCH 25/25] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20=206.5.0=20(#155)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- Changelog.md | 59 ++++++++++++++++++++++++++++++++ include/ignition/math/Helpers.hh | 9 ++--- src/Helpers_TEST.cc | 8 ++--- 4 files changed, 69 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a450b32fd..cec0419db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-math6 VERSION 6.4.0) +project(ignition-math6 VERSION 6.5.0) #============================================================================ # Find ignition-cmake diff --git a/Changelog.md b/Changelog.md index 3eedb8723..938f7a2e0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,60 @@ ## Ignition Math 6.x.x +## Ignition Math 6.5.0 (2020-09-04) + +1. Add string to time function + * [Pull request 152](https://github.com/ignitionrobotics/ign-math/pull/152) + +1. Added functions to convert between time_point and secNsec + * [Pull request 150](https://github.com/ignitionrobotics/ign-math/pull/150) + +1. Fix IGNITION_MATH_XXX_VERSION + * [Pull request 151](https://github.com/ignitionrobotics/ign-math/pull/151) + +1. Add Max and Min function to Vector2.hh + * [Pull request 133](https://github.com/ignitionrobotics/ign-math/pull/133) + * [Pull request 148](https://github.com/ignitionrobotics/ign-math/pull/148) + * [Issue 71](https://github.com/ignitionrobotics/ign-math/issues/71) + +1. Round, Rounded, Correct, Distance(x, y, z, w) and operator< addition to Vector 4 + * [Pull request 146](https://github.com/ignitionrobotics/ign-math/pull/146) + * [Issue 71](https://github.com/ignitionrobotics/ign-math/issues/71) + +1. Sum and normalized functions for Vector4 + * [Pull request 140](https://github.com/ignitionrobotics/ign-math/pull/140) + * [Issue 71](https://github.com/ignitionrobotics/ign-math/issues/71) + +1. Vector4 Ruby tests - Vector4.i and Vector4_TEST.rb + * [Pull request 137](https://github.com/ignitionrobotics/ign-math/pull/137) + * [Issue 71](https://github.com/ignitionrobotics/ign-math/issues/71) + +1. Vector3 to vector4 functions + * [Pull request 132](https://github.com/ignitionrobotics/ign-math/pull/132) + * [Issue 71](https://github.com/ignitionrobotics/ign-math/issues/71) + +1. Update vector2 fuctions from vector3 + * [Pull request 130](https://github.com/ignitionrobotics/ign-math/pull/130) + * [Issue 71](https://github.com/ignitionrobotics/ign-math/issues/71) + +1. Add Abs, Dot and AbsDot and respective tests to Vector4 + * [Pull request 135](https://github.com/ignitionrobotics/ign-math/pull/135) + * [Issue 71](https://github.com/ignitionrobotics/ign-math/issues/71) + +1. Create abs, absDot and Correct functions for Vector2d + * [Pull request 143](https://github.com/ignitionrobotics/ign-math/pull/143) + * [Issue 71](https://github.com/ignitionrobotics/ign-math/issues/71) + +1. Document Ruby tests + * [Pull request 145](https://github.com/ignitionrobotics/ign-math/pull/145) + +1. Add header for numeric_limits allowing build on ubuntu 16.04 + * [Pull request 119](https://github.com/ignitionrobotics/ign-math/pull/119) + +1. Add setter/getter for Pose's each element + * [Pull request 125](https://github.com/ignitionrobotics/ign-math/pull/125) + * [Issue 35](https://github.com/ignitionrobotics/ign-math/issues/35) + 1. Implement AxisAlignedBox Volume function * [Pull request 126](https://github.com/ignitionrobotics/ign-math/pull/126) @@ -11,6 +65,11 @@ 1. Make alpha optional when parsing a Color from an input stream. * [Pull request 106](https://github.com/ignitionrobotics/ign-math/pull/106) +1. GitHub actions CI and workflow updates + * [Pull request 117](https://github.com/ignitionrobotics/ign-math/pull/117) + * [Pull request 139](https://github.com/ignitionrobotics/ign-math/pull/139) + * [Pull request 110](https://github.com/ignitionrobotics/ign-math/pull/110) + 1. Added a Gauss-Markov Process class. * [BitBucket pull request 342](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-math/pull-requests/342) diff --git a/include/ignition/math/Helpers.hh b/include/ignition/math/Helpers.hh index 1b1c47dca..b9a8e49e7 100644 --- a/include/ignition/math/Helpers.hh +++ b/include/ignition/math/Helpers.hh @@ -835,12 +835,13 @@ namespace ignition /// \param[in] _timeString The string to convert in general format /// "dd hh:mm:ss.nnn" where n is millisecond value /// \return A std::chrono::steady_clock::time_point containing the - /// string's time value + /// string's time value. If it isn't possible to convert, the time will + /// be negative 1 second. inline std::chrono::steady_clock::time_point stringToTimePoint( const std::string &_timeString) { - std::chrono::steady_clock::time_point timePoint = - math::secNsecToTimePoint(-1, 0); + using namespace std::chrono_literals; + std::chrono::steady_clock::time_point timePoint{-1s}; if (_timeString.empty()) return timePoint; @@ -908,7 +909,7 @@ namespace ignition { numberDays = std::stoi(dayString); } - catch (const std::out_of_range &oor) + catch (const std::out_of_range &) { return timePoint; } diff --git a/src/Helpers_TEST.cc b/src/Helpers_TEST.cc index 28bde3719..948d2649d 100644 --- a/src/Helpers_TEST.cc +++ b/src/Helpers_TEST.cc @@ -589,10 +589,10 @@ TEST(HelpersTest, timePointToString) ///////////////////////////////////////////////// TEST(HelpersTest, stringToTimePoint) { - std::chrono::steady_clock::time_point zeroTime = - math::secNsecToTimePoint(0, 0); - std::chrono::steady_clock::time_point negTime = - math::secNsecToTimePoint(-1, 0); + using namespace std::chrono_literals; + + std::chrono::steady_clock::time_point zeroTime{0s}; + std::chrono::steady_clock::time_point negTime{-1s}; std::string time = "0 00:00:00.000"; std::chrono::steady_clock::time_point resultTime =