moveit2: MGI CallbackGroup doesn't trigger when running external Executor + Fast-DDS

Description

The OMPL constrained planning tutorial here no longer works.

I’ve traced it down to this:

  rclcpp::NodeOptions node_options;
  node_options.automatically_declare_parameters_from_overrides(true);
  auto node = rclcpp::Node::make_shared("ompl_constrained_planning_demo_node", node_options);

  rclcpp::executors::SingleThreadedExecutor executor;
  executor.add_node(node);
  auto spinner = std::thread([&executor]() { executor.spin(); });
  
  moveit::planning_interface::MoveGroupInterface move_group_interface(node, "panda_arm");
  auto moveit_visual_tools =
      moveit_visual_tools::MoveItVisualTools{ node, "panda_link0", rviz_visual_tools::RVIZ_MARKER_TOPIC,
                                              move_group_interface.getRobotModel() };
      ...
   success = (move_group_interface.plan(plan) == moveit::core::MoveItErrorCode::SUCCESS);
   RCLCPP_INFO(LOGGER, "Plan with plane constraint %s", success ? "" : "FAILED");   // Never prints

The last line does not print. In other words, the mgi.plan() call is blocking. I suspect this has to do with conflicting callback groups.

I tried a multi-threaded executor as well as two separate nodes.

I’m suspicious that this PR caused the bug: https://github.com/ros-planning/moveit2/pull/1305

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

so… what is the current status of this? Haven’t the FastDDS issues been resolved by now?

Ok, this is odd. I could reproduce this very easily, and indeed changing executor or callback group settings wouldn’t fix this. However, moving MGI initialization before the SingleThreadedExecutor does the trick for me:

  rclcpp::NodeOptions node_options;
  node_options.automatically_declare_parameters_from_overrides(true);
  auto node = rclcpp::Node::make_shared("ompl_constrained_planning_demo_node", node_options);
  
  moveit::planning_interface::MoveGroupInterface move_group_interface(node, "panda_arm");

  rclcpp::executors::SingleThreadedExecutor executor;
  executor.add_node(node);
  auto spinner = std::thread([&executor]() { executor.spin(); });
  
  auto moveit_visual_tools =
      moveit_visual_tools::MoveItVisualTools{ node, "panda_link0", rviz_visual_tools::RVIZ_MARKER_TOPIC,
                                              move_group_interface.getRobotModel() };
      ...
   success = (move_group_interface.plan(plan) == moveit::core::MoveItErrorCode::SUCCESS);
   RCLCPP_INFO(LOGGER, "Plan with plane constraint %s", success ? "" : "FAILED");   // Never prints

This looks like some rmw/CallbackGroup bug to me, possibly related to https://github.com/ros2/rclcpp/issues/1611. The code in MGI looks correct to me, otherwise.