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

Support for ON_REQUESTED_INCOMPATIBLE_QOS and ON_OFFERED_INCOMPATIBLE_QOS events #459

Merged
merged 9 commits into from Apr 1, 2020

Conversation

jaisontj
Copy link
Contributor

@jaisontj jaisontj commented Nov 15, 2019

Depends on ros2/rcl:535

Related to this feature request. The design and implementation details can also be found there.

  • Added INCOMPATIBLE_QOS event type to QoSPublisherEventType and QoSSubscriptionEventType
  • Added support for the above events in the QoSEventHandler
  • modified test_qos_event.py to include the new events.

Signed-off-by: Jaison Titus jaisontj92@gmail.com

Copy link
Contributor

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Jaison!

rclpy/rclpy/qos_event.py Outdated Show resolved Hide resolved
// Publisher events
rmw_offered_deadline_missed_status_t offered_deadline_missed;
rmw_liveliness_lost_status_t liveliness_lost;
rmw_offered_incompatible_qos_status_t offered_incompatible_qos;
} _qos_event_callback_data_t;
Copy link
Member

Choose a reason for hiding this comment

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

The idea of _qos_event_callback_data_t doesn't scale well, it gets bigger and bigger ...
The problem is maybe unrelated to the PR, but creating an issue may worth it.

rclpy/rclpy/qos_event.py Outdated Show resolved Hide resolved
@wjwwood wjwwood self-assigned this Jan 9, 2020
@mm318 mm318 force-pushed the jaisontj/incompatible_qos branch from 40a6a9a to c78cb46 Compare March 11, 2020 18:12
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

LGTM!

