diff --git a/scenarios/ArMemObjectMemory/config/ObjectMemory.cfg b/scenarios/ArMemObjectMemory/config/ObjectMemory.cfg index df483eb31778702f71c8a1ff6c13bf260f86c605..b8a602e969d23f0e85cb0be79d4471a271fd8885 100644 --- a/scenarios/ArMemObjectMemory/config/ObjectMemory.cfg +++ b/scenarios/ArMemObjectMemory/config/ObjectMemory.cfg @@ -193,10 +193,10 @@ ArmarX.AdditionalPackages = ArmarXObjects # ArmarX.ObjectMemory.mem.articulated.cls.ObjectsPackage: Name of the objects package to load from. # Attributes: -# - Default: ArmarXObjects +# - Default: PriorKnowledgeData # - Case sensitivity: yes # - Required: no -# ArmarX.ObjectMemory.mem.articulated.cls.ObjectsPackage = ArmarXObjects +# ArmarX.ObjectMemory.mem.articulated.cls.ObjectsPackage = PriorKnowledgeData # ArmarX.ObjectMemory.mem.articulated.inst.CoreSegmentName: Name of the object instance core segment. @@ -293,10 +293,10 @@ ArmarX.AdditionalPackages = ArmarXObjects # ArmarX.ObjectMemory.mem.cls.ObjectsPackage: Name of the objects package to load from. # Attributes: -# - Default: ArmarXObjects +# - Default: PriorKnowledgeData # - Case sensitivity: yes # - Required: no -# ArmarX.ObjectMemory.mem.cls.ObjectsPackage = ArmarXObjects +# ArmarX.ObjectMemory.mem.cls.ObjectsPackage = PriorKnowledgeData # ArmarX.ObjectMemory.mem.inst.CoreSegmentName: Name of the object instance core segment. diff --git a/source/RobotAPI/components/ArViz/Client/Elements.cpp b/source/RobotAPI/components/ArViz/Client/Elements.cpp index 3ce3ea6f48c69658788abc3ba2ed00c6a81e1002..daec8bc655e0f6431dc531f0401478838e7f053b 100644 --- a/source/RobotAPI/components/ArViz/Client/Elements.cpp +++ b/source/RobotAPI/components/ArViz/Client/Elements.cpp @@ -9,15 +9,18 @@ namespace armarx::viz { const std::string Object::DefaultObjectsPackage = armarx::ObjectFinder::DefaultObjectsPackageName; + const std::string Object::DefaultRelativeObjectsDirectory = armarx::ObjectFinder::DefaultObjectsDirectory; - Object& Object::fileByObjectFinder(const std::string& objectID, const std::string& objectsPackage) + Object& Object::fileByObjectFinder(const std::string& objectID, const std::string& objectsPackage, + const std::string& relativeObjectsDirectory) { - return this->fileByObjectFinder(armarx::ObjectID(objectID), objectsPackage); + return this->fileByObjectFinder(armarx::ObjectID(objectID), objectsPackage, relativeObjectsDirectory); } - Object& Object::fileByObjectFinder(const armarx::ObjectID& objectID, const std::string& objectsPackage) + Object& Object::fileByObjectFinder(const armarx::ObjectID& objectID, const std::string& objectsPackage, + const std::string& relativeObjectsDirectory) { - ObjectInfo info(objectsPackage, "", objectID); + ObjectInfo info(objectsPackage, "", relativeObjectsDirectory, objectID); armarx::PackageFileLocation file = info.simoxXML(); return this->file(file.package, file.relativePath); } diff --git a/source/RobotAPI/components/ArViz/Client/Elements.h b/source/RobotAPI/components/ArViz/Client/Elements.h index 66f07992e0ba2dc0c382b3a9742a5413c9f192b6..e9157a24d9f60b9ba71d70cccd2141b0258665c3 100644 --- a/source/RobotAPI/components/ArViz/Client/Elements.h +++ b/source/RobotAPI/components/ArViz/Client/Elements.h @@ -461,6 +461,7 @@ namespace armarx::viz { private: static const std::string DefaultObjectsPackage; + static const std::string DefaultRelativeObjectsDirectory; public: using ElementOps::ElementOps; @@ -483,8 +484,12 @@ namespace armarx::viz * @param objectsPackage The objects package ("ArmarXObjects" by default) * @see <RobotAPI/libraries/ArmarXObjects/ObjectFinder.h> */ - Object& fileByObjectFinder(const armarx::ObjectID& objectID, const std::string& objectsPackage = DefaultObjectsPackage); - Object& fileByObjectFinder(const std::string& objectID, const std::string& objectsPackage = DefaultObjectsPackage); + Object& fileByObjectFinder(const armarx::ObjectID& objectID, + const std::string& objectsPackage = DefaultObjectsPackage, + const std::string& relativeObjectsDirectory = DefaultRelativeObjectsDirectory); + Object& fileByObjectFinder(const std::string& objectID, + const std::string& objectsPackage = DefaultObjectsPackage, + const std::string& relativeObjectsDirectory = DefaultRelativeObjectsDirectory); Object& alpha(float alpha); diff --git a/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.cpp b/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.cpp index 2e026dd211cf6906d8b54b468ad6eebfff12141b..53642e1f5b16ca8c18a405a2bdcd1199e0c7df37 100644 --- a/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.cpp +++ b/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.cpp @@ -1,12 +1,10 @@ #include <VirtualRobot/XML/ObjectIO.h> -#include <boost/algorithm/string.hpp> +#include <set> #include <SimoxUtility/algorithm/string.h> #include <SimoxUtility/filesystem/list_directory.h> -#include <VirtualRobot/XML/RobotIO.h> - #include <ArmarXCore/core/system/ArmarXDataPath.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include <ArmarXCore/core/system/cmake/CMakePackageFinder.h> @@ -17,7 +15,9 @@ namespace armarx { namespace fs = std::filesystem; - ObjectFinder::ObjectFinder(const std::string& objectsPackageName) : packageName(objectsPackageName) + + ObjectFinder::ObjectFinder(const std::string& objectsPackageName, const ObjectFinder::path& relObjectsDir) : + packageName(objectsPackageName), relObjectsDir(relObjectsDir) { Logging::setTag("ObjectFinder"); } @@ -25,7 +25,7 @@ namespace armarx void ObjectFinder::setPath(const std::string& path) { packageName = path; - packageDataDir.clear(); + absPackageDataDir.clear(); } std::string ObjectFinder::getPackageName() const @@ -35,11 +35,11 @@ namespace armarx void ObjectFinder::init() const { - if (packageDataDir.empty()) + if (absPackageDataDir.empty()) { CMakePackageFinder packageFinder(packageName); - packageDataDir = packageFinder.getDataDir(); - if (packageDataDir.empty()) + absPackageDataDir = packageFinder.getDataDir(); + if (absPackageDataDir.empty()) { ARMARX_WARNING << "Could not find package '" << packageName << "'."; // throw LocalException() << "Could not find package '" << packageName << "'."; @@ -49,7 +49,7 @@ namespace armarx ARMARX_VERBOSE << "Objects root directory: " << _rootDirAbs(); // make sure this data path is available => e.g. for findArticulatedObjects - armarx::ArmarXDataPath::addDataPaths(std::vector<std::string> {packageDataDir}); + armarx::ArmarXDataPath::addDataPaths(std::vector<std::string> {absPackageDataDir}); } } } @@ -57,7 +57,7 @@ namespace armarx bool ObjectFinder::isDatasetDirValid(const path& path) const { - return path.filename() != "Scenes" and std::filesystem::is_directory(path); + return std::filesystem::is_directory(path); } @@ -70,7 +70,7 @@ namespace armarx } if (!dataset.empty()) { - return ObjectInfo(packageName, packageDataDir, dataset, name); + return ObjectInfo(packageName, absPackageDataDir, relObjectsDir, dataset, name); } // Search for object in datasets. const std::vector<std::string>& datasets = getDatasets(); @@ -78,7 +78,7 @@ namespace armarx { if (fs::is_directory(_rootDirAbs() / dataset / name)) { - return ObjectInfo(packageName, packageDataDir, dataset, name); + return ObjectInfo(packageName, absPackageDataDir, relObjectsDir, dataset, name); } } @@ -217,7 +217,7 @@ namespace armarx { if (fs::is_directory(datasetDir / dir)) { - ObjectInfo object(packageName, packageDataDir, dataset, dir.filename()); + ObjectInfo object(packageName, absPackageDataDir, relObjectsDir, dataset, dir.filename()); if (!checkPaths || object.checkPaths()) { objects.push_back(object); @@ -268,51 +268,22 @@ namespace armarx return {}; } - const std::vector<std::string> validExtensions{".urdf", ".xml"}; - - const auto hasValidExtension = [&](const std::string & file) -> bool - { - return std::find(validExtensions.begin(), validExtensions.end(), boost::algorithm::to_lower_copy(std::filesystem::path(file).extension().string())) != validExtensions.end(); - }; - std::vector<armem::articulated_object::ArticulatedObjectDescription> objects; const bool local = true; for (const path& dir : simox::fs::list_directory(datasetDir, local)) { - if (not fs::is_directory(datasetDir / dir)) - { - continue; - } - - for (const auto& file : std::filesystem::directory_iterator(datasetDir / dir)) + if (fs::is_directory(datasetDir / dir)) { - const std::string xml = std::filesystem::path(file).string(); - - if (hasValidExtension(xml)) + ObjectInfo object(packageName, absPackageDataDir, relObjectsDir, dataset, dir.filename()); + std::optional<PackageFileLocation> modelFile = object.getArticulatedModel(); + if (modelFile.has_value()) { - try + objects.emplace_back(armem::articulated_object::ArticulatedObjectDescription { - const auto robot = VirtualRobot::RobotIO::loadRobot(xml, VirtualRobot::RobotIO::RobotDescription::eStructure); - if (robot != nullptr && robot->isPassive()) - { - const std::string relativeXMLPath = armarx::ArmarXDataPath::getRelativeArmarXPath(xml); - - objects.emplace_back(armem::articulated_object::ArticulatedObjectDescription - { - .name = robot->getName(), - .xml = {packageName, relativeXMLPath} - // .dataset = dataset - }); - } - } - catch (const armarx::LocalException& ex) - { - ARMARX_WARNING << ex.what(); - } - catch (...) - { - - } + .name = object.idStr(), + .xml = {modelFile->package, modelFile->relativePath} + // .dataset = dataset + }); } } } @@ -401,7 +372,7 @@ namespace armarx ObjectFinder::path ObjectFinder::_rootDirAbs() const { - return packageDataDir / packageName; + return absPackageDataDir / packageName / relObjectsDir; } ObjectFinder::path ObjectFinder::_rootDirRel() const @@ -411,7 +382,7 @@ namespace armarx bool ObjectFinder::_ready() const { - return !packageDataDir.empty(); + return !absPackageDataDir.empty(); } } diff --git a/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.h b/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.h index 0bef0667120ee99e7d65f575f1c9b61b446ffe6f..0dcf339d342edcaf5f1c6dab3d4e74868acedf3c 100644 --- a/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.h +++ b/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.h @@ -7,26 +7,31 @@ #include <ArmarXCore/core/logging/Logging.h> +#include <RobotAPI/libraries/armem_objects/types.h> + #include "ObjectInfo.h" #include "ObjectPose.h" -#include <RobotAPI/libraries/armem_objects/types.h> namespace armarx { /** - * @brief Used to find objects in the ArmarX objects repository [1]. + * @brief Used to find objects in the ArmarX objects repository [1] (formerly [2]). * - * @see [1] https://gitlab.com/ArmarX/ArmarXObjects + * @see [1] https://gitlab.com/ArmarX/PriorKnowledgeData + * @see [2] https://gitlab.com/ArmarX/ArmarXObjects */ class ObjectFinder : Logging { public: using path = std::filesystem::path; - inline static const std::string DefaultObjectsPackageName = "ArmarXObjects"; + inline static const std::string DefaultObjectsPackageName = "PriorKnowledgeData"; + inline static const std::string DefaultObjectsDirectory = "objects"; public: - ObjectFinder(const std::string& objectsPackageName = DefaultObjectsPackageName); + + ObjectFinder(const std::string& objectsPackageName = DefaultObjectsPackageName, + const path& relObjectsDir = DefaultObjectsDirectory); ObjectFinder(ObjectFinder&&) = default; ObjectFinder(const ObjectFinder&) = default; @@ -108,7 +113,10 @@ namespace armarx * @brief Absolute path to data directory (e.g. "/.../repos/ArmarXObjects/data"). * Empty if package could not be found. */ - mutable path packageDataDir; + mutable path absPackageDataDir; + + /// Path to the directory containing objects in the package's data directory. + path relObjectsDir; }; } diff --git a/source/RobotAPI/libraries/ArmarXObjects/ObjectInfo.cpp b/source/RobotAPI/libraries/ArmarXObjects/ObjectInfo.cpp index 348a5b25419813a22717f71c92d0c3484042361c..162f4570fdd05d71e5ba6fb0e8cb1b922fdd3eca 100644 --- a/source/RobotAPI/libraries/ArmarXObjects/ObjectInfo.cpp +++ b/source/RobotAPI/libraries/ArmarXObjects/ObjectInfo.cpp @@ -14,14 +14,17 @@ namespace armarx ObjectInfo::ObjectInfo(const std::string& packageName, const ObjectInfo::path& packageDataDir, - const ObjectID& id) : - _packageName(packageName), _packageDataDir(packageDataDir), _id(id) + const path& relObjectsPath, const ObjectID& id) : + _packageName(packageName), _absPackageDataDir(packageDataDir), + _relObjectsPath(relObjectsPath), _id(id) { } ObjectInfo::ObjectInfo(const std::string& packageName, const ObjectInfo::path& packageDataDir, - const std::string& dataset, const std::string& name) : - _packageName(packageName), _packageDataDir(packageDataDir), _id(dataset, name) + const path& relObjectsPath, + const std::string& dataset, const std::string& className) : + _packageName(packageName), _absPackageDataDir(packageDataDir), + _relObjectsPath(relObjectsPath), _id(dataset, className) { } @@ -40,7 +43,7 @@ namespace armarx return _id.dataset(); } - std::string ObjectInfo::name() const + std::string ObjectInfo::className() const { return _id.className(); } @@ -57,7 +60,7 @@ namespace armarx ObjectInfo::path ObjectInfo::objectDirectory() const { - return path(_packageName) / _id.dataset() / _id.className(); + return path(_packageName) / _relObjectsPath / _id.dataset() / _id.className(); } PackageFileLocation ObjectInfo::file(const std::string& _extension, const std::string& suffix) const @@ -72,7 +75,7 @@ namespace armarx PackageFileLocation loc; loc.package = _packageName; loc.relativePath = objectDirectory() / filename; - loc.absolutePath = _packageDataDir / loc.relativePath; + loc.absolutePath = _absPackageDataDir / loc.relativePath; return loc; } @@ -81,6 +84,38 @@ namespace armarx return file(".xml"); } + PackageFileLocation ObjectInfo::articulatedSimoxXML() const + { + return file(".xml", "_articulated"); + } + + PackageFileLocation ObjectInfo::articulatedUrdf() const + { + return file(".urdf", "_articulated"); + } + + std::optional<PackageFileLocation> ObjectInfo::getArticulatedModel() const + { + if (fs::is_regular_file(articulatedSimoxXML().absolutePath)) + { + return articulatedSimoxXML(); + } + else if (fs::is_regular_file(articulatedUrdf().absolutePath)) + { + return articulatedUrdf(); + } + else + { + return std::nullopt; + } + } + + + PackageFileLocation ObjectInfo::meshWrl() const + { + return file(".wrl"); + } + PackageFileLocation ObjectInfo::wavefrontObj() const { return file(".obj"); @@ -232,15 +267,15 @@ namespace armarx { if (_logError) { - ARMARX_WARNING << "Expected simox object file for object '" << *this << "': " << simoxXML().absolutePath; + ARMARX_WARNING << "Expected simox object file for object " << *this << ": " << simoxXML().absolutePath; } result = false; } - if (!fs::is_regular_file(wavefrontObj().absolutePath)) + if (false and not fs::is_regular_file(wavefrontObj().absolutePath)) { if (_logError) { - ARMARX_WARNING << "Expected wavefront object file (.obj) for object '" << *this << "': " << wavefrontObj().absolutePath; + ARMARX_WARNING << "Expected wavefront object file (.obj) for object " << *this << ": " << wavefrontObj().absolutePath; } result = false; } diff --git a/source/RobotAPI/libraries/ArmarXObjects/ObjectInfo.h b/source/RobotAPI/libraries/ArmarXObjects/ObjectInfo.h index 634944e4cc52379977f784c370f48af1e84ed28d..e55c21dc004e70784cd5ff4362fef163bab4cdde 100644 --- a/source/RobotAPI/libraries/ArmarXObjects/ObjectInfo.h +++ b/source/RobotAPI/libraries/ArmarXObjects/ObjectInfo.h @@ -41,10 +41,19 @@ namespace armarx public: + /** + * @brief ObjectInfo + * + * @param packageName The ArmarX package. + * @param absPackageDataDir Absolute path to the package's data directory. + * @param localObjectsPath The path where objects are stored in the data directory. + * @param id The object class ID (with dataset and class name). + */ + ObjectInfo(const std::string& packageName, const path& absPackageDataDir, + const path& relObjectsPath, const ObjectID& id); ObjectInfo(const std::string& packageName, const path& packageDataDir, - const ObjectID& id); - ObjectInfo(const std::string& packageName, const path& packageDataDir, - const std::string& dataset, const std::string& name); + const path& relObjectsPath, + const std::string& dataset, const std::string& className); virtual ~ObjectInfo() = default; @@ -56,7 +65,13 @@ namespace armarx std::string package() const; std::string dataset() const; - std::string name() const; + std::string className() const; + [[deprecated("This function is deprecated. Use className() instead.")]] + std::string name() const + { + return className(); + } + /// Return "dataset/name". ObjectID id() const; std::string idStr() const; @@ -64,6 +79,13 @@ namespace armarx PackageFileLocation file(const std::string& extension, const std::string& suffix = "") const; PackageFileLocation simoxXML() const; + + PackageFileLocation articulatedSimoxXML() const; + PackageFileLocation articulatedUrdf() const; + /// Return the articulated Simox XML or URDF, if one exists. + std::optional<PackageFileLocation> getArticulatedModel() const; + + PackageFileLocation meshWrl() const; PackageFileLocation wavefrontObj() const; PackageFileLocation boundingBoxJson() const; @@ -113,7 +135,8 @@ namespace armarx private: std::string _packageName; - path _packageDataDir; + path _absPackageDataDir; + path _relObjectsPath; ObjectID _id; diff --git a/source/RobotAPI/libraries/ArmarXObjects/test/ArmarXObjectsTest.cpp b/source/RobotAPI/libraries/ArmarXObjects/test/ArmarXObjectsTest.cpp index 0af92b11dcd764b7ab376f07a5869cb1962e5f4f..85ca31bec07bbe8af4108a64a24805da44dd19d5 100644 --- a/source/RobotAPI/libraries/ArmarXObjects/test/ArmarXObjectsTest.cpp +++ b/source/RobotAPI/libraries/ArmarXObjects/test/ArmarXObjectsTest.cpp @@ -29,8 +29,80 @@ #include <iostream> -BOOST_AUTO_TEST_CASE(testExample) +#include <RobotAPI/libraries/ArmarXObjects/aron/ObjectPose.aron.generated.h> +#include <RobotAPI/libraries/ArmarXObjects/ObjectFinder.h> + + +namespace fs = std::filesystem; + + +BOOST_AUTO_TEST_SUITE(arondto_ObjectPose_test) + + +BOOST_AUTO_TEST_CASE(test_ObjectType_copy_assignment) +{ + BOOST_TEST_MESSAGE("Constructor"); + armarx::objpose::arondto::ObjectType lhs, rhs; + + BOOST_TEST_MESSAGE("Assignment"); + BOOST_CHECK_NO_THROW(lhs = rhs); + + BOOST_TEST_MESSAGE("Done"); +} + +BOOST_AUTO_TEST_CASE(test_ObjectAttachmentInfo_copy_assignment) +{ + BOOST_TEST_MESSAGE("Constructor"); + armarx::objpose::arondto::ObjectAttachmentInfo lhs, rhs; + + BOOST_TEST_MESSAGE("Assignment"); + BOOST_CHECK_NO_THROW(lhs = rhs); + + BOOST_TEST_MESSAGE("Done"); +} + +BOOST_AUTO_TEST_CASE(test_ObjectPose_copy_assignment) { + BOOST_TEST_MESSAGE("Constructor"); + armarx::objpose::arondto::ObjectPose lhs, rhs; - BOOST_CHECK_EQUAL(true, true); + BOOST_TEST_MESSAGE("Assignment"); + BOOST_CHECK_NO_THROW(lhs = rhs); + + BOOST_TEST_MESSAGE("Done"); +} + + +BOOST_AUTO_TEST_SUITE_END() + + + +BOOST_AUTO_TEST_SUITE(ObjectFinderTest) + + +BOOST_AUTO_TEST_CASE(test_find) +{ + using namespace armarx; + + ObjectFinder finder; + + bool checkPaths = false; + std::vector<ObjectInfo> objects = finder.findAllObjects(checkPaths); + BOOST_CHECK_GT(objects.size(), 0); + + for (const ObjectInfo& object : objects) + { + fs::path simoxXML = object.simoxXML().absolutePath; + fs::path objectDir = simoxXML.parent_path(); + BOOST_TEST_CONTEXT("Object: " << object.id() << " at " << objectDir) + { + BOOST_CHECK(fs::is_directory(objectDir)); + BOOST_CHECK(fs::is_regular_file(simoxXML) + || fs::is_regular_file(object.articulatedSimoxXML().absolutePath)); + } + } } + + + +BOOST_AUTO_TEST_SUITE_END() diff --git a/source/RobotAPI/libraries/armem_objects/SceneSnapshot.cpp b/source/RobotAPI/libraries/armem_objects/SceneSnapshot.cpp index d8ae0a10b97825f924d7e1605dc4687dcce9bfee..d491662edda9ff00244178735c0c84c26a923688 100644 --- a/source/RobotAPI/libraries/armem_objects/SceneSnapshot.cpp +++ b/source/RobotAPI/libraries/armem_objects/SceneSnapshot.cpp @@ -3,6 +3,7 @@ #include <SimoxUtility/json.h> #include <RobotAPI/libraries/ArmarXObjects/ObjectID.h> +#include <RobotAPI/libraries/ArmarXObjects/ObjectFinder.h> // #include <RobotAPI/libraries/armem/core/json_conversions.h> @@ -15,6 +16,20 @@ namespace armarx::armem::obj return ObjectID(className); } + + ObjectID SceneSnapshot::Object::getClassID(ObjectFinder& finder) const + { + ObjectID id = getClassID(); + if (id.dataset().empty()) + { + if (std::optional<ObjectInfo> info = finder.findObject(id.className())) + { + return info->id(); + } + } + return id; + } + } diff --git a/source/RobotAPI/libraries/armem_objects/SceneSnapshot.h b/source/RobotAPI/libraries/armem_objects/SceneSnapshot.h index 2baa2cd3c323794aa4112bbc5df8c3353073dc61..add5f1f183d15b6ec7c0588a5d4a9abc7e558d82 100644 --- a/source/RobotAPI/libraries/armem_objects/SceneSnapshot.h +++ b/source/RobotAPI/libraries/armem_objects/SceneSnapshot.h @@ -29,6 +29,7 @@ namespace armarx { class ObjectID; + class ObjectFinder; } namespace armarx::armem::obj { @@ -44,6 +45,7 @@ namespace armarx::armem::obj Eigen::Quaternionf orientation = Eigen::Quaternionf::Identity(); ObjectID getClassID() const; + ObjectID getClassID(ObjectFinder& finder) const; }; std::vector<Object> objects; }; diff --git a/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml b/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml index 650082eb4ef8b924c8368fdd6cdf8da4578e105a..cb3c418e68b53cb24b781b22ff057386f995d2dc 100644 --- a/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml +++ b/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml @@ -31,6 +31,10 @@ Core segment type of Object/Class. <armarx::arondto::PackagePath /> </ObjectChild> + <ObjectChild key="articulatedSimoxXmlPath"> + <armarx::arondto::PackagePath /> + </ObjectChild> + <ObjectChild key="meshWrlPath"> <armarx::arondto::PackagePath /> </ObjectChild> diff --git a/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.h b/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.h index 4c3be719fce4148970fa0ef16d8465d2df7a10d3..dcce63977438bdd0d646b50aa8e5dd9679354df8 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.h +++ b/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.h @@ -41,9 +41,9 @@ namespace armarx::armem::server::obj::clazz { bool show = true; - std::string entityName = "Environment/floor-20x20"; + std::string entityName = "Building/floor-20x20"; std::string layerName = "Floor"; - bool height = 1; + float height = -1; void define(armarx::PropertyDefinitionsPtr defs, const std::string& prefix = ""); }; diff --git a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp index 323a4df0d37cbf5d8177e763dddb9b58091bf4de..eb998a190a45003bb9bb60d07f4df356d8ddf058 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp @@ -172,18 +172,23 @@ namespace armarx::armem::server::obj::clazz toAron(data.id, info.id()); - if (fs::is_regular_file(info.simoxXML().absolutePath)) + auto setPathIfExists = []( + armarx::arondto::PackagePath & aron, + const PackageFileLocation & location) { - toAron(data.simoxXmlPath, info.simoxXML()); - } - if (fs::is_regular_file(info.wavefrontObj().absolutePath)) - { - toAron(data.meshObjPath, info.wavefrontObj()); - } - if (fs::is_regular_file(info.file(".wrl").absolutePath)) - { - toAron(data.meshWrlPath, info.file(".wrl")); - } + if (fs::is_regular_file(location.absolutePath)) + { + toAron(aron, location); + } + else + { + toAron(aron, PackageFileLocation()); + } + }; + setPathIfExists(data.simoxXmlPath, info.simoxXML()); + setPathIfExists(data.articulatedSimoxXmlPath, info.articulatedSimoxXML()); + setPathIfExists(data.meshObjPath, info.wavefrontObj()); + setPathIfExists(data.meshWrlPath, info.meshWrl()); auto aabb = info.loadAABB(); toAron(data.aabb, aabb ? aabb.value() : simox::AxisAlignedBoundingBox()); diff --git a/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp index eb81a73dc3fa4b949dbdf880a9023b51d02d7320..4e0e7429a61b4efc02ee0a783fad91ec86ea9944 100644 --- a/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp @@ -843,7 +843,7 @@ namespace armarx::armem::server::obj::instance for (const auto& object : scene.objects) { - const ObjectID classID = object.getClassID(); + const ObjectID classID = object.getClassID(objectFinder); objpose::ObjectPose& pose = objectPoses.emplace_back();