string_utils/tf2.hpp
Go to the documentation of this file.
1 #pragma once
2 
11 #include <string>
12 
13 #include <tf2/LinearMath/Vector3.h>
17 
18 namespace cras
19 {
20 
21 inline ::std::string to_string(const ::tf2::Vector3& value)
22 {
23  return ::cras::format("[%.6f, %.6f, %.6f]", value.getX(), value.getY(), value.getZ());
24 }
25 
26 inline ::std::string to_string(const ::tf2::Quaternion& value)
27 {
29  m.setRotation(value);
30  double roll, pitch, yaw;
31  m.getRPY(roll, pitch, yaw);
32  return ::cras::format("[x=%.6f, y=%.6f, z=%.6f, w=%.6f (r=%.3f, p=%.3f, y=%.3f)]",
33  value.getX(), value.getY(), value.getZ(), value.getW(), roll, pitch, yaw);
34 }
35 
36 inline ::std::string to_string(const ::tf2::Matrix3x3& value)
37 {
38  return ::cras::format("[[%.6f, %.6f, %.6f]; [%.6f, %.6f, %.6f]; [%.6f, %.6f, %.6f]]",
39  value.getRow(0).getX(), value.getRow(0).getY(), value.getRow(0).getZ(),
40  value.getRow(1).getX(), value.getRow(1).getY(), value.getRow(1).getZ(),
41  value.getRow(2).getX(), value.getRow(2).getY(), value.getRow(2).getZ());
42 }
43 
44 inline ::std::string to_string(const ::tf2::Transform& value)
45 {
46  return "Transform(t=" + ::cras::to_string(value.getOrigin()) + ", r=" +
47  ::cras::to_string(value.getRotation()) + ")";
48 }
49 
50 }
cras::to_string
inline ::std::string to_string(const ::tf2::Transform &value)
Definition: string_utils/tf2.hpp:44
cras
Definition: any.hpp:15
cras::format
inline ::std::string format(::std::string format,...)
Definition: string_utils.hpp:280
Vector3.h
tf2::Matrix3x3::setRotation
void setRotation(const Quaternion &q)
tf2::Matrix3x3::getRPY
void getRPY(tf2Scalar &roll, tf2Scalar &pitch, tf2Scalar &yaw, unsigned int solution_number=1) const
Quaternion.h
cras::to_string
inline ::std::string to_string(const ::Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > &value)
Definition: string_utils/eigen.hpp:21
tf2::Matrix3x3
Matrix3x3.h
Transform.h


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 26 2024 03:49:04