Skip to content
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

Closed

Conversation

stephanie-eng
Copy link
Contributor

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

  • Required by CI: Code is auto formatted using clang-format
  • While waiting for someone to review your request, please consider reviewing another open pull request to support the maintainers

Copy link
Contributor

@henrygerardmoore henrygerardmoore left a 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

@rhaschke
Copy link
Contributor

rhaschke commented Jun 9, 2022

Obviously, it would be better to fix MTC. Is there an issue for the underlying problem? Could you pinpoint the problem?
I think this worked with MoveIt1.

@JafarAbdi
Copy link
Member

Obviously, it would be better to fix MTC. Is there an issue for the underlying problem? Could you pinpoint the problem? I think this worked with MoveIt1.

@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;
	}
}

@stephanie-eng
Copy link
Contributor Author

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.

@rhaschke
Copy link
Contributor

rhaschke commented Jun 9, 2022

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.

@tylerjw
Copy link
Member

tylerjw commented Jun 9, 2022

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.

@stephanie-eng
Copy link
Contributor Author

OK, then we can leave the tutorial as-is - I'll close this PR once MTC is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants