From 6c1dd70e99e8e46b205ea89f556be59066183dd6 Mon Sep 17 00:00:00 2001 From: Rainer Kartmann <rainer.kartmann@kit.edu> Date: Tue, 19 May 2020 14:52:25 +0200 Subject: [PATCH] Add access to AABB --- .../ObjectPoseObserver/ObjectFinder.cpp | 17 +++++++++++++++++ .../ObjectPoseObserver/ObjectFinder.h | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/source/RobotAPI/components/ObjectPoseObserver/ObjectFinder.cpp b/source/RobotAPI/components/ObjectPoseObserver/ObjectFinder.cpp index 9081084cd..f9e85b2b4 100644 --- a/source/RobotAPI/components/ObjectPoseObserver/ObjectFinder.cpp +++ b/source/RobotAPI/components/ObjectPoseObserver/ObjectFinder.cpp @@ -1,6 +1,8 @@ #include "ObjectFinder.h" #include <SimoxUtility/filesystem/list_directory.h> +#include <SimoxUtility/json.h> +#include <SimoxUtility/shapes/AxisAlignedBoundingBox.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include <ArmarXCore/core/system/cmake/CMakePackageFinder.h> @@ -207,6 +209,21 @@ namespace armarx return file(".obj"); } + PackageFileLocation ObjectInfo::boundingBoxJson() const + { + return file(".json", "_bb"); + } + + simox::AxisAlignedBoundingBox ObjectInfo::aabb() const + { + nlohmann::json j = nlohmann::read_json(boundingBoxJson().absolutePath); + nlohmann::json jaabb = j.at("aabb"); + auto min = jaabb.at("min").get<Eigen::Vector3f>(); + auto max = jaabb.at("max").get<Eigen::Vector3f>(); + + return simox::AxisAlignedBoundingBox(min, max); + } + bool ObjectInfo::checkPaths() const { namespace fs = std::filesystem; diff --git a/source/RobotAPI/components/ObjectPoseObserver/ObjectFinder.h b/source/RobotAPI/components/ObjectPoseObserver/ObjectFinder.h index 1e6aee1b8..c0b08f07e 100644 --- a/source/RobotAPI/components/ObjectPoseObserver/ObjectFinder.h +++ b/source/RobotAPI/components/ObjectPoseObserver/ObjectFinder.h @@ -4,6 +4,10 @@ #include <ArmarXCore/core/logging/Logging.h> +namespace simox +{ + struct AxisAlignedBoundingBox; +} namespace armarx { @@ -82,6 +86,11 @@ namespace armarx PackageFileLocation simoxXML() const; PackageFileLocation wavefrontObj() const; + PackageFileLocation boundingBoxJson() const; + + simox::AxisAlignedBoundingBox aabb() const; + + /** * @brief Checks the existence of expected files. * If a file is does not exist, emits a warning returns false. -- GitLab