From 1ec9ab119eea4947829e55810daf30a9e250f089 Mon Sep 17 00:00:00 2001 From: Levi Armstrong Date: Tue, 10 Oct 2023 14:06:23 -0500 Subject: [PATCH] Add Eigen::Vector3d yaml support --- .../include/tesseract_common/yaml_utils.h | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tesseract_common/include/tesseract_common/yaml_utils.h b/tesseract_common/include/tesseract_common/yaml_utils.h index abd5205922e..4bbfafdda5e 100644 --- a/tesseract_common/include/tesseract_common/yaml_utils.h +++ b/tesseract_common/include/tesseract_common/yaml_utils.h @@ -358,6 +358,30 @@ struct convert } }; +template <> +struct convert +{ + static Node encode(const Eigen::Vector3d& rhs) + { + Node node; + for (long i = 0; i < rhs.size(); ++i) + node.push_back(rhs(i)); + + return node; + } + + static bool decode(const Node& node, Eigen::Vector3d& rhs) + { + if (!node.IsSequence() || (node.size() != 3)) + return false; + + for (long i = 0; i < 3; ++i) + rhs(i) = node[i].as(); + + return true; + } +}; + template <> struct convert {