22 Base(memoryToIceAdapter,
"Trajectory",
"MovementPrimitive")
31 defs->optional(properties.motionsPackage,
32 prefix +
"MotionsPackage",
33 "Name of the prior knowledge package to load from.");
34 defs->optional(properties.loadFromMotionsPackage,
35 prefix +
"LoadFromMotionsPackage",
36 "If true, load the motions from the motions package on startup.");
44 if (properties.loadFromMotionsPackage)
46 loadByMotionFinder(properties.motionsPackage);
56 MPSegment::loadByMotionFinder(
const std::string& packageName)
59 int loadedMotions = 0;
62 auto allMotions = motionFinder.findAll(
"trajectories");
63 for (
const auto& motionFinderInfo : allMotions)
66 motionFinderInfo.getFullPath() /
69 for (
const auto& entry : std::filesystem::directory_iterator(pathToInfoJson))
71 if (std::string(entry.path().filename()).rfind(
"taskspace", 0) == 0)
74 loadSingleMotionFinder(entry.path(), motionFinderInfo.getID(),
true);
75 loadedMotions += allMotions.size();
85 loadedMotions += allMotions.size();
92 MPSegment::loadSingleMotionFinder(
const std::string& pathToInfoJson,
93 const std::string& entityName,
99 ss <<
"Found valid instance at: " << pathToInfoJson <<
". The motionID is: ";
109 std::filesystem::path path(pathToInfoJson);
110 for (
const auto& entry : std::filesystem::directory_iterator(path.parent_path()))
112 std::string newname =
113 "joint-trajectory" + std::string(path.filename()).erase(0, 20);
114 if (std::string(entry.path().filename()).rfind(newname, 0) == 0)
119 op->jointSpace = op2->jointSpace;
120 instance.
data() = op->toAron();
125 snapshot.addInstance(instance);
131 snapshot.addInstance(instance);
141 ARMARX_WARNING <<
"Found an invalid path to a motion file: " << pathToInfoJson;