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

MGI CallbackGroup doesn't trigger when running external Executor + Fast-DDS #1474

Closed
AndyZe opened this issue Aug 3, 2022 · 15 comments
Closed
Labels
bug Something isn't working

Comments

@AndyZe
Copy link
Member

AndyZe commented Aug 3, 2022

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: #1305

@AndyZe AndyZe added the bug Something isn't working label Aug 3, 2022
@AndyZe
Copy link
Member Author

AndyZe commented Aug 3, 2022

Indeed, rolling back #1305 prevents the issue.

@henningkayser
Copy link
Member

Does MoveGroup receive the planning call and does it return a result?

@AndyZe
Copy link
Member Author

AndyZe commented Aug 3, 2022

Yes, planning succeeds. I'm not sure if it tries to return a value or not. (If it does try to return a value, it doesn't make it.) Easy to test with the tutorial

@henningkayser
Copy link
Member

What do you mean with "parallel with 'other things'"? Running MGI requests from multiple threads?

@AndyZe
Copy link
Member Author

AndyZe commented Aug 3, 2022

moveit_visual_tools in this case. You can look at the linked tutorial code

@henningkayser
Copy link
Member

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 ros2/rclcpp#1611.
The code in MGI looks correct to me, otherwise.

@henningkayser henningkayser changed the title MoveGroupInterface in parallel with "other things" --> blocking MGI CallbackGroup doesn't trigger callbacks when running external Executor Aug 3, 2022
@BrettHemes
Copy link
Contributor

I just encountered this yesterday as well... My ROS Answers post here from earlier today for reference.

@BrettHemes
Copy link
Contributor

However, moving MGI initialization before the SingleThreadedExecutor does the trick for me

I can confirm this works in my application as well.

@HammadB
Copy link

HammadB commented Aug 17, 2022

However, moving MGI initialization before the SingleThreadedExecutor does the trick for me

This works for me as well

@henningkayser
Copy link
Member

Thanks @mikeferguson, I just confirmed that everything is fine when using Cyclone DDS (link for anyone who wants to reproduce). Was this the issue you were referring to? The bug has hopefully been fixed already with ros2/rmw_fastrtps#619, we should check that.

@henningkayser henningkayser changed the title MGI CallbackGroup doesn't trigger callbacks when running external Executor MGI CallbackGroup doesn't trigger when running external Executor + Fast-DDS Aug 25, 2022
@AbduEhab
Copy link

However, moving MGI initialization before the SingleThreadedExecutor does the trick for me.

This does seem to fix the issue for me too, has it been changed in the documentation yet?

@AndyZe
Copy link
Member Author

AndyZe commented Sep 17, 2022

However, moving MGI initialization before the SingleThreadedExecutor does the trick for me.

I gave this a shot yesterday but it didn't completely fix the issue. I could proceed a little farther through the tutorials but they still deadlocked eventually. I guess switching to Cyclone DDS is the best fix, unfortunately.

@henningkayser
Copy link
Member

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

@henningkayser henningkayser moved this to 🏗 In progress in MoveIt Mar 10, 2023
@JafarAbdi
Copy link
Member

Fixed in the latest release ros2/rmw_fastrtps#650

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in MoveIt Apr 12, 2023
@fzoric8
Copy link

fzoric8 commented May 9, 2024

Hi,

Could mentioned problem be connected with following maybe?

I'm not able to set up MoveGroupInterface with MultiThreadedExecutor? Is that expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants