28 using namespace GraspingPipelineGroup;
39 double length = t->getLength(0);
45 double timelength = t->getTimeLength();
47 auto timestamps = t->getTimestamps();
49 Ice::DoubleSeq newTimestamps;
50 newTimestamps.push_back(0);
51 for (
size_t var = 0; var < timestamps.size() - 1; ++var)
53 double tBefore = timestamps.at(var);
54 double tAfter = (timestamps.at(var + 1));
56 double partLength = t->getLength(0, tBefore, tAfter);
57 double lengthPortion = partLength / length;
59 newTimestamps.push_back(*newTimestamps.rbegin() + timelength * lengthPortion);
63 for (
size_t d = 0; d < t->dim(); ++d)
65 newTraj->addDimension(t->getDimensionData(d), newTimestamps, t->getDimensionName(d));
67 newTraj->setLimitless(t->getLimitless());
86 memoryx::WorkingMemoryInterfacePrx workingMemory = getWorkingMemory();
87 memoryx::ObjectInstanceBasePtr objectInstance;
88 std::string objectName;
89 ARMARX_INFO <<
"Run() of CalculateTrajectory started";
90 if (in.isObjectInstanceChannelSet())
92 objectName = in.getObjectInstanceChannel()->getDataField(
"className")->getString();
93 auto id = in.getObjectInstanceChannel()->getDataField(
"id")->getString();
94 objectInstance = workingMemory->getObjectInstancesSegment()->getObjectInstanceById(
id);
97 else if (in.isObjectNameSet())
99 objectName = in.getObjectName();
100 objectInstance = workingMemory->getObjectInstancesSegment()->getObjectInstanceByName(objectName);
104 ARMARX_ERROR <<
"Either ObjectName or ObjectInstanceChannel must bet set!";
110 ARMARX_WARNING <<
"Could not find ObjectInstance with name " + objectName;
116 GraspingTrajectory gt;
119 for (
int i = 0; i < maxTries; i++)
124 gt =
graspingManager->generateGraspingTrajectory(objectInstance->getId());
126 catch (armarx::LocalException&)
131 if (gt.poseTrajectory && gt.configTrajectory && !gt.rnsToUse.empty())
134 out.setKinematicChainName(gt.rnsToUse);
135 out.setHandName(gt.endeffector);
139 json->setVariant(
"posetrajectory",
new Variant(gt.poseTrajectory));
142 out.setPlatformTrajectory(gt.poseTrajectory);
143 out.setJointTrajectory(gt.configTrajectory);
144 out.setGraspPose(gt.grasp.framedPose);
145 out.setPreGraspPose(gt.grasp.framedPrePose);
146 std::vector<Vector3Ptr> platformPointList;
147 TrajectoryPtr platformTraj = TrajectoryPtr ::dynamicCast(gt.poseTrajectory);
150 platformPointList.push_back(
new Vector3(point.getPosition(0),
151 point.getPosition(1),
152 point.getPosition(2)));
155 out.setPlatformPointList(platformPointList);
162 ARMARX_INFO <<
"GraspingManger could not generate a graspingTrajectory. Trying again....";
165 ARMARX_WARNING <<
"Stopped trying to find a solution after " << maxTries <<
" trys.";