Skip to content

Commit 7631486

Browse files
authored
Add unittest for moveit#581
1 parent cd28bdc commit 7631486

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

core/test/test_fallback.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include <moveit/task_constructor/container_p.h>
22
#include <moveit/task_constructor/stage_p.h>
33
#include <moveit/task_constructor/task_p.h>
4-
#include <moveit/task_constructor/stages/fixed_state.h>
4+
#include <moveit/task_constructor/stages/predicate_filter.h>
5+
#include <moveit/task_constructor/stages/noop.h>
56
#include <moveit/planning_scene/planning_scene.h>
67

78
#include "stage_mockups.h"
@@ -159,6 +160,26 @@ TEST_F(FallbacksFixturePropagate, activeChildReset) {
159160
EXPECT_COSTS(fwd2->solutions(), testing::IsEmpty());
160161
}
161162

163+
// https://github.com/moveit/moveit_task_constructor/issues/581#issuecomment-2147985474
164+
TEST_F(FallbacksFixturePropagate, filterPropagatesFailures) {
165+
t.add(std::make_unique<GeneratorMockup>(PredefinedCosts::single(0.0)));
166+
167+
auto fallbacks = std::make_unique<Fallbacks>("Fallbacks");
168+
auto add_filtered_fwd = [&fallbacks](double cost, bool accept) {
169+
auto fwd = std::make_unique<ForwardMockup>(PredefinedCosts::constant(cost));
170+
auto filter = std::make_unique<stages::PredicateFilter>("filter", std::move(fwd));
171+
filter->setPredicate([accept](const SolutionBase& /*solution*/, std::string& /*comment*/) { return accept; });
172+
fallbacks->add(std::move(filter));
173+
};
174+
add_filtered_fwd(INF, false); // Propagate fails, filter rejects
175+
add_filtered_fwd(2.0, true); // Propagate succeeds, filter accepts
176+
fallbacks->add(std::make_unique<stages::NoOp>());
177+
t.add(std::move(fallbacks));
178+
179+
EXPECT_TRUE(t.plan());
180+
EXPECT_COSTS(t.solutions(), testing::ElementsAre(2.));
181+
}
182+
162183
using FallbacksFixtureConnect = TaskTestBase;
163184

164185
TEST_F(FallbacksFixtureConnect, connectStageInsideFallbacks) {

0 commit comments

Comments
 (0)