-
Notifications
You must be signed in to change notification settings - Fork 123
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
Fix fuse optimizer unit test #369
Conversation
Looks like you're not the only one: ros-controls/ros2_controllers#1101 Slightly different use case, but the net result is the same. Looking at other issues linked there, I see a comment from William Woodall: It feels like there has to be some kind of dangling reference to the sub somewhere. You are using this overload: The Your solution is obviously find, but I wonder if you used the other overload, which forces you to create the sub yourself, then you could manually call |
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.
sounds like the wait_for_message should be creating a subscription with a callback group created with automatically_add_to_executor_with_node = false
so that a wait_set can be later created without raising that exception?
rclcpp::SubscriptionOptions opts;
opts.callback_group =
node->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive, false);
auto sub = node->create_subscription<MsgT>(topic, 1, [](const std::shared_ptr<const MsgT>) {}, opts);
return wait_for_message<MsgT, Rep, Period>(
out, sub, node->get_node_options().context(), time_to_wait);
Maybe? It's hard to know if that test is throwing a fault on the first call to |
Just for fun I added some tracing print statements.
|
But as Tom/Carlos suggest:
This does work. However, now that I see what is happening under the hood, I'm not in love with the loop creating a subscriber every time. That seems like it could lead to missed/dropped messages? If the external node published a message at just the wrong time? |
I think I'm going to leave the unit test as-is -- create a normal subscriber and wait for the expected message. This feels like it requires far less explanation for how the test works. But I did realize I introduced a threading problem. The last commit adds a mutex to guard access to the stored odometry message. |
…hrowing an exception 'subscription already associated with a wait set'. Switched to a standard subscriber instead.
9d09337
to
bd8e60c
Compare
Checking if adding a comment will trigger the upstream CI build to run |
I don't understand. The last PR magically triggered CI jobs after I added a comment. This one refuses. Merging anyway. |
* Fix fuse optimizer unit test. The rclcpp::wait_for_message call was throwing an exception 'subscription already associated with a wait set'. Switched to a standard subscriber instead.
Fix fuse optimizer unit test. The
rclcpp::wait_for_message
call was throwing an exception 'subscription already associated with a wait set'. I have no idea why. My instinct is that the node in this unit test is using a single-threaded executor with a dedicated spin thread, and that maybe therclcpp::wait_for_message
is also trying to spin that same subscriber? 🤷I switched the test to use a normal subscriber + callback function. It's not the prettiest thing, but it's not terrible either. I also needed to add a delay between publishing
pose_msg1
andpose_msg2
. Again, I have no idea why this is needed. I have the publisher queue set to 5, and the pose subscriber has a default queue size of 10. I'm not sure why the first message is getting lost.