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

Merge branch 'feature/improved-ArticulatedObjectWriter' into 'master'

ArticulatedObjectWriter: adding alternative implementation for storeArticulatedObject which should be more efficient

See merge request !515
parents d4923c4e 6d1f9ac3
No related branches found
No related tags found
1 merge request!515ArticulatedObjectWriter: adding alternative implementation for storeArticulatedObject which should be more efficient
Pipeline #22426 failed
...@@ -14,11 +14,14 @@ ...@@ -14,11 +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());
...@@ -51,6 +54,37 @@ namespace armarx::armem::articulated_object ...@@ -51,6 +54,37 @@ namespace armarx::armem::articulated_object
.timestamp = timestamp}; .timestamp = timestamp};
} }
// fast version without filesystem (CMake) access
static armem::articulated_object::ArticulatedObject
convertWithoutPackagePath(const VirtualRobot::Robot& obj, const armem::Time& timestamp)
{
ARMARX_DEBUG << "Filename is " << obj.getFilename();
return armem::articulated_object::ArticulatedObject{
.description = {.name = obj.getType(), .xml = {}, .visualization = {}, .info = {}},
.instance = obj.getName(),
.config = {.timestamp = timestamp,
.globalPose = Eigen::Isometry3f(obj.getRootNode()->getGlobalPose()),
.jointMap = obj.getJointValues(),
.proprioception = std::nullopt},
.timestamp = timestamp};
}
bool
ArticulatedObjectWriter::storeArticulatedObjectWithObjectClass(
const VirtualRobot::RobotPtr& articulatedObject,
const armem::Time& timestamp,
const bool isStatic)
{
ARMARX_CHECK_NOT_NULL(articulatedObject);
armarx::armem::articulated_object::ArticulatedObject armemArticulatedObject =
convert(*articulatedObject, timestamp);
return store(armemArticulatedObject, isStatic);
}
bool bool
ArticulatedObjectWriter::storeArticulatedObject(const VirtualRobot::RobotPtr& articulatedObject, ArticulatedObjectWriter::storeArticulatedObject(const VirtualRobot::RobotPtr& articulatedObject,
const armem::Time& timestamp, const armem::Time& timestamp,
...@@ -60,8 +94,9 @@ namespace armarx::armem::articulated_object ...@@ -60,8 +94,9 @@ namespace armarx::armem::articulated_object
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()); convertWithoutPackagePath(*articulatedObject, timestamp);
return store(armemArticulatedObject, isStatic); return storeInstance(armemArticulatedObject, isStatic);
} }
} // namespace armarx::armem::articulated_object } // namespace armarx::armem::articulated_object
...@@ -14,8 +14,22 @@ namespace armarx::armem::articulated_object ...@@ -14,8 +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);
/**
* @brief Stores the articulated object. If the object class in unknown,
* 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:
}; };
} // 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