23 Base(memoryToIceAdapter,
"Trajectory",
"MovementPrimitive")
31 defs->optional(properties.motionsPackage, prefix +
"MotionsPackage",
"Name of the prior knowledge package to load from.");
32 defs->optional(properties.loadFromMotionsPackage, prefix +
"LoadFromMotionsPackage",
"If true, load the motions from the motions package on startup.");
39 if (properties.loadFromMotionsPackage)
41 loadByMotionFinder(properties.motionsPackage);
50 int MPSegment::loadByMotionFinder(
const std::string& packageName)
53 int loadedMotions = 0;
56 auto allMotions = motionFinder.findAll(
"trajectories");
57 for (
const auto& motionFinderInfo : allMotions)
59 auto pathToInfoJson = motionFinderInfo.getFullPath() / motionFinderInfo.getID();
60 for (
const auto & entry: std::filesystem::directory_iterator(pathToInfoJson))
62 if (std::string(entry.path().filename()).rfind(
"taskspace", 0) == 0)
65 loadSingleMotionFinder(entry.path(), motionFinderInfo.getID(),
true);
66 loadedMotions += allMotions.size();
76 loadedMotions += allMotions.size();
82 void MPSegment::loadSingleMotionFinder(
const std::string &pathToInfoJson,
const std::string &entityName,
bool taskspace)
87 ss <<
"Found valid instance at: " << pathToInfoJson <<
". The motionID is: ";
97 std::filesystem::path path(pathToInfoJson);
98 for (
const auto & entry: std::filesystem::directory_iterator(path.parent_path()))
100 std::string newname =
"joint-trajectory" + std::string(path.filename()).erase(0, 20);
101 if (std::string(entry.path().filename()).rfind(newname, 0) == 0)
105 op->jointSpace = op2->jointSpace;
106 instance.
data() = op->toAron();
111 snapshot.addInstance(instance);
117 snapshot.addInstance(instance);
127 ARMARX_WARNING <<
"Found an invalid path to a motion file: " << pathToInfoJson;