Skip to content

Commit faa8486

Browse files
Add start and end states to the spawn method of Generator
1 parent 55c4b52 commit faa8486

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

core/include/moveit/task_constructor/stage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ class Generator : public ComputeBase
365365

366366
virtual bool canCompute() const = 0;
367367
virtual void compute() = 0;
368+
void spawn(InterfaceState&& from, InterfaceState&& to, SubTrajectory&& trajectory);
368369
void spawn(InterfaceState&& state, SubTrajectory&& trajectory);
369370
void spawn(InterfaceState&& state, double cost) {
370371
SubTrajectory trajectory;

core/include/moveit/task_constructor/stage_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class StagePrivate
136136
void sendBackward(InterfaceState&& from, const InterfaceState& to, const SolutionBasePtr& solution);
137137
template <Interface::Direction>
138138
inline void send(const InterfaceState& start, InterfaceState&& end, const SolutionBasePtr& solution);
139+
void spawn(InterfaceState&& from, InterfaceState&& to, const SolutionBasePtr& solution);
139140
void spawn(InterfaceState&& state, const SolutionBasePtr& solution);
140141
void connect(const InterfaceState& from, const InterfaceState& to, const SolutionBasePtr& solution);
141142

core/src/stage.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,28 +219,32 @@ void StagePrivate::sendBackward(InterfaceState&& from, const InterfaceState& to,
219219
newSolution(solution);
220220
}
221221

222-
void StagePrivate::spawn(InterfaceState&& state, const SolutionBasePtr& solution) {
222+
void StagePrivate::spawn(InterfaceState&& from, InterfaceState&& to, const SolutionBasePtr& solution) {
223223
assert(prevEnds() && nextStarts());
224224

225-
computeCost(state, state, *solution);
225+
computeCost(from, to, *solution);
226226

227227
if (!storeSolution(solution, nullptr, nullptr))
228228
return; // solution dropped
229229

230-
auto from = states_.insert(states_.end(), InterfaceState(state)); // copy
231-
auto to = states_.insert(states_.end(), std::move(state));
230+
auto from_it = states_.insert(states_.end(), std::move(from));
231+
auto to_it = states_.insert(states_.end(), std::move(to));
232232

233-
solution->setStartState(*from);
234-
solution->setEndState(*to);
233+
solution->setStartState(*from_it);
234+
solution->setEndState(*to_it);
235235

236236
if (!solution->isFailure()) {
237-
prevEnds()->add(*from);
238-
nextStarts()->add(*to);
237+
prevEnds()->add(*from_it);
238+
nextStarts()->add(*to_it);
239239
}
240240

241241
newSolution(solution);
242242
}
243243

244+
void StagePrivate::spawn(InterfaceState&& state, const SolutionBasePtr& solution) {
245+
spawn(InterfaceState(state), std::move(state), solution);
246+
}
247+
244248
void StagePrivate::connect(const InterfaceState& from, const InterfaceState& to, const SolutionBasePtr& solution) {
245249
computeCost(from, to, *solution);
246250

@@ -688,6 +692,10 @@ void GeneratorPrivate::compute() {
688692
Generator::Generator(GeneratorPrivate* impl) : ComputeBase(impl) {}
689693
Generator::Generator(const std::string& name) : Generator(new GeneratorPrivate(this, name)) {}
690694

695+
void Generator::spawn(InterfaceState&& from, InterfaceState&& to, SubTrajectory&& t) {
696+
pimpl()->spawn(std::move(from), std::move(to), std::make_shared<SubTrajectory>(std::move(t)));
697+
}
698+
691699
void Generator::spawn(InterfaceState&& state, SubTrajectory&& t) {
692700
pimpl()->spawn(std::move(state), std::make_shared<SubTrajectory>(std::move(t)));
693701
}

0 commit comments

Comments
 (0)