math#
Gazebo Math : Math classes and functions for robot applications
Maintainer: scpeters AT openrobotics DOT org
Gazebo Math, a component of Gazebo, provides general purpose math classes and functions designed for robotic applications.
Table of Contents
Features
Gazebo Math provides a wide range of functionality, including:
Type-templated pose, matrix, vector, and quaternion classes.
Shape representations along with operators to compute volume, density, size and other properties.
Classes for material properties, mass, inertial, temperature, PID, kmeans, spherical coordinates, and filtering.
Optional Eigen component that converts between a few Eigen and Gazebo Math types.
Install
See the installation tutorial.
Usage
Please refer to the examples directory.
Folder Structure
Refer to the following table for information about important directories and files in this repository.
gz-math
├── examples Example programs.
├── include/gz/math Header files.
├── src Source files and unit tests.
│ └── graph Source files for the graph classes.
│ └── python_pybind11 Pybind11 Python interfaces.
│ └── ruby SWIG Ruby interfaces.
├── eigen3 Files for Eigen component.
├── test
│ ├── integration Integration tests.
│ ├── performance Performance tests.
│ └── regression Regression tests.
├── tutorials Tutorials, written in markdown.
├── Changelog.md Changelog.
└── CMakeLists.txt CMake build script.
Contributing
Please see the contributing guide.
Code of Conduct
Please see CODE_OF_CONDUCT.md.
Versioning
This library uses Semantic Versioning. Additionally, this library is part of the Gazebo project which periodically releases a versioned set of compatible and complimentary libraries. See the Gazebo website for version and release information.
License
This library is licensed under Apache 2.0. See also the LICENSE file.
Gazebo Math 8.x
Gazebo Math 8.0.0 (2024-09-25)
Miscellaneous documentation fixes
Fix Vector examples
Added CoordinateVector3 and used it in SphericalCoordinates
Clamping color channel values to within [0, 1]
Use ImplPtr, Implement rule of zero
Fix flaky Stopwatch test
Line*.hh: remove unneeded use of static variable
Fix potential unsafe initialization in the Graph class
Remove APIs deprecated in gz-math7
Deprecate math::clock alias
Clean up nested namespaces
Find python directly instead of using GzPython
Adding cone primitives.
Enable 24.04 CI, remove distutils dependency
Remove HIDE_SYMBOLS_BY_DEFAULT: replace by a default configuration in gz-cmake.
Use HIDE_SYMBOLS_BY_DEFAULT, fix MovingWindowFilter
Dependency version bumps in ionic: use gz-cmake4, gz-utils3
Remove ignition headers and macros
Bump major version to 8
Gazebo Math 7.x
Gazebo Math 7.5.1 (2024-08-23)
Fix tolerance for axis-angle conversion of quaternions
Added box examples in C++ and Python
Check for 0 stddev when generating a random number using normal distribution
Clean up nested namespaces
Gazebo Math 7.5.0 (2024-06-18)
Backport: Adding cone primitives.
Enable 24.04 CI on harmonic
Add package.xml
bazel: correctly export license
Add missing eigen3.hh header for bazel build
Expose non-const reference to edges
Gazebo Math 7.4.0 (2024-03-14)
Added MecanumDriveOdometry Python wrapper
Update CI badges in README
Infrastructure
Suppress warnings on MSVC
Remove the use of numeric_limits in appendToStream test
Replace CMake Python variables with new ones from FindPython3 module
Fix
Matrix3_TEST.py
on Windows with conda-forge dependenciesFix small typo cppgetstarted.md
Update Ubuntu Binary installation since apt-key is deprecated
Update file tree in README to point out pybind11
Update tutorial/color.md
ign->gz in README.md
Update example_triangle.md
Gazebo Math 7.3.0 (2023-08-29)
Adds a validity check for Sessions created using the
TimeVaryingVolumetricGrid
Fixes for testing in non standard architectures
MecanumDriveOdometry to handle odometry estimation of Mecanum wheeled models
Fix documentation on Plane.hh
Infrastructure
Build examples from CMake rather than executable
Added
std::optional MassMatrix()
functions for Box, Cylinder & Sphere
Gazebo Math 7.2.0 (2023-06-14)
Add tests to increase test coverage
Forward ports
Disable pybind11 on windows by default
Add option to skip pybind11 and SWIG
Custom PID error rate
Garden bazel support
Rename COPYING to LICENSE
Infrastructure
Fix link of installation tutorial to point to 7.1 version
Gazebo Math 7.1.0 (2022-11-15)
Adds bounds retrieval for TimeVarying grid class.
Gazebo Math 7.0.2 (2022-09-26)
Update to disable tests failing on arm64
Gazebo Math 7.0.1 (2022-09-23)
Disable tests failing on arm64
Gazebo Math 7.0.0 (2022-09-22)
Deprecated
Angle::Degree(double)
andAngle::Radian(double)
. UseAngle::SetDegree(double)
andAngle::SetRadian(double)
instead.Added Equal functions with a tolerance parameter to Pose3 and Quaternion.
Updates per issue #101.
Helpers: BitBucket pull request 330, BitBucket pull request 323
Matrix3: BitBucket pull request 328
Quaternion: BitBucket pull request 327, BitBucket pull request 338
Removed deprecations.
Updated Temperature class documentation, script interface, and added examples.
Prevent -0 with out stream operator
Use
<ostream>
and<istream>
narrower includes, not<iostream>
Evict large function definitions from the Helpers.hh header file.
Defer regex construction to avoid static initialization.
Defer Material::Predefined construction to avoid static initialization.
Resolve cppcheck errors by adding explicit constructors and consts.
Remove virtual from destructors of copyable classes.
Use constexpr for simple static constants.
Fix output stream operator
Tutorial updates
Fixed quaternion from euler example
Rename the python library as gz.math7
Add option to skip pybind11 and SWIG
Python bindings
Add a Time Interpolation API
Add fluid added mass to inertial
VolumetricGridLookupField: generalize index type, add constructor
Drop unnecessary moving window filter pimpl
Migrate ign -> gz
Fix output stream operator
Compute distance between points on a general celestial body
Update GoogleTest to latest version
Reduce compilation time
Pose3: deprecate +, -, and -= operators
Document
Pose::operator*()
Subtraction operator for Inertial class
Add linear interpolation methods.
Infrastructure
Add PiecewiseScalarField3 class
Add AdditivelySeparableScalarField3 class
Add Polynomial3 class
Add Interval and Region3 classes
Add missing headers
[math7] Tidy up unused variables
Use ImplPtr from ign-utils where relevant
Modified cmake target name for Ruby interfaces
Make API / naming consistent for Frustum, Edge, Angle
Reduce Stopwatch test sleep times
Speed up Helpers::Pair test
Make Vector2 API more consistent with Vector3
Clean up a few new GCC9 warnings
Gazebo Math 6.x
Gazebo Math 6.15.1 (2024-01-05)
Replace CMake Python variables with new ones from FindPython3 module
Suppress warnings on MSVC
Infrastructure
Gazebo Math 6.15.0 (2023-09-01)
Fixes for testing in non standard architectures
MecanumDriveOdometry to handle odometry estimation of Mecanum wheeled models
Infrastructure
Gazebo Math 6.14.0 (2023-04-14)
Disable pybind11 on windows by default
Add option to skip pybind11 and SWIG
Custom PID error rate
Infrastructure
Gazebo Math 6.13.0 (2022-08-31)
Support migration and migrate headers
Remove redundant namespace references
Gazebo Math 6.12.0 (2022-07-27)
Added Helper function isTimeString to Python
Ignition -> Gazebo
Added
*.pyc
to.gitignore
Alphabetize examples
Add
PiecewiseScalarField3
classAdd
AdditivelySeparableScalarField3
classAdd
Polynomial3
classAdd
Region3
classAdd
Interval
classAdd Matrix6 class
Backport newest appendToStream functions
Use pytest to generate junit xml files for python tests
Add Aditya as codeowner
Gazebo Math 6.11.0 (2022-05-11)
MassMatrix3: fix bug in PrincipalAxesOffset tolerances
Fix return policies for some member functions
Added Ellipsoid Python interface
Added Capsule Python interface
Fixes for tests on i386: relax SphericalCoordinates and workaround for negative zero
Added helper function to check if a string represents a time
Reduce pybind11 compilation memory
Gazebo Math 6.10.0 (2022-01-26)
Use const instead of constexpr in Ellipsoid constructor
Refactor finding pybind11
Fix Focal on Jenkins
kmeans example in C++ and Python
Small fixed in doxygen
Added Python Getting started tutorial
Move SWIG interfaces from Python to Ruby
Added pybind11 interfaces for various classes
SphericalCoordinates
Vector3Stats
SignalStats
Sphere
Frustum
Plane
Cylinder
OrientedBox
Inertial
Matrix4
PID
Temperature
DiffDriveOdometry (with examples)
MassMatrix3
AxisAlignedBox
GaussMarkovProcess (with examples)
RotationSpline
Material
Kmeans
Triangle3
Pose3
Triangle
Spline
Filter
SemanticVersion
Matrix3
MovingWindowFilter
Line3
Quaternion
StopWatch
RollingMean
Line2
Color
Helpers
Rand (with examples)
Angle
Vector2, Vector3 and Vector4
Fix Color::HSV() incorrect hue output
Add example and modify document for class Color
Document that euler angles should be in radians for quaternion constructor
Fix windows warnings in Vector2, 3 and 4
Modified cmake target name for Ruby interfaces
Frustrum Python interface
quaternion_from_euler example: input degrees
Internal URL fixed (paragraph 266)
Added tutorials for vector, angle, triangle and rotation
Inertial Python interface
Box Python interfaces
DiffDriveOdometry Python interface
Sphere Python interface
Plane Python interfaces
Cylinder Python interface
Added SphericalCoordinates Python interface
MassMatrix3 Python interface
AxisAlignedBox Python interface
AxisAlignedBox: deprecate unimplemented methods
Gazebo Math 6.9.2 (2021-10-14)
Added StopWatch Python Interface
Fix clang warnings.
Fixed Helpers Python templates
Add Helpers Python interface
Add Python interface to Triangle3
Adds python interface to MaterialType and Material.
Remove Cylinder::SetLength const method
Gazebo Math 6.9.1 (2021-09-30)
Avoid assertAlmostEqual for python strings
Pose3_TEST.py: use 0.01 (not 0) in string test
Gazebo Math 6.9.0 (2021-09-28)
Volume below a plane for spheres and boxes
🌐 Spherical coordinates: bug fix, docs and sanity checks
Add Vector(2|3|4)
::NaN to easily create invalid vectors Add options to install python/ruby in system standard paths
Add eigen utils to convert mesh 3d vertices to oriented box
Python interface
Adds python interface to RollingMean, Color and Spline
Adds python interface for Kmeans and Vector3Stats
Adds python interface to PID and SemanticVersion.
Adds python interface to triangle.
Adds Line2, Line3, SignalStats, Temperature python interface
Python interface: Renames methods to match PEP8 style
Adds python interface to Filter, MovingWindowFilter, RotationSpline.
Adds python interface to Quaternion, Pose3, Matrix3 and Matrix4
Basic setup for Python interface using SWIG
👩🌾 Don’t use std::pow with integers in Vectors and handle sqrt
Relax expectations about zero in SpeedLimiter_TEST to make ARM happy
Infrastructure
Gazebo Math 6.8.0 (2021-03-30)
Add speed limiter class
Bazel Updates for math6
Add Equal tolerance method to Quaternion
Fix broken link in MassMatrix3.hh
Add instructions to build and run examples
Infrastructure and documentation
Remove unnecessary copy constructor declaration from Box
Windows installation via conda-forge
Add rule-of-five members for Angle
Ellipsoid: new shape class with inertia calculation method
Avoid moving a return value, it might prevent (N)RVO
Properly handle stream errors when reading math objects
Gazebo Math 6.7.0 (2020-11-23)
Capsule: new shape class with inertia calculation method
Add missing header to Color.hh
Improve tests of
Vector2
,Vector3
,Vector4
,Quaternion
, andPose3
Pose3: document
operator*
Quaternion: add Normalized() method
Vector2: add Round(), Rounded() methods
Add test for printing
inf
Vector3
Gazebo Math 6.6.0 (2020-09-16)
Add chrono duration helper functions
Gazebo Math 6.5.0 (2020-09-04)
Add string to time function
Added functions to convert between time_point and secNsec
Fix GZ_MATH_XXX_VERSION
Add Max and Min function to Vector2.hh
Round, Rounded, Correct, Distance(x, y, z, w) and operator< addition to Vector 4
Sum and normalized functions for Vector4
Vector4 Ruby tests - Vector4.i and Vector4_TEST.rb
Vector3 to vector4 functions
Update vector2 fuctions from vector3
Add Abs, Dot and AbsDot and respective tests to Vector4
Create abs, absDot and Correct functions for Vector2d
Document Ruby tests
Add header for numeric_limits allowing build on ubuntu 16.04
Add setter/getter for Pose’s each element
Implement AxisAlignedBox Volume function
Add operator + for AxisAlignedBox and Vector3.
Make alpha optional when parsing a Color from an input stream.
GitHub actions CI and workflow updates
Added a Gauss-Markov Process class.
Fix bug in Inertial addition of off-diagonal moment of inertia terms with pose offsets.
Create FAKE_INSTALL target so example compilation can be tested without doing a real install.
Angle: BitBucket pull request 335
Updating documentation.
Angle: BitBucket pull request 325
GraphAlgorithms: add ToUndirected(DirectedGraph) that copies to an UndirectedGraph.
Doxygen fixes for graph classes
Gazebo Math 6.4.0
Added a function that rounds up a number to the nearest multiple of another number.
Gazebo Math 6.3.0
Added Odometry class that computes odometry for a two wheeled vehicle.
Added RollingMean class.
Gazebo Math 6.2.0
eigen3: Use linear() instead of rotation() to prevent computation of SVD
Change definition of Pose3
*
operator to fix multiplication order
Gazebo Math 6.1.0
eigen3: add conversion functions for Eigen::AlignedBox3d <=> gz::math::AxisAlignedBox
Gazebo Math 6.0.0
Helper function that converts from
std::chrono::steady_clock::duration
to {seconds, nanoseconds}.Upgrade to c++17.
Gazebo Math 5.x
Gazebo Math 5.x.x
Gazebo Math 5.1.0 (2019-09-11)
GraphAlgorithms: add ToUndirected(DirectedGraph) that copies to an UndirectedGraph.
Doxygen fixes for graph classes
eigen3: Use linear() instead of rotation() to prevent computation of SVD
Change definition of Pose3
*
operator to fix multiplication ordereigen3: add conversion functions for Eigen::AlignedBox3d <=> gz::math::AxisAlignedBox
Gazebo Math 5.0.0 (2018-12-12)
Added a Stopwatch class
Added material properties to OrientedBox
Added a Cylinder class.
The
Box
class has been changed to a templatized class that is not axis-aligned. The previousBox
functionality is now in theAxisAlignedBox
class.Added eigen3 component with functions for converting between Eigen and gz-math types.
Added a
MassMatrix3::SetFromCylinder
function that uses aMaterial
to specify a density.Added a Sphere class.
Added a
MassMatrix3::SetFromSphere
function that uses aMaterial
to specify a density.Added a
MassMatrix3::SetFromBox
function that uses aMaterial
to specify a density.Deprecated mutator functions in MassMatrix3 that lacked a
Set
prefix.Updated the MassMatrix3::ValidMoments(), MassMatrix3::IsValid(), MassMatrix3::IsPositive(), and Inertial::SetMassMatrix functions to accept a tolerance parameter.
Add MassMatrix3::IsNearPositive and use it in MassMatrix3::IsValid, use >= instead of > in MassMatrix3::ValidMoments
Gazebo Math 4.x
Gazebo Math 4.x.x
Add Graph::EdgeFromVertices function that return an edge, if one exists, between two vertices.
Added multiply assign operator to Matrix4.
Add Plane copy constructor and fix cppcheck on artful
Added MovingWindowFilter, a copy from Gazebo Common. This version will replace the version found in Gazebo Common.
Added a Material class, which holds information about materials like wood, steel, and iron.
Gazebo Math 4.0.0 (2017-12-26)
Use std::stoi and std::stod in math::parse* functions to reduce code
Fixing const-correctness for operator* of Pose3
Deprecate Matrix4::Translate and replace by Matrix4::SetTranslation
Use ignition-cmake to simplify build scripts
Make constructor SemanticVersion(string) explicit
Switch to C++14
Removed the box ‘extent’ field. The default constructor now sets a box’s corners to extrema in order to indicate an uninitialized box.
Added graph utilites:
Added a Vertex class:
Added an Edge class:
Added a Graph class:
Added a GraphAlgorithms class:
Added a function to calculate connected components in undirected graphs:
Improved the performance of
graph::InDegree()
andgraph::IncidentsTo()
.
Added Inline Versioned Namespace
Gazebo Math 3.x
Gazebo Math 3.x.x
Gazebo Math 3.3.0 (2017-11-27)
Fixed frustum falsely saying it contained AABB in some cases
Create consistent bracket operators across all Vector# types
Change name to the generic BUILDING_DLL macro to avoid conflicts
Fix some compiler warnings
Suppress gtest warnings
Move private headers to src folder
Update configure.bat
Gazebo Math 3.2.0 (2017-05-15)
Construct on first use in Rand class
Extended Spline API: derivative interpolation, arc length calculation and tangent forcing.
Gazebo Math 3.1.0 (2017-04-11)
Added signum functions to Helpers.hh.
Contribution from Martin Pecka
Gazebo Math 3.0.0 (2017-01-05)
Deprecate many IGN_* macros in favor of static const variables in Helpers.hh
Removed exceptions. Return values should be evaluated to determine if errors have occured.
Added
operator=(const Quaternion<T> &_q)
toMatrix3
.Fix xenial cppcheck
Require cmake 2.8.12
Migrate to relocatable CMake package. Contribution from Silvio Traversaro.
Fix logic of installation of CMake configuration files in Windows. Contribution from Silvio Traversaro.
Gazebo Math 2.x
Gazebo Math 2.9 (2017-11-22)
Fixed frustum falsely saying it contained AABB in some cases
Added Color
Backport updated configure.bat to gz-math2 and fix cppcheck warnings
Gazebo Math 2.8
Gazebo Math 2.8.0
Added OrientedBox
Added an assignment operator to the Frustum class.
Gazebo Math 2.7
Gazebo Math 2.7.0
Add static const variables as alternative to macros in Helpers.hh
Add new methods for floating numbers: lessOrEqual and greaterOrEqual
Gazebo Math 2.6
Gazebo Math 2.6.0
Added copy constructor, equality operators and assignment operators to SphericalCoordinates class.
Fix Euler angle conversion of quaternions near singularities
Backport triangle3, helper functions, equality helper to work with 387 fp unit (Contribution from Rich Mattes).
Added Matrix4
::LookAt Set Inertial Rotations
Added SemanticVersion class
Gazebo Math 2.5
Gazebo Math 2.5.0
Added PID class
Added SphericalCoordinate class
Gazebo Math 2.4
Gazebo Math 2.4.1
Combine inertial properties of different objects, returning the equivalent inertial properties as if the objects were welded together.
Gazebo Math 2.4.0
New MassMatrix3 class
MassMatrix3 helper functions
Added Temperature class
A contribution from Shintaro Noda
Gazebo Math 2.3.0
Added simple volumes formulas
Add Length and SquaredLength for Vector2 with test
Add Equal function with numerical tolerance argument
First part of MassMatrix3 class, mostly accessors and modifiers
Add Transpose methods for Matrix3,4 with test
Multiplication improvements for Vector/Matrix classes
Scalar +,- operators for Vector[234]
Add Determinant method for Matrix[34]
Fixes for compiling and running tests on Windows 7/Visual Studio 2013 Contribution from Silvio Traversaro.