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

Add wait_for_all_acked support #793

Merged
merged 8 commits into from
Sep 13, 2021

Conversation

Barry-Xu-2018
Copy link
Contributor

Related to ros2/rmw#295

false.
"""
with self.handle:
return self.__publisher.wait_for_all_acked(timeout._duration_handle)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should use try&except statement? Publisher::wait_for_all_acked would throw RCLError exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After check other codes, I find it also doesn't deal with RCLError.
e.g.

def publish(self, msg: Union[MsgType, bytes]) -> None:
"""
Send a message to the topic for the publisher.
:param msg: The ROS message to publish.
:raises: TypeError if the type of the passed message isn't an instance
of the provided type when the publisher was constructed.
"""
with self.handle:
if isinstance(msg, self.msg_type):
self.__publisher.publish(msg)
elif isinstance(msg, bytes):
self.__publisher.publish_raw(msg)
else:
raise TypeError('Expected {}, got {}'.format(self.msg_type, type(msg)))

Not catch exception

The underlying code may throw exception

void
Publisher::publish(py::object pymsg)
{
auto raw_ros_message = convert_from_py(pymsg);
if (!raw_ros_message) {
throw py::error_already_set();
}
rcl_ret_t ret = rcl_publish(rcl_publisher_.get(), raw_ros_message.get(), NULL);
if (RCL_RET_OK != ret) {
throw RCLError("Failed to publish");
}
}

@@ -75,6 +76,26 @@ def do_test_topic_name(cls, test_topics, node):
assert publisher.topic_name == target_topic
publisher.destroy()

@classmethod
def do_test_wait_for_all_acked(cls, test_topic, node):
pub = node.create_publisher(BasicTypes, test_topic, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QoS Reliable setting would be nice to check too.

@Barry-Xu-2018
Copy link
Contributor Author

Friendly ping @fujitatomoya. Please look at my comments and I supplement tests.

@fujitatomoya fujitatomoya added the enhancement New feature or request label May 18, 2021
@fujitatomoya
Copy link
Collaborator

CC: @ivanpauno @wjwwood friendly ping.

@sloretz sloretz force-pushed the topic-wait_for_all_acked-feature branch from 85c8ac1 to 4cd0524 Compare August 12, 2021 17:57
Copy link
Contributor

@sloretz sloretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, since it's been a while I made some changes pushed it to your branch directly

I would like it to be reviewed by once more by someone who hasn't edited this PR


# Publisher is reliable and subscription is best effort
pub_qos.reliability = rclpy.qos.QoSReliabilityPolicy.RELIABLE
TestPublisher.do_test_wait_for_all_acked(TEST_TOPIC, self.node, pub_qos, sub_qos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a need for trying the different QoS options - it seems unrelated to the feature being tested.

Copy link
Contributor

@sloretz sloretz Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Barry-Xu-2018 and others added 8 commits September 1, 2021 13:24
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Barry Xu <barry.xu@sony.com>
@Barry-Xu-2018 Barry-Xu-2018 force-pushed the topic-wait_for_all_acked-feature branch from 2efbaa3 to e1c6ca2 Compare September 2, 2021 06:39
@Barry-Xu-2018
Copy link
Contributor Author

Do rebase.

@Barry-Xu-2018
Copy link
Contributor Author

rcl package isn't updated (ros2/rcl#913 isn't included). So CI failed.

14:41:44 /tmp/ws/src/rclpy/rclpy/src/rclpy/publisher.cpp: In member function ‘bool rclpy::Publisher::wait_for_all_acked(rcl_duration_t)’:
14:41:44 /tmp/ws/src/rclpy/rclpy/src/rclpy/publisher.cpp:149:19: error: ‘rcl_publisher_wait_for_all_acked’ was not declared in this scope
14:41:44   149 |   rcl_ret_t ret = rcl_publisher_wait_for_all_acked(rcl_publisher_.get(), pytimeout.nanoseconds);
14:41:44       |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14:41:44 make[2]: *** [CMakeFiles/_rclpy_pybind11.dir/build.make:297: CMakeFiles/_rclpy_pybind11.dir/src/rclpy/publisher.cpp.o] Error 1
14:41:44 make[1]: *** [CMakeFiles/Makefile2:193: CMakeFiles/_rclpy_pybind11.dir/all] Error 2
14:41:44 make: *** [Makefile:141: all] Error 2

@ivanpauno
Copy link
Member

Released rcl (ros/rosdistro#30681), the Rpr checker should start passing in some hours.

@Barry-Xu-2018
Copy link
Contributor Author

@ros-pull-request-builder retest this please

@ivanpauno
Copy link
Member

@Barry-Xu-2018 @fujitatomoya can you run ci?
This is ready to go

@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@ivanpauno ivanpauno merged commit a1b1cc2 into ros2:master Sep 13, 2021
@@ -103,6 +105,29 @@ def test_topic_name_remapping(self):
]
TestPublisher.do_test_topic_name(test_topics, self.node)

def test_wait_for_all_acked(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is failing with Connext #824

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

Successfully merging this pull request may close these issues.

5 participants