diff --git a/rclpy/rclpy/publisher.py b/rclpy/rclpy/publisher.py index 3c0790c10..9dece4f11 100644 --- a/rclpy/rclpy/publisher.py +++ b/rclpy/rclpy/publisher.py @@ -12,15 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import List from typing import TypeVar from rclpy.callback_groups import CallbackGroup from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy from rclpy.qos import QoSProfile from rclpy.qos_event import PublisherEventCallbacks -from rclpy.qos_event import QoSEventHandler -from rclpy.qos_event import QoSPublisherEventType MsgType = TypeVar('MsgType') @@ -60,8 +57,6 @@ def __init__( self.node_handle = node_handle self.callback_group = callback_group - self.event_callbacks = event_callbacks - self.event_handlers: List[QoSEventHandler] = [] self.event_callbacks = event_callbacks self.event_handlers = event_callbacks.create_event_handlers( callback_group, publisher_handle) diff --git a/rclpy/rclpy/subscription.py b/rclpy/rclpy/subscription.py index 50c9cb5fb..a877850cc 100644 --- a/rclpy/rclpy/subscription.py +++ b/rclpy/rclpy/subscription.py @@ -13,13 +13,10 @@ # limitations under the License. from typing import Callable -from typing import List from typing import TypeVar from rclpy.callback_groups import CallbackGroup from rclpy.qos import QoSProfile -from rclpy.qos_event import QoSEventHandler -from rclpy.qos_event import QoSSubscriptionEventType from rclpy.qos_event import SubscriptionEventCallbacks diff --git a/rclpy/src/rclpy/_rclpy.c b/rclpy/src/rclpy/_rclpy.c index 33200b1bd..c7573e484 100644 --- a/rclpy/src/rclpy/_rclpy.c +++ b/rclpy/src/rclpy/_rclpy.c @@ -3606,7 +3606,6 @@ rclpy_convert_from_py_qos_policy(PyObject * Py_UNUSED(self), PyObject * args) qos_profile->depth = pyqos_depth; qos_profile->reliability = pyqos_reliability; qos_profile->durability = pyqos_durability; - qos_profile->deadline = (rmw_time_t){0, 500 * 1000LL * 1000LL}; qos_profile->avoid_ros_namespace_conventions = avoid_ros_namespace_conventions; PyObject * pyqos_profile = PyCapsule_New(qos_profile, "rmw_qos_profile_t", NULL); return pyqos_profile; diff --git a/rclpy/src/rclpy/_rclpy_qos_event.c b/rclpy/src/rclpy/_rclpy_qos_event.c index 7936f0db5..4eac52666 100644 --- a/rclpy/src/rclpy/_rclpy_qos_event.c +++ b/rclpy/src/rclpy/_rclpy_qos_event.c @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + typedef union _qos_event_callback_data { // Subscription events rmw_requested_deadline_missed_status_t requested_deadline_missed; @@ -21,9 +23,11 @@ typedef union _qos_event_callback_data { rmw_liveliness_lost_status_t liveliness_lost; } _qos_event_callback_data_t; -typedef PyObject * (*_qos_event_data_filler_function)(_qos_event_callback_data_t *); +typedef PyObject * (* _qos_event_data_filler_function)(_qos_event_callback_data_t *); -bool _check_rcl_return(rcl_ret_t ret, const char * error_msg) { +bool +_check_rcl_return(rcl_ret_t ret, const char * error_msg) +{ if (ret != RCL_RET_OK) { PyErr_Format(PyExc_RuntimeError, "%s: %s", error_msg, rcl_get_error_string().str); @@ -177,7 +181,7 @@ _liveliness_lost_to_py_object(_qos_event_callback_data_t * data) _qos_event_data_filler_function -_get_qos_event_data_filler_function_for(PyObject * pyparent, unsigned long event_type) +_get_qos_event_data_filler_function_for(PyObject * pyparent, uint32_t event_type) { if (_is_pycapsule_rcl_subscription(pyparent)) { switch (event_type) { @@ -203,7 +207,6 @@ _get_qos_event_data_filler_function_for(PyObject * pyparent, unsigned long event PyErr_Format(PyExc_TypeError, "Parent handle was not a valid Publisher or Subscription."); } - return NULL; } @@ -226,9 +229,13 @@ rclpy_create_event(PyObject * Py_UNUSED(self), PyObject * args) { unsigned PY_LONG_LONG pyevent_type; PyObject * pyparent = NULL; + + rcl_ret_t ret; rcl_subscription_t * subscription = NULL; rcl_publisher_t * publisher = NULL; - rcl_ret_t ret; + rcl_event_t * event = NULL; + + PyObject * pyevent = NULL; if (!PyArg_ParseTuple(args, "KO", &pyevent_type, &pyparent)) { return NULL; @@ -243,7 +250,7 @@ rclpy_create_event(PyObject * Py_UNUSED(self), PyObject * args) return NULL; } - rcl_event_t * event = _new_zero_initialized_rcl_event(); + event = _new_zero_initialized_rcl_event(); if (!event) { return NULL; } @@ -253,15 +260,14 @@ rclpy_create_event(PyObject * Py_UNUSED(self), PyObject * args) } else { ret = rcl_publisher_event_init(event, publisher, pyevent_type); } - if (!_check_rcl_return(ret, "Failed to initialize event")) { PyMem_Free(event); return NULL; } - PyObject * pyevent = PyCapsule_New(event, "rcl_event_t", _destroy_event_capsule); + pyevent = PyCapsule_New(event, "rcl_event_t", _destroy_event_capsule); if (!pyevent) { - rcl_ret_t ret = rcl_event_fini(event); + ret = rcl_event_fini(event); PyMem_Free(event); _check_rcl_return(ret, "Failed to fini 'rcl_event_t'"); return NULL; @@ -295,10 +301,9 @@ rclpy_take_event(PyObject * Py_UNUSED(self), PyObject * args) // Type conversion rcl_ret_t ret; - _qos_event_callback_data_t event_data; - rcl_event_t * event = NULL; PyObject * pyqos_event = NULL; + _qos_event_callback_data_t event_data; _qos_event_data_filler_function event_filler = NULL; if (!PyArg_ParseTuple(args, "OOK", &pyevent, &pyparent, &pyevent_type)) { @@ -323,7 +328,6 @@ rclpy_take_event(PyObject * Py_UNUSED(self), PyObject * args) pyqos_event = event_filler(&event_data); if (!pyqos_event) { - PyErr_Format(PyExc_RuntimeError, "Unable to convert callback payload into a Python type."); return NULL; } return pyqos_event; diff --git a/rclpy/src/rclpy_common/include/rclpy_common/common.h b/rclpy/src/rclpy_common/include/rclpy_common/common.h index f6e089cbf..58e30ffdf 100644 --- a/rclpy/src/rclpy_common/include/rclpy_common/common.h +++ b/rclpy/src/rclpy_common/include/rclpy_common/common.h @@ -16,7 +16,6 @@ #include -#include #include // rcl_names_and_types_t #include diff --git a/rclpy/test/test_qos_event.py b/rclpy/test/test_qos_event.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/rclpy/test/test_qos_event.py @@ -0,0 +1 @@ +