jaisontj and others added 5 commits March 22, 2020 10:10
QoSSubscriptionEventType
- Added support for the above events in the QoSEventHandler

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
- Added test for incompatible_qos events

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
rclpy/rclpy/qos.py Outdated Show resolved Hide resolved
This enum matches the one defined in rmw/incompatible_qos_events_statuses.h
"""

RMW_QOS_POLICY_INVALID = 1 << 0
Copy link
Member

Choose a reason for hiding this comment

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

It would also be good to use the values defined in rmw, instead of manually write them here again.

I don't mind strongly, you can left a TODO.

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure how to do that. Do you have an example?

QoSPublisherEventType and QoSSubscriptionEventType were also done this way.

Copy link
Member

Choose a reason for hiding this comment

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

Not really nice, but here an example:

rclpy_get_error_logging_severity(PyObject * Py_UNUSED(self), PyObject * Py_UNUSED(args))

You could also create the constants in the module init function, but again, not super nice.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I'm not sure if this is worth the effort, because it won't automatically synchronize when new enums are added to rmw_qos_policy_kind_t.

I'll leave a TODO here.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I'm not sure if this is worth the effort, because it won't automatically synchronize when new enums are added to rmw_qos_policy_kind_t.

Sounds good!

QoSOfferedIncompatibleQoSInfo = QoSRequestedIncompatibleQoSInfo


class UnsupportedEventTypeException(Exception):
Copy link
Member

Choose a reason for hiding this comment

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

RuntimeError sounds like a better base class.
I would also rename the exception to UnsupportedEventTypeError, as Error is usually used as suffix in Python instead of Exception.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, NotImplementedError may be a better base class.

Copy link
Member

Choose a reason for hiding this comment

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

The Python documentation says "All user-defined exceptions should also be derived from this class (Exception)", so I don't think RuntimeError or NotImplementedError are meant to be base classes.

Copy link
Member

Choose a reason for hiding this comment

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

The Python documentation says "All user-defined exceptions should also be derived from this class (Exception)", so I don't think RuntimeError or NotImplementedError are meant to be base classes.

IMHO, that means that isinstance(CustomError(..), Exception) should be True.
That's the case, because the base case of RuntimeError is Exception.
There's a nice hierarchy tree at the end of the page you linked.
AFAIK, it's a usual practice to subclass RuntimeError or any other python built-in exception.
e.g.: RCLError subclass from RuntimeError.

@wjwwood what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Correct, you can, and where appropriate, you should inherit from other exception types. They just mean you should raise a completely custom class that does not inherit from exception at all, directly or indirectly.

Copy link
Member

Choose a reason for hiding this comment

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

I will move the definition of this exception to _rclpy.c as suggested at #459 (comment) , in which case this exception will inherit from RCLError instead of RuntimeError.

PyObject * pyqos_event_exception = NULL;

if (RCL_RET_UNSUPPORTED == ret) {
PyObject * pyqos_event_module = PyImport_ImportModule("rclpy.qos_event");
Copy link
Member

Choose a reason for hiding this comment

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

I think that it's better to define the new exception in C, like this:

RCLError = PyErr_NewExceptionWithDoc(
.

Copy link
Member

Choose a reason for hiding this comment

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

If we define the new exception in C, then it looks like using it from Python module would be something like:

from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
...
try:
    ...
except _rclpy.UnsupportedEventTypeError as e:
    ...

whereas if we define it in Python (as it is in this pull request currently), the usage would be like:

from rclpy.qos_event import UnsupportedEventTypeError
...
try:
    ...
except UnsupportedEventTypeError as e:
    ...

I think the latter is better, because you probably wouldn't want a user to be importing rclpy.impl.*

Copy link
Member

Choose a reason for hiding this comment

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

you can import it in rclpy.qos_event and then reexport it.

@wjwwood for a second opinion.

Copy link
Member

Choose a reason for hiding this comment

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

I think both will work. It’s slightly less awkward to avoid importing code in the c extension and then reexport it as @ivanpauno said, but I don’t mind as long as it works.

Copy link
Member

Choose a reason for hiding this comment

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

I have moved the definition of the new exception into C instead of Python.

rclpy/src/rclpy/_rclpy_qos_event.c Outdated Show resolved Hide resolved
Signed-off-by: Miaofei <miaofei@amazon.com>
@mm318 mm318 force-pushed the jaisontj/incompatible_qos branch from a5eaf57 to 885a520 Compare March 26, 2020 07:38
@mm318
Copy link
Member

mm318 commented Mar 26, 2020

Are the rclpy tests only run with rmw_fastrtps_cpp? Should we make it run with additional rmw implementations?

@ivanpauno
Copy link
Member

Are the rclpy tests only run with rmw_fastrtps_cpp? Should we make it run with additional rmw implementations?

I'm ok with running them in only one implementation.
We also have jobs in build.ros2.org where only one implementation is available, so it will cover all off them there.

Signed-off-by: Miaofei <miaofei@amazon.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

LGTM! (with green CI)

@mm318
Copy link
Member

mm318 commented Mar 31, 2020

@ros2/aws-oncall - please run this CI job
Gist: https://gist.githubusercontent.com/mm318/e32e5d8c1e712f6098101fa6b32efc57/raw/48efc95ff1c41ef1cab6322f2b639221637c34a0/ros2_qos.repos
BUILD args: --packages-up-to ros2topic quality_of_service_demo_cpp quality_of_service_demo_py
TEST args: --packages-select rclcpp rclpy ros2topic quality_of_service_demo_cpp quality_of_service_demo_py
Job: ci_launcher

@dabonnie
Copy link

dabonnie commented Mar 31, 2020

@ros2/aws-oncall - please run this CI job
Gist: https://gist.githubusercontent.com/mm318/e32e5d8c1e712f6098101fa6b32efc57/raw/48efc95ff1c41ef1cab6322f2b639221637c34a0/ros2_qos.repos
BUILD args: --packages-up-to ros2topic quality_of_service_demo_cpp quality_of_service_demo_py
TEST args: --packages-select rclcpp rclpy ros2topic quality_of_service_demo_cpp quality_of_service_demo_py
Job: ci_launcher

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

@mm318
Copy link
Member

mm318 commented Mar 31, 2020

I have pushed a fix to ros2/ros2cli#410. @ros2/aws-oncall, can you please re-run CI (#459 (comment))?

@dabonnie
Copy link

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

@mm318
Copy link
Member

mm318 commented Mar 31, 2020

Hi @ivanpauno, can you take a look at the CI results at #459 (comment)? I think the macOS and Windows CI test failures are unrelated.

@ivanpauno
Copy link
Member

Hi @ivanpauno, can you take a look at the CI results at #459 (comment)? I think the macOS and Windows CI test failures are unrelated.

Seems to be unrelated to me.

@ivanpauno
Copy link
Member

ros2/demos#416

Please, address the comment in that one. I will merge the others now.

@ivanpauno ivanpauno merged commit a1477e8 into ros2:master Apr 1, 2020
tfoote added a commit that referenced this pull request Apr 1, 2020
Revert "switch to slightly more generic isinstance"

This reverts commit 77df874.

Revert "Support for ON_REQUESTED_INCOMPATIBLE_QOS and ON_OFFERED_INCOMPATIBLE_QOS events (#459)"

This reverts commit a1477e8.
tfoote pushed a commit that referenced this pull request Apr 1, 2020
…_QOS events (#459)

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
Co-authored-by: Miaofei <miaofei@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review Waiting for review (Kanban column)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants