tf2_2d package from tf2_2d repo

tf2_2d

Package Summary

Tags No category tags.
Version 1.0.1
License BSD
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/locusrobotics/tf2_2d.git
VCS Type git
VCS Version rolling
Last Updated 2024-03-04
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A set of 2D geometry classes modeled after the 3D geometry classes in tf2.

Additional Links

No additional links.

Maintainers

  • Stephen Williams

Authors

  • Stephen Williams

tf2_2d

A set of 2D geometry classes modeled after the 3D geometry classes in tf2.

Using tf2 toMsg() and fromMsg()

I've tried to include fromMsg() implementations for anything that remotely makes sense. The tf2 toMsg() signature does limit its use to a single output type, so I've had to make a guess as to the most useful variation there.

For example:

#include <tf2_2d/tf2_2d.h>     // This header includes the tf2 conversion functions
#include <tf2_2d/transform.h>  // Then include what you use

// Convert a tf2_2d object into a 3D message
auto transform_2d = tf2_2d::Transform(1.0, 1.5, 2.0);
geometry_msgs::Transform transform_3d_msg = tf2::toMsg(transform_2d);

// Convert a 3D message into a 2D tf2_2d object
geometry_msgs::Transform transform_3d_msg;
tf2_2d::Transform transform_2d;
tf2::fromMsg(transform_3d_msg, transform_2d);

// You can do Stamped<> things as well
auto transform_2d = tf2::Stamped<tf2_2d::Transform>(tf2_2d::Transform(1.0, 1.5, 2.0), ros::Time(1.2), "frame");
geometry_msgs::TransformStamped transform_3d_msg = tf2::toMsg(transform_2d);

Conversion of Points and Quaternions are also supported, as are conversions to other datatypes that are handled by tf2's conversion system.

Transformation math

The tf2_2d types also implement all of the expected transformation math.

auto v1 = tf2_2d::Vector2(1.0, 2.0);
auto v2 = tf2_2d::Vector2(1.5, 2.5);
auto v3 = v1 + v2;                             // v3 == (2.5, 4.5)

tf2_2d::Rotation r1(M_PI);
auto v4 = r1.rotate(v1);                       // v4 == (-2.0, 1.0)

auto t1 = tf2_2d::Transform(1.0, 2.0, 3.0);
auto t2 = tf2_2d::Transform(-2.0, -1.0, -1.5);
auto t3 = t1 * t2;                             // t3 == (3.12, 2.70, 1.5)

auto t4 = tf2_2d::Transform(1.0, 2.0, 3.0);
auto t5 = tf2_2d::Transform(-2.0, -1.0, -1.5);
auto t6 = t4.inverseTimes(t5);                 // t6 == (2.54, 3.39, 1.78)

The tf2_2d::Rotation class deserves a few additional notes. The angle stored in a Rotation object is always within the (-Pi, Pi] range. You can construct a Rotation object with any floating point value, but it will be wrapped to that range. You can also perform arithmetic with the angles, without worrying about wrapping issues.

tf2_2d::Rotation r1(1.0);
auto r2 = 17.0 * r1;       // r2.angle() == -1.84956

tf2_2d::Rotation r3(1.0);
tf2_2d::Rotation r4(3.0);
auto r5 = r3 + r4;         // r5.angle() == -2.28319

tf2_2d::Rotation r6(-3.0);
tf2_2d::Rotation r7(1.0);
auto r8 = r6 - r7;         // r8.angle() == 2.28319

Additionally, the tf2_td::Rotation class caches the sin/cos results needed to perform rotations. So, once a Rotation object is used to rotate something, the trig functions will never be evaluated again. And the cached sin/cos values will propagate to any derived objects that it can. This includes the Rotation object built into a Transform.

