Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/src/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,9 @@ bool Fallbacks::canCompute() const {
if (child->canCompute())
return true;

if (!Stage::solutions().empty())
return false; // we are done as soon as a child has found solutions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch does not make any sense to me.

If the generator in ComputeFirstSuccessfulStageOnly would spawn multiple solutions, I would still expect a solution from the first child for each of the inputs! Otherwise you prune too many computation branches and loose solutions.

// active child failed, continue with next
auto next = child->it();
++next;
Expand Down
52 changes: 52 additions & 0 deletions core/test/test_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void append(ContainerBase& c, const std::initializer_list<StageType>& types) {
}
}
}
constexpr double INF = std::numeric_limits<double>::infinity();

class NamedStage : public GeneratorMockup
{
Expand Down Expand Up @@ -685,3 +686,54 @@ TEST(Fallback, failing) {
EXPECT_FALSE(t.plan());
EXPECT_EQ(t.solutions().size(), 0u);
}

TEST(Fallback, DISABLED_ConnectStageInsideFallbacks) {
resetMockupIds();
Task t;
t.setRobotModel(getModel());

t.add(std::make_unique<GeneratorMockup>());

auto fallbacks = std::make_unique<Fallbacks>("Fallbacks");
fallbacks->add(std::make_unique<ConnectMockup>());
t.add(std::move(fallbacks));

t.add(std::make_unique<GeneratorMockup>());

EXPECT_TRUE(t.plan());
EXPECT_EQ(t.numSolutions(), 1u);
}

TEST(Fallback, ComputeFirstSuccessfulStageOnly) {
resetMockupIds();
Task t;
t.setRobotModel(getModel());

t.add(std::make_unique<GeneratorMockup>());

auto fallbacks = std::make_unique<Fallbacks>("Fallbacks");
fallbacks->add(std::make_unique<ForwardMockup>(PredefinedCosts::constant(0.0)));
fallbacks->add(std::make_unique<ForwardMockup>(PredefinedCosts::constant(0.0)));
t.add(std::move(fallbacks));

EXPECT_TRUE(t.plan());
EXPECT_EQ(t.numSolutions(), 1u);
}

TEST(Fallback, ActiveChildReset) {
resetMockupIds();
Task t;
t.setRobotModel(getModel());

t.add(std::make_unique<GeneratorMockup>(PredefinedCosts{ { 0.0, INF, 0.0 } }));

auto fallbacks = std::make_unique<Fallbacks>("Fallbacks");
fallbacks->add(std::make_unique<ForwardMockup>(PredefinedCosts::constant(0.0)));
fallbacks->add(std::make_unique<ForwardMockup>(PredefinedCosts::constant(0.0)));
auto first = fallbacks->findChild("FWD1");
t.add(std::move(fallbacks));

EXPECT_TRUE(t.plan());
EXPECT_EQ(t.numSolutions(), 2u);
EXPECT_EQ(first->solutions().size(), 2u);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we agree on how this test should behave. That's good. :)

However, this only succeeds because of https://github.com/ros-planning/moveit_task_constructor/pull/280/files#diff-5b0930974b77eab73f48b74214a60ac0562cd2a110285279bb5ad1094b40a842R822 now (Robert fixes the active child as soon as it produced any solution, even if it can't compute in between). As I do not agree with this patch we are not done here yet.

}