Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Miaofei <miaofei@amazon.com>
  • Loading branch information
mm318 committed Mar 26, 2020
1 parent 900772a commit a5eaf57
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
27 changes: 13 additions & 14 deletions rclpy/rclpy/qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,28 @@ class QoSPolicyKind(IntEnum):
This enum matches the one defined in rmw/incompatible_qos_events_statuses.h
"""

RMW_QOS_POLICY_INVALID = 1 << 0
RMW_QOS_POLICY_DURABILITY = 1 << 1
RMW_QOS_POLICY_DEADLINE = 1 << 2
RMW_QOS_POLICY_LIVELINESS = 1 << 3
RMW_QOS_POLICY_RELIABILITY = 1 << 4
RMW_QOS_POLICY_HISTORY = 1 << 5
RMW_QOS_POLICY_LIFESPAN = 1 << 6
INVALID = 1 << 0
DURABILITY = 1 << 1
DEADLINE = 1 << 2
LIVELINESS = 1 << 3
RELIABILITY = 1 << 4
HISTORY = 1 << 5
LIFESPAN = 1 << 6


def qos_policy_name_from_kind(policy_kind: QoSPolicyKind):
"""Get QoS policy name from QoSPolicyKind enum."""

if policy_kind == RMW_QOS_POLICY_DURABILITY:
if policy_kind == QoSPolicyKind.DURABILITY:
return 'DURABILITY_QOS_POLICY'
elif policy_kind == RMW_QOS_POLICY_DEADLINE:
elif policy_kind == QoSPolicyKind.DEADLINE:
return 'DEADLINE_QOS_POLICY'
elif policy_kind == RMW_QOS_POLICY_LIVELINESS:
elif policy_kind == QoSPolicyKind.LIVELINESS:
return 'LIVELINESS_QOS_POLICY'
elif policy_kind == RMW_QOS_POLICY_RELIABILITY:
elif policy_kind == QoSPolicyKind.RELIABILITY:
return 'RELIABILITY_QOS_POLICY'
elif policy_kind == RMW_QOS_POLICY_HISTORY:
elif policy_kind == QoSPolicyKind.HISTORY:
return 'HISTORY_QOS_POLICY'
elif policy_kind == RMW_QOS_POLICY_LIFESPAN:
elif policy_kind == QoSPolicyKind.LIFESPAN:
return 'LIFESPAN_QOS_POLICY'
else:
return 'INVALID_QOS_POLICY'
Expand Down
2 changes: 1 addition & 1 deletion rclpy/rclpy/qos_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class QoSSubscriptionEventType(IntEnum):
QoSOfferedIncompatibleQoSInfo = QoSRequestedIncompatibleQoSInfo


class UnsupportedEventTypeException(Exception):
class UnsupportedEventTypeError(Exception):
"""Raised when registering a callback for an event type that is not supported."""

def __init__(self, *args):
Expand Down
3 changes: 2 additions & 1 deletion rclpy/src/rclpy/_rclpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@

#include "rclpy_common/common.h"
#include "rclpy_common/handle.h"
#include "./_rclpy_qos_event.c"

static PyObject * RCLInvalidROSArgsError;
static PyObject * UnknownROSArgsError;
static PyObject * NodeNameNonExistentError;
static PyObject * RCLError;

#include "./_rclpy_qos_event.c"

void
_rclpy_context_handle_destructor(void * p)
{
Expand Down
5 changes: 3 additions & 2 deletions rclpy/src/rclpy/_rclpy_qos_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _check_rcl_return(rcl_ret_t ret, const char * error_msg)
return true;
}

PyObject * exception = PyExc_RuntimeError;
PyObject * exception = RCLError;
PyObject * pyqos_event_module = NULL;
PyObject * pyqos_event_exception = NULL;

Expand All @@ -47,7 +47,8 @@ _check_rcl_return(rcl_ret_t ret, const char * error_msg)
goto throw_exception;
}

PyObject * pyqos_event_exception = PyObject_GetAttrString(pyqos_event_module, "UnsupportedEventTypeException");
PyObject * pyqos_event_exception = PyObject_GetAttrString(
pyqos_event_module, "UnsupportedEventTypeError");
if (NULL == pyqos_event_exception) {
goto throw_exception;
}
Expand Down

0 comments on commit a5eaf57

Please sign in to comment.