tf2_2d::Vector2 v1(1.0, 2.0);
tf2_2d::Rotation r1(1.0);            // No sin/cos calls have been made, since it is not needed yet
auto v2 = r1.rotate(v1);             // Computes sin/cos and remembers it
auto v3 = r1.unrotate(v2);           // Does not need to compute sin/cos again
tf2_2d::Rotation r2 = r1;            // Transfers sin/cos to r2
auto v4 = r2.rotate(v1);             // Does not need to compute sin/cos because it stole the cached values from r1
tf2_2d::Rotation r3 = r1.inverse();  // Inverts and transfers sin/cos to r3
auto v5 = r3.rotate(v1);             // Does not need to compute sin/cos because it stole the cached values from r1

CHANGELOG

Changelog for package tf2_2d

1.0.1 (2023-03-03)

  • Port tf2_2d to ROS 2 (#5)
    • Build sytem changes for ROS 2
    • Code changes for ROS 2
    • Don\'t need int main(); because linking to GTEST_MAIN_LIBRARIES
    • Skip ament_cmake_copyright
    • Move .h headers to .hpp
    • Add .h headers with warning for backwards compatability
    • Linter fixes: Satisfy Uncrustify
    • Linter fixes: Satisfy cpplint
    • Minimum CMake 3.14.4
    • \${tf2_geometry_msgs_TARGETS} -> tf2_geometry_msgs::tf2_geometry_msgs
    • Bump copywrite date on redirection headers
    • Remove Scalar.h include
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: Shane Loretz, locus-services

0.6.4 (2021-07-14)

  • Handling issue with tf2 circular dependency (#4)
    • Handling issue with tf2 circular dependency and other warnings
  • Contributors: Tom Moore

0.6.3 (2021-07-13)

  • Fixing package license
  • Contributors: Tom Moore

0.6.2 (2021-07-12)

  • Fix test build issue in noetic
  • Contributors: Tom Moore

0.6.1 (2021-07-11)

  • Contributors: locus-services

0.6.0 (2020-10-02)

  • Contributors: locus-services

0.5.0 (2019-07-12)

  • License cleanup (#3)
  • Contributors: Stephen Williams, locus-services

0.4.0 (2019-03-18)

  • Contributors: locus-services

0.3.0 (2019-01-16)

  • [RST-1548] transform covariance (#2)
    • Added conversions to Eigen types
    • Added stream operators
    • Added some additional toMsg conversions using a non-tf2-standard signature
    • Added functions to transform SE2 covariance matrices
  • Tailor: Creating Jenkinsfile
  • Expanded readme
  • Renamed the Transform rotation value to \'yaw\'
  • Moved into separate repo
  • Contributors: Stephen Williams, locus-services

0.2.0 (2018-04-16)

  • Adding tf_2d constructor overload from a standard tf transform
  • Contributors: Stephen Williams, Tom Moore

0.1.0 (2018-02-14)

  • Small trig cache optimization in the \'unrotate()\' function
  • Added 2D geometry classes (vector, rotation, transform) and conversion functions in the style of the tf2 3D geometry classes
  • Contributors: Stephen Williams

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged tf2_2d at Robotics Stack Exchange

tf2_2d package from tf2_2d repo

tf2_2d

Package Summary

Tags No category tags.
Version 1.0.1
License BSD
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/locusrobotics/tf2_2d.git
VCS Type git
VCS Version rolling
Last Updated 2024-03-04
Dev Status MAINTAINED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A set of 2D geometry classes modeled after the 3D geometry classes in tf2.

Additional Links

No additional links.

Maintainers

  • Stephen Williams

Authors

  • Stephen Williams

tf2_2d

A set of 2D geometry classes modeled after the 3D geometry classes in tf2.

Using tf2 toMsg() and fromMsg()

I've tried to include fromMsg() implementations for anything that remotely makes sense. The tf2 toMsg() signature does limit its use to a single output type, so I've had to make a guess as to the most useful variation there.

For example:

#include <tf2_2d/tf2_2d.h>     // This header includes the tf2 conversion functions
#include <tf2_2d/transform.h>  // Then include what you use

// Convert a tf2_2d object into a 3D message
auto transform_2d = tf2_2d::Transform(1.0, 1.5, 2.0);
geometry_msgs::Transform transform_3d_msg = tf2::toMsg(transform_2d);

// Convert a 3D message into a 2D tf2_2d object
geometry_msgs::Transform transform_3d_msg;
tf2_2d::Transform transform_2d;
tf2::fromMsg(transform_3d_msg, transform_2d);

// You can do Stamped<> things as well
auto transform_2d = tf2::Stamped<tf2_2d::Transform>(tf2_2d::Transform(1.0, 1.5, 2.0), ros::Time(1.2), "frame");
geometry_msgs::TransformStamped transform_3d_msg = tf2::toMsg(transform_2d);

Conversion of Points and Quaternions are also supported, as are conversions to other datatypes that are handled by tf2's conversion system.

Transformation math

The tf2_2d types also implement all of the expected transformation math.

auto v1 = tf2_2d::Vector2(1.0, 2.0);
auto v2 = tf2_2d::Vector2(1.5, 2.5);
auto v3 = v1 + v2;                             // v3 == (2.5, 4.5)

tf2_2d::Rotation r1(M_PI);
auto v4 = r1.rotate(v1);                       // v4 == (-2.0, 1.0)

auto t1 = tf2_2d::Transform(1.0, 2.0, 3.0);
auto t2 = tf2_2d::Transform(-2.0, -1.0, -1.5);
auto t3 = t1 * t2;                             // t3 == (3.12, 2.70, 1.5)

auto t4 = tf2_2d::Transform(1.0, 2.0, 3.0);
auto t5 = tf2_2d::Transform(-2.0, -1.0, -1.5);
auto t6 = t4.inverseTimes(t5);                 // t6 == (2.54, 3.39, 1.78)

The tf2_2d::Rotation class deserves a few additional notes. The angle stored in a Rotation object is always within the (-Pi, Pi] range. You can construct a Rotation object with any floating point value, but it will be wrapped to that range. You can also perform arithmetic with the angles, without worrying about wrapping issues.

tf2_2d::Rotation r1(1.0);
auto r2 = 17.0 * r1;       // r2.angle() == -1.84956

tf2_2d::Rotation r3(1.0);
tf2_2d::Rotation r4(3.0);
auto r5 = r3 + r4;         // r5.angle() == -2.28319

tf2_2d::Rotation r6(-3.0);
tf2_2d::Rotation r7(1.0);
auto r8 = r6 - r7;         // r8.angle() == 2.28319

Additionally, the tf2_td::Rotation class caches the sin/cos results needed to perform rotations. So, once a Rotation object is used to rotate something, the trig functions will never be evaluated again. And the cached sin/cos values will propagate to any derived objects that it can. This includes the Rotation object built into a Transform.

tf2_2d::Vector2 v1(1.0, 2.0);
tf2_2d::Rotation r1(1.0);            // No sin/cos calls have been made, since it is not needed yet
auto v2 = r1.rotate(v1);             // Computes sin/cos and remembers it
auto v3 = r1.unrotate(v2);           // Does not need to compute sin/cos again
tf2_2d::Rotation r2 = r1;            // Transfers sin/cos to r2
auto v4 = r2.rotate(v1);             // Does not need to compute sin/cos because it stole the cached values from r1
tf2_2d::Rotation r3 = r1.inverse();  // Inverts and transfers sin/cos to r3
auto v5 = r3.rotate(v1);             // Does not need to compute sin/cos because it stole the cached values from r1

CHANGELOG

Changelog for package tf2_2d

1.0.1 (2023-03-03)

  • Port tf2_2d to ROS 2 (#5)
    • Build sytem changes for ROS 2
    • Code changes for ROS 2
    • Don\'t need int main(); because linking to GTEST_MAIN_LIBRARIES
    • Skip ament_cmake_copyright
    • Move .h headers to .hpp
    • Add .h headers with warning for backwards compatability
    • Linter fixes: Satisfy Uncrustify
    • Linter fixes: Satisfy cpplint
    • Minimum CMake 3.14.4
    • \${tf2_geometry_msgs_TARGETS} -> tf2_geometry_msgs::tf2_geometry_msgs
    • Bump copywrite date on redirection headers
    • Remove Scalar.h include
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: Shane Loretz, locus-services

0.6.4 (2021-07-14)

  • Handling issue with tf2 circular dependency (#4)
    • Handling issue with tf2 circular dependency and other warnings
  • Contributors: Tom Moore

0.6.3 (2021-07-13)

  • Fixing package license
  • Contributors: Tom Moore

0.6.2 (2021-07-12)

  • Fix test build issue in noetic
  • Contributors: Tom Moore

0.6.1 (2021-07-11)

  • Contributors: locus-services

0.6.0 (2020-10-02)

  • Contributors: locus-services

0.5.0 (2019-07-12)

  • License cleanup (#3)
  • Contributors: Stephen Williams, locus-services

0.4.0 (2019-03-18)

  • Contributors: locus-services

0.3.0 (2019-01-16)

  • [RST-1548] transform covariance (#2)
    • Added conversions to Eigen types
    • Added stream operators
    • Added some additional toMsg conversions using a non-tf2-standard signature
    • Added functions to transform SE2 covariance matrices
  • Tailor: Creating Jenkinsfile
  • Expanded readme
  • Renamed the Transform rotation value to \'yaw\'
  • Moved into separate repo
  • Contributors: Stephen Williams, locus-services

0.2.0 (2018-04-16)

  • Adding tf_2d constructor overload from a standard tf transform
  • Contributors: Stephen Williams, Tom Moore

0.1.0 (2018-02-14)

  • Small trig cache optimization in the \'unrotate()\' function
  • Added 2D geometry classes (vector, rotation, transform) and conversion functions in the style of the tf2 3D geometry classes
  • Contributors: Stephen Williams

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged tf2_2d at Robotics Stack Exchange

tf2_2d package from tf2_2d repo

tf2_2d

Package Summary

Tags No category tags.
Version 0.10.0
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/locusrobotics/tf2_2d.git
VCS Type git
VCS Version devel
Last Updated 2024-02-02
Dev Status MAINTAINED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A set of 2D geometry classes modeled after the 3D geometry classes in tf2.

Additional Links

No additional links.

Maintainers

  • Stephen Williams

Authors

  • Stephen Williams

tf2_2d

A set of 2D geometry classes modeled after the 3D geometry classes in tf2.

Using tf2 toMsg() and fromMsg()

I've tried to include fromMsg() implementations for anything that remotely makes sense. The tf2 toMsg() signature does limit its use to a single output type, so I've had to make a guess as to the most useful variation there.

For example:

#include <tf2_2d/tf2_2d.h>     // This header includes the tf2 conversion functions
#include <tf2_2d/transform.h>  // Then include what you use

// Convert a tf2_2d object into a 3D message
auto transform_2d = tf2_2d::Transform(1.0, 1.5, 2.0);
geometry_msgs::Transform transform_3d_msg = tf2::toMsg(transform_2d);

// Convert a 3D message into a 2D tf2_2d object
geometry_msgs::Transform transform_3d_msg;
tf2_2d::Transform transform_2d;
tf2::fromMsg(transform_3d_msg, transform_2d);

// You can do Stamped<> things as well
auto transform_2d = tf2::Stamped<tf2_2d::Transform>(tf2_2d::Transform(1.0, 1.5, 2.0), ros::Time(1.2), "frame");
geometry_msgs::TransformStamped transform_3d_msg = tf2::toMsg(transform_2d);

Conversion of Points and Quaternions are also supported, as are conversions to other datatypes that are handled by tf2's conversion system.

Transformation math

The tf2_2d types also implement all of the expected transformation math.

auto v1 = tf2_2d::Vector2(1.0, 2.0);
auto v2 = tf2_2d::Vector2(1.5, 2.5);
auto v3 = v1 + v2;                             // v3 == (2.5, 4.5)

tf2_2d::Rotation r1(M_PI);
auto v4 = r1.rotate(v1);                       // v4 == (-2.0, 1.0)

auto t1 = tf2_2d::Transform(1.0, 2.0, 3.0);
auto t2 = tf2_2d::Transform(-2.0, -1.0, -1.5);
auto t3 = t1 * t2;                             // t3 == (3.12, 2.70, 1.5)

auto t4 = tf2_2d::Transform(1.0, 2.0, 3.0);
auto t5 = tf2_2d::Transform(-2.0, -1.0, -1.5);
auto t6 = t4.inverseTimes(t5);                 // t6 == (2.54, 3.39, 1.78)

The tf2_2d::Rotation class deserves a few additional notes. The angle stored in a Rotation object is always within the (-Pi, Pi] range. You can construct a Rotation object with any floating point value, but it will be wrapped to that range. You can also perform arithmetic with the angles, without worrying about wrapping issues.

tf2_2d::Rotation r1(1.0);
auto r2 = 17.0 * r1;       // r2.angle() == -1.84956

tf2_2d::Rotation r3(1.0);
tf2_2d::Rotation r4(3.0);
auto r5 = r3 + r4;         // r5.angle() == -2.28319

tf2_2d::Rotation r6(-3.0);
tf2_2d::Rotation r7(1.0);
auto r8 = r6 - r7;         // r8.angle() == 2.28319

Additionally, the tf2_td::Rotation class caches the sin/cos results needed to perform rotations. So, once a Rotation object is used to rotate something, the trig functions will never be evaluated again. And the cached sin/cos values will propagate to any derived objects that it can. This includes the Rotation object built into a Transform.

tf2_2d::Vector2 v1(1.0, 2.0);
tf2_2d::Rotation r1(1.0);            // No sin/cos calls have been made, since it is not needed yet
auto v2 = r1.rotate(v1);             // Computes sin/cos and remembers it
auto v3 = r1.unrotate(v2);           // Does not need to compute sin/cos again
tf2_2d::Rotation r2 = r1;            // Transfers sin/cos to r2
auto v4 = r2.rotate(v1);             // Does not need to compute sin/cos because it stole the cached values from r1
tf2_2d::Rotation r3 = r1.inverse();  // Inverts and transfers sin/cos to r3
auto v5 = r3.rotate(v1);             // Does not need to compute sin/cos because it stole the cached values from r1

CHANGELOG

Changelog for package tf2_2d

0.7.0 (2022-02-23)

  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: locus-services

0.8.0 (2023-02-22)

  • 0.7.0
  • Update changelogs
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: Gary Servin, locus-services

0.9.0 (2023-09-25)

  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • 0.8.0
  • Update changelogs
  • 0.7.0
  • Update changelogs
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: Gary Servin, locus-services

0.10.0 (2024-02-02)

  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • 0.9.0
  • Update changelogs
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • 0.8.0
  • Update changelogs
  • 0.7.0
  • Update changelogs
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: Gary Servin, locus-services

0.6.4 (2021-07-14)

  • Handling issue with tf2 circular dependency (#4)
    • Handling issue with tf2 circular dependency and other warnings
  • Contributors: Tom Moore

0.6.3 (2021-07-13)

  • Fixing package license
  • Contributors: Tom Moore

0.6.2 (2021-07-12)

  • Fix test build issue in noetic
  • Contributors: Tom Moore

0.6.1 (2021-07-11)

  • Contributors: locus-services

0.6.0 (2020-10-02)

  • Contributors: locus-services

0.5.0 (2019-07-12)

  • License cleanup (#3)
  • Contributors: Stephen Williams, locus-services

0.4.0 (2019-03-18)

  • Contributors: locus-services

0.3.0 (2019-01-16)

  • [RST-1548] transform covariance (#2)
    • Added conversions to Eigen types
    • Added stream operators
    • Added some additional toMsg conversions using a non-tf2-standard signature
    • Added functions to transform SE2 covariance matrices
  • Tailor: Creating Jenkinsfile
  • Expanded readme
  • Renamed the Transform rotation value to \'yaw\'
  • Moved into separate repo
  • Contributors: Stephen Williams, locus-services

0.2.0 (2018-04-16)

  • Adding tf_2d constructor overload from a standard tf transform
  • Contributors: Stephen Williams, Tom Moore

0.1.0 (2018-02-14)

  • Small trig cache optimization in the \'unrotate()\' function
  • Added 2D geometry classes (vector, rotation, transform) and conversion functions in the style of the tf2 3D geometry classes
  • Contributors: Stephen Williams

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Package Dependencies

System Dependencies

Name
eigen

Dependant Packages

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged tf2_2d at Robotics Stack Exchange

tf2_2d package from tf2_2d repo

tf2_2d

Package Summary

Tags No category tags.
Version 0.10.0
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/locusrobotics/tf2_2d.git
VCS Type git
VCS Version devel
Last Updated 2024-02-02
Dev Status MAINTAINED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A set of 2D geometry classes modeled after the 3D geometry classes in tf2.

Additional Links

No additional links.

Maintainers

  • Stephen Williams

Authors

  • Stephen Williams

tf2_2d

A set of 2D geometry classes modeled after the 3D geometry classes in tf2.

Using tf2 toMsg() and fromMsg()

I've tried to include fromMsg() implementations for anything that remotely makes sense. The tf2 toMsg() signature does limit its use to a single output type, so I've had to make a guess as to the most useful variation there.

For example:

#include <tf2_2d/tf2_2d.h>     // This header includes the tf2 conversion functions
#include <tf2_2d/transform.h>  // Then include what you use

// Convert a tf2_2d object into a 3D message
auto transform_2d = tf2_2d::Transform(1.0, 1.5, 2.0);
geometry_msgs::Transform transform_3d_msg = tf2::toMsg(transform_2d);

// Convert a 3D message into a 2D tf2_2d object
geometry_msgs::Transform transform_3d_msg;
tf2_2d::Transform transform_2d;
tf2::fromMsg(transform_3d_msg, transform_2d);

// You can do Stamped<> things as well
auto transform_2d = tf2::Stamped<tf2_2d::Transform>(tf2_2d::Transform(1.0, 1.5, 2.0), ros::Time(1.2), "frame");
geometry_msgs::TransformStamped transform_3d_msg = tf2::toMsg(transform_2d);

Conversion of Points and Quaternions are also supported, as are conversions to other datatypes that are handled by tf2's conversion system.

Transformation math

The tf2_2d types also implement all of the expected transformation math.

auto v1 = tf2_2d::Vector2(1.0, 2.0);
auto v2 = tf2_2d::Vector2(1.5, 2.5);
auto v3 = v1 + v2;                             // v3 == (2.5, 4.5)

tf2_2d::Rotation r1(M_PI);
auto v4 = r1.rotate(v1);                       // v4 == (-2.0, 1.0)

auto t1 = tf2_2d::Transform(1.0, 2.0, 3.0);
auto t2 = tf2_2d::Transform(-2.0, -1.0, -1.5);
auto t3 = t1 * t2;                             // t3 == (3.12, 2.70, 1.5)

auto t4 = tf2_2d::Transform(1.0, 2.0, 3.0);
auto t5 = tf2_2d::Transform(-2.0, -1.0, -1.5);
auto t6 = t4.inverseTimes(t5);                 // t6 == (2.54, 3.39, 1.78)

The tf2_2d::Rotation class deserves a few additional notes. The angle stored in a Rotation object is always within the (-Pi, Pi] range. You can construct a Rotation object with any floating point value, but it will be wrapped to that range. You can also perform arithmetic with the angles, without worrying about wrapping issues.

tf2_2d::Rotation r1(1.0);
auto r2 = 17.0 * r1;       // r2.angle() == -1.84956

tf2_2d::Rotation r3(1.0);
tf2_2d::Rotation r4(3.0);
auto r5 = r3 + r4;         // r5.angle() == -2.28319

tf2_2d::Rotation r6(-3.0);
tf2_2d::Rotation r7(1.0);
auto r8 = r6 - r7;         // r8.angle() == 2.28319

Additionally, the tf2_td::Rotation class caches the sin/cos results needed to perform rotations. So, once a Rotation object is used to rotate something, the trig functions will never be evaluated again. And the cached sin/cos values will propagate to any derived objects that it can. This includes the Rotation object built into a Transform.

tf2_2d::Vector2 v1(1.0, 2.0);
tf2_2d::Rotation r1(1.0);            // No sin/cos calls have been made, since it is not needed yet
auto v2 = r1.rotate(v1);             // Computes sin/cos and remembers it
auto v3 = r1.unrotate(v2);           // Does not need to compute sin/cos again
tf2_2d::Rotation r2 = r1;            // Transfers sin/cos to r2
auto v4 = r2.rotate(v1);             // Does not need to compute sin/cos because it stole the cached values from r1
tf2_2d::Rotation r3 = r1.inverse();  // Inverts and transfers sin/cos to r3
auto v5 = r3.rotate(v1);             // Does not need to compute sin/cos because it stole the cached values from r1

CHANGELOG

Changelog for package tf2_2d

0.7.0 (2022-02-23)

  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: locus-services

0.8.0 (2023-02-22)

  • 0.7.0
  • Update changelogs
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: Gary Servin, locus-services

0.9.0 (2023-09-25)

  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • 0.8.0
  • Update changelogs
  • 0.7.0
  • Update changelogs
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: Gary Servin, locus-services

0.10.0 (2024-02-02)

  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • 0.9.0
  • Update changelogs
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • 0.8.0
  • Update changelogs
  • 0.7.0
  • Update changelogs
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Tailor: Updating Jenkinsfile
  • Contributors: Gary Servin, locus-services

0.6.4 (2021-07-14)

  • Handling issue with tf2 circular dependency (#4)
    • Handling issue with tf2 circular dependency and other warnings
  • Contributors: Tom Moore

0.6.3 (2021-07-13)

  • Fixing package license
  • Contributors: Tom Moore

0.6.2 (2021-07-12)

  • Fix test build issue in noetic
  • Contributors: Tom Moore

0.6.1 (2021-07-11)

  • Contributors: locus-services

0.6.0 (2020-10-02)

  • Contributors: locus-services

0.5.0 (2019-07-12)

  • License cleanup (#3)
  • Contributors: Stephen Williams, locus-services

0.4.0 (2019-03-18)

  • Contributors: locus-services

0.3.0 (2019-01-16)

  • [RST-1548] transform covariance (#2)
    • Added conversions to Eigen types
    • Added stream operators
    • Added some additional toMsg conversions using a non-tf2-standard signature
    • Added functions to transform SE2 covariance matrices
  • Tailor: Creating Jenkinsfile
  • Expanded readme
  • Renamed the Transform rotation value to \'yaw\'
  • Moved into separate repo
  • Contributors: Stephen Williams, locus-services

0.2.0 (2018-04-16)

  • Adding tf_2d constructor overload from a standard tf transform
  • Contributors: Stephen Williams, Tom Moore

0.1.0 (2018-02-14)

  • Small trig cache optimization in the \'unrotate()\' function
  • Added 2D geometry classes (vector, rotation, transform) and conversion functions in the style of the tf2 3D geometry classes
  • Contributors: Stephen Williams

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Package Dependencies

System Dependencies

Name
eigen

Dependant Packages

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged tf2_2d at Robotics Stack Exchange