-
Notifications
You must be signed in to change notification settings - Fork 196
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
Update tutorial to avoid moving the MTC task #426
Conversation
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.
Cloned and ran and it works as expected now! Didn't encounter any problems
Obviously, it would be better to fix MTC. Is there an issue for the underlying problem? Could you pinpoint the problem? |
@rhaschke I was debugging this issue yesterday and came up with a minimal reproducible example, I'll open a draft PR later today TEST(Task, taskMoveContructor) {
rclcpp::init(0, nullptr);
auto createTask = [] {
moveit::core::RobotModelConstPtr robot_model = getModel();
Task t("first");
t.setRobotModel(robot_model);
resetMockupIds();
auto ref = new stages::FixedState("fixed");
auto scene = std::make_shared<planning_scene::PlanningScene>(t.getRobotModel());
ref->setState(scene);
t.add(Stage::pointer(ref));
t.add(std::make_unique<ConnectMockup>());
t.add(std::make_unique<MonitoringGeneratorMockup>(ref));
return t;
};
// Doesn't segfault
/* Task t = createTask(); */
// Segfaults when introspection is enabled
Task t;
t = createTask();
try {
t.init();
EXPECT_TRUE(t.plan(1));
} catch (const InitStageException& e) {
ADD_FAILURE() << "InitStageException:" << std::endl << e << t;
}
} |
I agree that we should fix MTC as well, but I also think this workaround is a better usage example for the tutorials. It's a bit cleaner to read, and there's really no need to move the task around when we can just pass a reference to it. |
I don't really agree. I think it is quite natural to have a factory function for task creation instead of "filling" a provided task instance. |
Generally, I think it is not advisable to use mutable reference parameters. I agree that the better option is to fix MTC than to require/encourage people to create mutable references. |
OK, then we can leave the tutorial as-is - I'll close this PR once MTC is fixed. |
Description
Running the existing MTC tutorial code will segfault with the latest version of MoveIt Task Constructor. Workaround is to avoid moving/copying the MTC task.
Checklist