31 using namespace MotionPlanningGroup;
47 if (in.getPlanPlatformMovement())
50 if (!in.isCSpacePlatformMovementBoundsMinSet())
52 ARMARX_ERROR_S <<
"platform movement should be planned, but the min movement bounds were not set.";
56 if (!in.isCSpacePlatformMovementBoundsMaxSet())
58 ARMARX_ERROR_S <<
"platform movement should be planned, but the max movement bounds were not set.";
62 cspaceSimox = cspaceSimox2d;
63 Vector3fRange movBounds;
64 movBounds.min.e0 = in.getCSpacePlatformMovementBoundsMin()->x;
65 movBounds.min.e1 = in.getCSpacePlatformMovementBoundsMin()->y;
66 movBounds.min.e2 = in.getCSpacePlatformMovementBoundsMin()->z;
67 movBounds.max.e0 = in.getCSpacePlatformMovementBoundsMax()->x;
68 movBounds.max.e1 = in.getCSpacePlatformMovementBoundsMax()->y;
69 movBounds.max.e2 = in.getCSpacePlatformMovementBoundsMax()->z;
70 cspaceSimox2d->setPoseBounds(movBounds);
74 cspaceSimox =
new SimoxCSpace {getWorkingMemory()->getCommonStorage()};
78 AgentPlanningInformation agent;
79 agent.agentProjectNames = in.getAgentProjectName();
80 agent.agentRelativeFilePath = in.getAgentRelativeFilePath();
82 if (in.isCSpaceKinemaicChainNamesSet())
84 agent.kinemaicChainNames = in.getCSpaceKinemaicChainNames();
86 if (in.isCSpaceAdditionalJointsForPlanningSet())
88 agent.additionalJointsForPlanning = in.getCSpaceAdditionalJointsForPlanning();
90 if (in.isCSpaceJointsExcludedFromPlanningSet())
92 agent.jointsExcludedFromPlanning = in.getCSpaceJointsExcludedFromPlanning();
95 agent.collisionSetNames = in.getCollisionSetNames();
96 if (in.isInitialJointValuesSet())
98 agent.initialJointValues = in.getInitialJointValues();
100 agent.agentPose = in.getInitialAgentPose();
102 if (agent.kinemaicChainNames.empty() && agent.additionalJointsForPlanning.empty())
104 ARMARX_ERROR_S <<
"no joints set for planning! (define CSpaceAdditionalJointsForPlanning and/or CSpaceKinemaicChainNames)";
109 ARMARX_VERBOSE_S <<
"Loading agent from project '" << agent.agentProjectName
110 <<
"' and path '" << agent.agentRelativeFilePath <<
"'";
112 cspaceSimox->setAgent(agent);
114 cspaceSimox->addObjectsFromWorkingMemory(getWorkingMemory());
115 cspaceSimox->setStationaryObjectMargin(in.getStationaryObjectMargin());
116 VectorXf start = cspaceSimox->jointMapToVector(in.getConfigStart());
117 if (start.size() !=
static_cast<std::size_t
>(cspaceSimox->getDimensionality()))
119 ARMARX_ERROR_S <<
"the start config has " << start.size() <<
"demensions, but the cspace has " << cspaceSimox->getDimensionality() <<
" dimensions.";
124 VectorXf stop = cspaceSimox->jointMapToVector(in.getConfigStop());
125 if (stop.size() !=
static_cast<std::size_t
>(cspaceSimox->getDimensionality()))
127 ARMARX_ERROR_S <<
"the stop config has " << stop.size() <<
"demensions, but the cspace has " << cspaceSimox->getDimensionality() <<
" dimensions.";
133 CSpaceBasePtr cspace = cspaceSimox;
135 if (in.getPlanPlatformMovement())
138 VectorXf scale = {0.005, 0.005, 1};
139 scale.resize(cspaceSimox->getDimensionality(), 1);
141 scaledCspace->scaleConfig(start);
142 scaledCspace->scaleConfig(stop);
143 cspace = scaledCspace;
146 float dcdStepSize = 0.1;
148 std::lock_guard< std::mutex> lock {
taskMutex};
151 getMotionPlanningServer()->enqueueTask(
159 "Statechart.PlanMotionBase.RRT",
160 in.getPlanningTimeInSeconds(),
163 "Statechart.PlanMotionBase.PostProcess",
164 in.getTrajectoryOptimizationTimeout()
169 while (!isRunningTaskStopped() && !
task->finishedRunning())
172 std::this_thread::sleep_for(std::chrono::milliseconds(20));
174 if (TaskStatus::eDone ==
task->getTaskStatus())
177 PathWithCost p =
task->getPathWithCost();
181 scaledCspace->unscalePath(p.nodes);
185 setOutput(
"Trajectory", trajectory);
195 std::lock_guard< std::mutex> lock {
taskMutex};