TypedDataDisplayVisitor.cpp
Go to the documentation of this file.
2 
3 #include <iomanip> // std::setprecision
4 
5 #include <SimoxUtility/algorithm/string.h>
6 #include <SimoxUtility/math/pose/pose.h>
7 
9 
13 
14 #include "DataDisplayVisitor.h"
15 
16 namespace armarx::aron
17 {
18 
19  std::string
21  {
23  data::visit(v, data, type);
24  return v.value.str();
25  }
26 
28  {
29  }
30 
31  void
33  {
35  }
36 
37  void
39  {
41  }
42 
43  void
45  {
47  }
48 
49  void
51  {
53  }
54 
55  void
57  {
59  }
60 
61  void
63  {
66  }
67 
68  void
70  {
73  }
74 
75  void
77  {
79  }
80 
81  void
83  {
85  }
86 
87  void
89  {
91  }
92 
93  void
95  const type::VariantPtr& type)
96  {
99 
100  if (enumType == nullptr or enumData == nullptr)
101  {
102  ARMARX_WARNING << "Enum Type or Data is NULL";
103  return;
104  }
105 
106  std::string name = enumType->getValueName(enumData->getValue());
107  value << name;
108  }
109 
110  /*void TypedDataDisplayVisitor::visitDateTime(const data::VariantPtr& data, const type::VariantPtr& type)
111  {
112  auto l = data::Long::DynamicCastAndCheck(data);
113  armem::Time time { armem::Duration::MicroSeconds(l->getValue()) };
114  value << armem::toDateTimeMilliSeconds(time);
115  }*/
116 
117 
118  template <typename ScalarT>
119  void
120  TypedDataDisplayVisitor::processMatrix(const type::Matrix& type, const data::NDArray& data)
121  {
122  Eigen::Map<Eigen::Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic>> m(
123  reinterpret_cast<ScalarT*>(data.getData()),
124  data.getShape().at(0),
125  data.getShape().at(1));
126  value << m.format(eigenIof);
127  }
128 
129  void
130  TypedDataDisplayVisitor::processQuaternion(const data::NDArray& data)
131  {
132  const Eigen::Quaternionf quat =
135  value << quat.w() << coeffSep << "|" << coeffSep << quat.x() << coeffSep << quat.y()
136  << coeffSep << quat.z();
137  }
138 
139  void
140  TypedDataDisplayVisitor::processPose(const type::Matrix&, const data::NDArray& d)
141  {
142  const Eigen::IOFormat eigenIof(Eigen::StreamPrecision, 0, " ", "\n", "( ", " )", "", "");
143  const std::string cdot = "\u00B7"; // center dot: https://unicode-table.com/de/00B7/
144 
145  auto getLines = [&](auto&& mat)
146  {
147  std::stringstream ss;
148  setStreamPrecision(ss);
149  ss << mat.format(eigenIof);
150  std::vector<std::string> lines = simox::alg::split(ss.str(), "\n");
151  ARMARX_CHECK_EQUAL(lines.size(), 3);
152  return lines;
153  };
154 
155  const Eigen::Matrix4f pose =
157  const std::vector<std::string> r = getLines(simox::math::orientation(pose));
158  const std::vector<std::string> t = getLines(simox::math::position(pose));
159 
160  std::vector<std::string> lines;
161  lines.push_back(r.at(0) + " \t" + t.at(0));
162  lines.push_back(r.at(1) + " " + cdot + " x + \t" + t.at(1));
163  lines.push_back(r.at(2) + " \t" + t.at(2));
164 
165  value << simox::alg::join(lines, "\n");
166  }
167 
168  void
169  TypedDataDisplayVisitor::processPosition(const type::Matrix&, const data::NDArray& d)
170  {
173  value << pos.format(eigenIof);
174  }
175 
176  void
178  {
180  }
181 
182  void
184  {
186  processQuaternion(d);
187  }
188 
189  void
191  {
192  // aron::typenavigator::ImagePixelType pixelType = ImageNavigator::pixelTypeFromName(data.getType());
193  //value << DataDisplayVisitor::getValue(data) << " pixel type: " << data.getType()";
195  }
196 
197  void
199  const type::VariantPtr& type)
200  {
202  }
203 
204 } // namespace armarx::aron
armarx::aron::TypedDataDisplayVisitor::visitImage
void visitImage(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:190
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
Matrix
Eigen::Matrix< T, 3, 3 > Matrix
Definition: UnscentedKalmanFilterTest.cpp:37
armarx::aron::TypedDataDisplayVisitor::getValue
static std::string getValue(const type::VariantPtr &type, const data::VariantPtr &data)
Definition: TypedDataDisplayVisitor.cpp:20
armarx::aron::data::converter::AronEigenConverter::ConvertToMatrix4f
static Eigen::Matrix4f ConvertToMatrix4f(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:57
armarx::aron::data::NDArray
Definition: NDArray.h:48
armarx::aron::TypedDataDisplayVisitor::visitPointCloud
void visitPointCloud(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:198
armarx::aron::StringStreamMixin::setStreamPrecision
void setStreamPrecision()
Definition: StringStreamMixin.cpp:13
armarx::aron::data::detail::SpecializedVariantBase< data::dto::NDArray, NDArray >::DynamicCastAndCheck
static PointerType DynamicCastAndCheck(const VariantPtr &n)
Definition: SpecializedVariant.h:135
armarx::aron::data::detail::SpecializedVariantBase< data::dto::AronInt, Int >::DynamicCast
static PointerType DynamicCast(const VariantPtr &n)
Definition: SpecializedVariant.h:117
armarx::aron::data::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::aron::TypedDataDisplayVisitor::visitString
void visitString(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:88
armarx::aron::TypedDataDisplayVisitor::visitBool
void visitBool(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:56
armarx::aron::TypedDataDisplayVisitor::visitDouble
void visitDouble(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:62
armarx::aron
Definition: DataDisplayVisitor.cpp:5
armarx::aron::type::detail::SpecializedVariantBase< type::dto::IntEnum, IntEnum >::DynamicCast
static IntEnum & DynamicCast(Variant &n)
Definition: SpecializedVariant.h:106
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::aron::TypedDataDisplayVisitor::visitMatrix
void visitMatrix(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:177
armarx::aron::StringStreamMixin::value
std::stringstream value
Definition: StringStreamMixin.h:20
armarx::aron::TypedDataDisplayVisitor::visitTuple
void visitTuple(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:50
All.h
EigenConverter.h
Eigen::Quaternionf
Quaternion< float, 0 > Quaternionf
Definition: EigenForwardDeclarations.h:61
armarx::aron::data::converter::AronEigenConverter::ConvertToQuaternionf
static Eigen::Quaternion< float > ConvertToQuaternionf(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:33
armarx::aron::TypedDataDisplayVisitor
Definition: TypedDataDisplayVisitor.h:15
armarx::aron::StringStreamMixin::eigenIof
const Eigen::IOFormat eigenIof
Definition: StringStreamMixin.h:24
armarx::aron::DataDisplayVisitor::getValue
static std::string getValue(const data::VariantPtr &n)
Definition: DataDisplayVisitor.cpp:9
armarx::aron::TypedDataDisplayVisitor::visitIntEnum
void visitIntEnum(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:94
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::aron::TypedDataDisplayVisitor::TypedDataDisplayVisitor
TypedDataDisplayVisitor()
Definition: TypedDataDisplayVisitor.cpp:27
armarx::aron::TypedDataDisplayVisitor::visitDict
void visitDict(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:32
TypedDataDisplayVisitor.h
Time.h
armarx::aron::TypedDataDisplayVisitor::visitObject
void visitObject(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:38
armarx::aron::data::visit
requires isVisitor< VisitorImplementation, typename VisitorImplementation::Input > void visit(VisitorImplementation &v, typename VisitorImplementation::Input &o)
Definition: Visitor.h:124
armarx::aron::TypedDataDisplayVisitor::visitFloat
void visitFloat(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:69
armarx::aron::type::IntEnumPtr
std::shared_ptr< IntEnum > IntEnumPtr
Definition: IntEnum.h:36
armarx::aron::TypedDataDisplayVisitor::visitLong
void visitLong(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:82
armarx::aron::TypedDataDisplayVisitor::visitQuaternion
void visitQuaternion(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:183
Logging.h
armarx::aron::TypedDataDisplayVisitor::visitInt
void visitInt(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:76
armarx::aron::StringStreamMixin::coeffSep
const std::string coeffSep
Definition: StringStreamMixin.h:23
armarx::aron::data::IntPtr
std::shared_ptr< Int > IntPtr
Definition: forward_declarations.h:23
ARMARX_CHECK_EQUAL
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
Definition: ExpressionException.h:130
armarx::aron::TypedDataDisplayVisitor::visitList
void visitList(const data::VariantPtr &data, const type::VariantPtr &type) override
Definition: TypedDataDisplayVisitor.cpp:44
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::aron::type::Matrix
The Matrix class.
Definition: Matrix.h:39
armarx::aron::data::converter::AronEigenConverter::ConvertToVector3f
static Eigen::Vector3f ConvertToVector3f(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:45
armarx::split
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelpers.cpp:36
DataDisplayVisitor.h