-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Debug/Fix #485 #495
Merged
Merged
[WIP] Debug/Fix #485 #495
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0fd989c
Simplify tests
rhaschke 605a1e5
DelayingWrapper stage to delay solution shipping in unit tests
rhaschke 08b102d
Unit tests for #485
rhaschke 7b96586
Add more debugging output
rhaschke 13264ba
Fix leaking of failures into enumerated solutions
rhaschke bf2714b
printPendingPairs(os) -> os<<pendingPairsPrinter()
rhaschke 9dfd6bd
Fix duplicate solutions
rhaschke e163f57
Cleanup debug output
rhaschke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include "stage_mockups.h" | ||
#include <moveit/task_constructor/container_p.h> | ||
|
||
using namespace moveit::task_constructor; | ||
|
||
struct TestGeneratorMockup : public GeneratorMockup | ||
{ | ||
InterfacePtr next_starts_; | ||
InterfacePtr prev_ends_; | ||
|
||
using GeneratorMockup::GeneratorMockup; | ||
using GeneratorMockup::init; | ||
|
||
void init() { | ||
next_starts_ = std::make_shared<Interface>(); | ||
prev_ends_ = std::make_shared<Interface>(); | ||
|
||
GeneratorMockup::reset(); | ||
GeneratorMockup::init(getModel()); | ||
|
||
GeneratorPrivate* impl = pimpl(); | ||
impl->setNextStarts(next_starts_); | ||
impl->setPrevEnds(prev_ends_); | ||
} | ||
}; | ||
|
||
TEST(GeneratorMockup, compute) { | ||
TestGeneratorMockup gen({ 1.0, 2.0, 3.0 }); | ||
gen.init(); | ||
|
||
for (int i = 0; i < 3; ++i) { | ||
ASSERT_TRUE(gen.canCompute()); | ||
gen.compute(); | ||
} | ||
EXPECT_FALSE(gen.canCompute()); | ||
|
||
EXPECT_COSTS(gen.solutions(), ::testing::ElementsAre(1, 2, 3)); | ||
} | ||
|
||
#define COMPUTE_EXPECT_COSTS(stage, ...) \ | ||
{ \ | ||
EXPECT_TRUE(stage.canCompute()); \ | ||
stage.compute(); \ | ||
EXPECT_COSTS(stage.solutions(), ::testing::ElementsAre(__VA_ARGS__)); \ | ||
constexpr auto num_elements = std::initializer_list<double>{ __VA_ARGS__ }.size(); \ | ||
EXPECT_EQ(runs, num_elements); \ | ||
} | ||
|
||
TEST(GeneratorMockup, delayed) { | ||
auto gen = std::make_unique<TestGeneratorMockup>(PredefinedCosts({ 1.0, 2.0, 3.0 })); | ||
gen->init(); | ||
auto& runs = gen->runs_; | ||
|
||
DelayingWrapper w({ 1, 0, 2 }, std::move(gen)); | ||
auto prev_ends = std::make_shared<Interface>(); | ||
auto next_starts = std::make_shared<Interface>(); | ||
|
||
WrapperBasePrivate* impl = w.pimpl(); | ||
impl->setPrevEnds(prev_ends); | ||
impl->setNextStarts(next_starts); | ||
|
||
// 1st compute() is delayed by 1 | ||
COMPUTE_EXPECT_COSTS(w); | ||
COMPUTE_EXPECT_COSTS(w, 1); | ||
|
||
// 2nd compute() is not delayed | ||
COMPUTE_EXPECT_COSTS(w, 1, 2); | ||
|
||
// 1st compute() is delayed by 2 | ||
COMPUTE_EXPECT_COSTS(w, 1, 2); | ||
COMPUTE_EXPECT_COSTS(w, 1, 2); | ||
COMPUTE_EXPECT_COSTS(w, 1, 2, 3); | ||
|
||
EXPECT_FALSE(w.canCompute()); | ||
} | ||
#undef COMPUTE_EXPECT_COSTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to get my head around why this happens in some situations I encountered in the past and failed.
Can you describe a scenario where the assert will be violated with pruning active?
I'm fine with changing it because it is a step necessary if we want to have a flag that disables pruning for a whole task (any unpruned stage with a dead end on the other side of a partial solution will trigger this assert), but I do not yet understand why it can be invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the reasons anymore (it's nearly half a year ago that I handled this).
I think we cannot be sure that only valid solutions enter the start/end interfaces. For example, Connect stages do preserve all InterfaceStates, both successes and failures. We just save failures for later inspection as well.
Thus, we need to explicitly filter them here.
I remember that this was a no-brainer when encountering it. But now I don't remember a concrete example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, my fault for letting it lie around for so long.
Of course, but they also prune the paths on failure. so unless the solution path forks, the other end should not compute at all (as the interface state is pruned). I came up with an example case below where the assert is violated with forking solution paths:
But I observed a rare stochastic assert in the following situation some days ago where
turn
yielded a solution which hit the assert when propagating back the priority to the failed attempt inapproach grasp
:In this situation there are no obvious forking solution paths (unless ComputeIK factors through a single pose in the wrapped generator, but that should not happen?) and the failure in
approach grasp
should have pruned the only connected interface start state inturn
, so the compute call that generated theturn
solution should not have happened.I tried to write a test case for this, but failed to do so in reasonable time.
So TLDR: I guess dropping the assert is correct, but also obfuscates bugs in the pruning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange that you cannot reproduce the error in a simpler unit test.