Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Support for ON_REQUESTED_INCOMPATIBLE_QOS and ON_OFFERED_INCOMPATIBLE_QOS events #459
Changes from 6 commits
ed09bf1
10cf607
6a17ca9
d743efa
b5f7a05
900772a
885a520
2095a30
c8d8309
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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
andQoSSubscriptionEventType
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
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.
Sounds good!
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
, asError
is usually used as suffix in Python instead ofException
.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
orNotImplementedError
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.
IMHO, that means that
isinstance(CustomError(..), Exception)
should beTrue
.That's the case, because the base case of
RuntimeError
isException
.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 fromRuntimeError
.@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 fromRCLError
instead ofRuntimeError
.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.
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
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:
whereas if we define it in Python (as it is in this pull request currently), the usage would be like:
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.