-
Notifications
You must be signed in to change notification settings - Fork 237
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
Conversation
293d7d3
to
b37d9ce
Compare
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.
LGTM, thanks Jaison!
// 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; |
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.
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.
b37d9ce
to
8ec5d35
Compare
40a6a9a
to
c78cb46
Compare
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.
LGTM!
QoSSubscriptionEventType - Added support for the above events in the QoSEventHandler Signed-off-by: Jaison Titus <[email protected]>
Signed-off-by: Jaison Titus <[email protected]>
- Added test for incompatible_qos events Signed-off-by: Jaison Titus <[email protected]>
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
c78cb46
to
b5f7a05
Compare
Signed-off-by: Miaofei <[email protected]>
rclpy/rclpy/qos.py
Outdated
This enum matches the one defined in rmw/incompatible_qos_events_statuses.h | ||
""" | ||
|
||
RMW_QOS_POLICY_INVALID = 1 << 0 |
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.
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.
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.
I am not sure how to do that. Do you have an example?
QoSPublisherEventType
and QoSSubscriptionEventType
were also done this way.
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.
Not really nice, but here an example:
rclpy/rclpy/src/rclpy/_rclpy_logging.c
Line 244 in 3d1698a
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.
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.
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.
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.
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!
rclpy/rclpy/qos_event.py
Outdated
QoSOfferedIncompatibleQoSInfo = QoSRequestedIncompatibleQoSInfo | ||
|
||
|
||
class UnsupportedEventTypeException(Exception): |
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.
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
.
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.
Actually, NotImplementedError
may be a better base class.
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.
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.
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.
The Python documentation says "All user-defined exceptions should also be derived from this class (Exception)", so I don't think
RuntimeError
orNotImplementedError
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?
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.
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.
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.
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
.
rclpy/src/rclpy/_rclpy_qos_event.c
Outdated
PyObject * pyqos_event_exception = NULL; | ||
|
||
if (RCL_RET_UNSUPPORTED == ret) { | ||
PyObject * pyqos_event_module = PyImport_ImportModule("rclpy.qos_event"); |
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.
I think that it's better to define the new exception in C
, like this:
rclpy/rclpy/src/rclpy/_rclpy.c
Line 5523 in 3d1698a
RCLError = PyErr_NewExceptionWithDoc( |
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.
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.*
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.
you can import it in rclpy.qos_event
and then reexport it.
@wjwwood for a second opinion.
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.
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.
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.
I have moved the definition of the new exception into C instead of Python.
Signed-off-by: Miaofei <[email protected]>
a5eaf57
to
885a520
Compare
Are the |
I'm ok with running them in only one implementation. |
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
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.
LGTM! (with green CI)
Thanks! The following is the set of remaining pull requests for this feature:
After I add some more tests to |
@ros2/aws-oncall - please run this CI job |
|
I have pushed a fix to ros2/ros2cli#410. @ros2/aws-oncall, can you please re-run CI (#459 (comment))? |
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. |
Please, address the comment in that one. I will merge the others now. |
…_QOS events (#459) Signed-off-by: Jaison Titus <[email protected]> Signed-off-by: Miaofei <[email protected]> Co-authored-by: Miaofei <[email protected]>
Depends on ros2/rcl:535
Related to this feature request. The design and implementation details can also be found there.
INCOMPATIBLE_QOS
event type toQoSPublisherEventType
andQoSSubscriptionEventType
QoSEventHandler
test_qos_event.py
to include the new events.Signed-off-by: Jaison Titus [email protected]