Skip to content
Snippets Groups Projects
Commit 6d1f9ac3 authored by Fabian Reister's avatar Fabian Reister
Browse files

articulated object writer: implementation such that the default behavior is...

articulated object writer: implementation such that the default behavior is changed: by default, only the instance will be stored and not the class
parent d92f0d51
No related branches found
No related tags found
1 merge request!515ArticulatedObjectWriter: adding alternative implementation for storeArticulatedObject which should be more efficient
Pipeline #22395 failed
...@@ -14,13 +14,14 @@ ...@@ -14,13 +14,14 @@
namespace armarx::armem::articulated_object namespace armarx::armem::articulated_object
{ {
armem::articulated_object::ArticulatedObject // Slow version with filesystem access. It runs CMake for each project / environment variable.
static armem::articulated_object::ArticulatedObject
convert(const VirtualRobot::Robot& obj, const armem::Time& timestamp) convert(const VirtualRobot::Robot& obj, const armem::Time& timestamp)
{ {
ARMARX_DEBUG << "Filename is " << obj.getFilename(); ARMARX_DEBUG << "Filename is " << obj.getFilename();
// this is very inefficient. It runs CMake for each project
const std::vector<std::string> packages = const std::vector<std::string> packages =
armarx::CMakePackageFinder::FindAllArmarXSourcePackages(); armarx::CMakePackageFinder::FindAllArmarXSourcePackages();
const std::string package = armarx::ArmarXDataPath::getProject(packages, obj.getFilename()); const std::string package = armarx::ArmarXDataPath::getProject(packages, obj.getFilename());
...@@ -53,8 +54,9 @@ namespace armarx::armem::articulated_object ...@@ -53,8 +54,9 @@ namespace armarx::armem::articulated_object
.timestamp = timestamp}; .timestamp = timestamp};
} }
armem::articulated_object::ArticulatedObject // fast version without filesystem (CMake) access
convert2(const VirtualRobot::Robot& obj, const armem::Time& timestamp) static armem::articulated_object::ArticulatedObject
convertWithoutPackagePath(const VirtualRobot::Robot& obj, const armem::Time& timestamp)
{ {
ARMARX_DEBUG << "Filename is " << obj.getFilename(); ARMARX_DEBUG << "Filename is " << obj.getFilename();
...@@ -69,30 +71,30 @@ namespace armarx::armem::articulated_object ...@@ -69,30 +71,30 @@ namespace armarx::armem::articulated_object
} }
bool bool
ArticulatedObjectWriter::storeArticulatedObject(const VirtualRobot::RobotPtr& articulatedObject, ArticulatedObjectWriter::storeArticulatedObjectWithObjectClass(
const armem::Time& timestamp, const VirtualRobot::RobotPtr& articulatedObject,
const bool isStatic) const armem::Time& timestamp,
const bool isStatic)
{ {
ARMARX_CHECK_NOT_NULL(articulatedObject); ARMARX_CHECK_NOT_NULL(articulatedObject);
armarx::armem::articulated_object::ArticulatedObject armemArticulatedObject = armarx::armem::articulated_object::ArticulatedObject armemArticulatedObject =
convert(*articulatedObject, Time::Now()); convert(*articulatedObject, timestamp);
return store(armemArticulatedObject, isStatic); return store(armemArticulatedObject, isStatic);
} }
bool bool
ArticulatedObjectWriter::storeArticulatedObject2( ArticulatedObjectWriter::storeArticulatedObject(const VirtualRobot::RobotPtr& articulatedObject,
const VirtualRobot::RobotPtr& articulatedObject, const armem::Time& timestamp,
const armem::Time& timestamp, const bool isStatic)
const bool isStatic)
{ {
ARMARX_CHECK_NOT_NULL(articulatedObject); ARMARX_CHECK_NOT_NULL(articulatedObject);
armarx::armem::articulated_object::ArticulatedObject armemArticulatedObject = armarx::armem::articulated_object::ArticulatedObject armemArticulatedObject =
convert2(*articulatedObject, Time::Now()); convertWithoutPackagePath(*articulatedObject, timestamp);
return storeInstance(armemArticulatedObject, isStatic); return storeInstance(armemArticulatedObject, isStatic);
} }
......
...@@ -14,15 +14,22 @@ namespace armarx::armem::articulated_object ...@@ -14,15 +14,22 @@ namespace armarx::armem::articulated_object
public: public:
using Writer::Writer; using Writer::Writer;
/**
* @brief Stores the articulated object in the memory.
*
*/
bool storeArticulatedObject(const VirtualRobot::RobotPtr& articulatedObject, bool storeArticulatedObject(const VirtualRobot::RobotPtr& articulatedObject,
const armem::Time& timestamp, const armem::Time& timestamp,
bool isStatic = false); bool isStatic = false);
bool storeArticulatedObject2(const VirtualRobot::RobotPtr& articulatedObject, /**
const armem::Time& timestamp, * @brief Stores the articulated object. If the object class in unknown,
bool isStatic = false); * it will also be stored in the corresponding class core segment.
*/
bool storeArticulatedObjectWithObjectClass(const VirtualRobot::RobotPtr& articulatedObject,
const armem::Time& timestamp,
bool isStatic = false);
private: private:
}; };
} // namespace armarx::armem::articulated_object } // namespace armarx::armem::articulated_object
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment