|
1 | 1 | #include <moveit/task_constructor/container_p.h>
|
2 | 2 | #include <moveit/task_constructor/stage_p.h>
|
3 | 3 | #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> |
5 | 6 | #include <moveit/planning_scene/planning_scene.h>
|
6 | 7 |
|
7 | 8 | #include "stage_mockups.h"
|
@@ -160,6 +161,26 @@ TEST_F(FallbacksFixturePropagate, activeChildReset) {
|
160 | 161 | EXPECT_COSTS(fwd2->solutions(), testing::IsEmpty());
|
161 | 162 | }
|
162 | 163 |
|
| 164 | +// https://github.com/moveit/moveit_task_constructor/issues/581#issuecomment-2147985474 |
| 165 | +TEST_F(FallbacksFixturePropagate, filterPropagatesFailures) { |
| 166 | + t.add(std::make_unique<GeneratorMockup>(PredefinedCosts::single(0.0))); |
| 167 | + |
| 168 | + auto fallbacks = std::make_unique<Fallbacks>("Fallbacks"); |
| 169 | + auto add_filtered_fwd = [&fallbacks](double cost, bool accept) { |
| 170 | + auto fwd = std::make_unique<ForwardMockup>(PredefinedCosts::constant(cost)); |
| 171 | + auto filter = std::make_unique<stages::PredicateFilter>("filter", std::move(fwd)); |
| 172 | + filter->setPredicate([accept](const SolutionBase& /*solution*/, std::string& /*comment*/) { return accept; }); |
| 173 | + fallbacks->add(std::move(filter)); |
| 174 | + }; |
| 175 | + add_filtered_fwd(INF, false); // Propagate fails, filter rejects |
| 176 | + add_filtered_fwd(2.0, true); // Propagate succeeds, filter accepts |
| 177 | + fallbacks->add(std::make_unique<stages::NoOp>()); |
| 178 | + t.add(std::move(fallbacks)); |
| 179 | + |
| 180 | + EXPECT_TRUE(t.plan()); |
| 181 | + EXPECT_COSTS(t.solutions(), testing::ElementsAre(2.)); |
| 182 | +} |
| 183 | + |
163 | 184 | using FallbacksFixtureConnect = TaskTestBase;
|
164 | 185 |
|
165 | 186 | TEST_F(FallbacksFixtureConnect, connectStageInsideFallbacks) {
|
|
0 commit comments