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 }
inline ::std::string to_string(const ::Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > &value)
inline ::std::string format(const char *format, ::va_list args)
void setRotation(const Quaternion &q)
void getRPY(tf2Scalar &roll, tf2Scalar &pitch, tf2Scalar &yaw, unsigned int solution_number=1) const
Definition: any.hpp:15
inline ::std::string to_string(const ::tf2::Transform &value)


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Sat Jun 17 2023 02:32:53