Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions rclpy/rclpy/impl/_rclpy_pybind11.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -602,14 +602,6 @@ class Subscription(Destroyable, Generic[MsgT]):
def get_publisher_count(self) -> int:
"""Count the publishers from a subscription."""

<<<<<<< HEAD
=======
def set_on_new_message_callback(self, callback: Callable[[int], None]) -> None:
"""Set the on new message callback function for the subscription."""

def clear_on_new_message_callback(self) -> None:
"""Clear the on new message callback function for the subscription."""

def is_cft_enabled(self) -> bool:
"""Check if content filtering is enabled for this subscription."""

Expand All @@ -619,7 +611,6 @@ class Subscription(Destroyable, Generic[MsgT]):
def get_content_filter(self) -> ContentFilterOptions:
"""Get the filter expression and expression parameters for the subscription."""

>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))

class rcl_time_point_t:

Expand Down
37 changes: 0 additions & 37 deletions rclpy/rclpy/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@
from rclpy.service import Service
from rclpy.subscription import MessageInfo
from rclpy.subscription import Subscription
<<<<<<< HEAD
=======
from rclpy.subscription import SubscriptionCallbackUnion
from rclpy.subscription_content_filter_options import ContentFilterOptions
>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))
from rclpy.time_source import TimeSource
from rclpy.timer import Rate
from rclpy.timer import Timer, TimerInfo
Expand Down Expand Up @@ -1694,40 +1690,7 @@ def create_subscription(
self,
msg_type: Type[MsgT],
topic: str,
<<<<<<< HEAD
callback: Union[Callable[[MsgT], None], Callable[[MsgT, MessageInfo], None]],
=======
callback: GenericSubscriptionCallback[bytes],
qos_profile: Union[QoSProfile, int],
*,
callback_group: Optional[CallbackGroup] = None,
event_callbacks: Optional[SubscriptionEventCallbacks] = None,
qos_overriding_options: Optional[QoSOverridingOptions] = None,
raw: Literal[True],
content_filter_options: Optional[ContentFilterOptions] = None
) -> Subscription[MsgT]: ...

@overload
def create_subscription(
self,
msg_type: Type[MsgT],
topic: str,
callback: GenericSubscriptionCallback[MsgT],
qos_profile: Union[QoSProfile, int],
*,
callback_group: Optional[CallbackGroup] = None,
event_callbacks: Optional[SubscriptionEventCallbacks] = None,
qos_overriding_options: Optional[QoSOverridingOptions] = None,
raw: bool = False,
content_filter_options: Optional[ContentFilterOptions] = None
) -> Subscription[MsgT]: ...

def create_subscription(
self,
msg_type: Type[MsgT],
topic: str,
callback: SubscriptionCallbackUnion[MsgT],
>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))
qos_profile: Union[QoSProfile, int],
*,
callback_group: Optional[CallbackGroup] = None,
Expand Down
55 changes: 0 additions & 55 deletions rclpy/src/rclpy/subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@
#include <memory>
#include <stdexcept>
#include <string>
<<<<<<< HEAD
=======
#include <utility>
#include <vector>

#include <rcpputils/scope_exit.hpp>
>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))

#include "exceptions.hpp"
#include "node.hpp"
Expand All @@ -44,10 +40,6 @@ using pybind11::literals::operator""_a;

namespace rclpy
{
<<<<<<< HEAD
=======
using events_executor::RclEventCallbackTrampoline;

namespace
{
std::vector<const char *>
Expand All @@ -64,7 +56,6 @@ get_c_vector_string(const std::vector<std::string> & strings_in)
}
} // namespace

>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))
Subscription::Subscription(
Node & node, py::object pymsg_type, std::string topic,
py::object pyqos_profile, py::object content_filter_options)
Expand Down Expand Up @@ -242,43 +233,6 @@ Subscription::get_publisher_count() const
return count;
}

void
<<<<<<< HEAD
=======
Subscription::set_callback(
rcl_event_callback_t callback,
const void * user_data)
{
rcl_ret_t ret = rcl_subscription_set_on_new_message_callback(
rcl_subscription_.get(),
callback,
user_data);

if (RCL_RET_OK != ret) {
throw RCLError(std::string("Failed to set the on new message callback for subscription: ") +
rcl_get_error_string().str);
}
}

void
Subscription::set_on_new_message_callback(std::function<void(size_t)> callback)
{
clear_on_new_message_callback();
on_new_message_callback_ = std::move(callback);
set_callback(
RclEventCallbackTrampoline,
static_cast<const void *>(&on_new_message_callback_));
}

void
Subscription::clear_on_new_message_callback()
{
if (on_new_message_callback_) {
set_callback(nullptr, nullptr);
on_new_message_callback_ = nullptr;
}
}

bool
Subscription::is_cft_enabled() const
{
Expand Down Expand Up @@ -362,7 +316,6 @@ Subscription::get_content_filter() const
}

void
>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))
define_subscription(py::object module)
{
py::class_<Subscription, Destroyable, std::shared_ptr<Subscription>>(module, "Subscription")
Expand All @@ -388,14 +341,7 @@ define_subscription(py::object module)
"Return the resolved topic name of a subscription.")
.def(
"get_publisher_count", &Subscription::get_publisher_count,
<<<<<<< HEAD
"Count the publishers from a subscription.");
=======
"Count the publishers from a subscription.")
.def(
"set_on_new_message_callback", &Subscription::set_on_new_message_callback,
py::arg("callback"))
.def("clear_on_new_message_callback", &Subscription::clear_on_new_message_callback)
.def("is_cft_enabled", &Subscription::is_cft_enabled,
"Check if content filtering is enabled for this subscription.")
.def(
Expand All @@ -404,6 +350,5 @@ define_subscription(py::object module)
.def(
"get_content_filter", &Subscription::get_content_filter,
"Get the filter expression and expression parameters for the subscription.");
>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))
}
} // namespace rclpy
3 changes: 0 additions & 3 deletions rclpy/src/rclpy/subscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ class Subscription : public Destroyable, public std::enable_shared_from_this<Sub
void
destroy() override;

<<<<<<< HEAD
=======
void
set_on_new_message_callback(std::function<void(size_t)> callback);

Expand Down Expand Up @@ -139,7 +137,6 @@ class Subscription : public Destroyable, public std::enable_shared_from_this<Sub
py::object
get_content_filter() const;

>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))
private:
Node node_;
std::shared_ptr<rcl_subscription_t> rcl_subscription_;
Expand Down
22 changes: 1 addition & 21 deletions rclpy/test/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import time
from typing import List

import pytest

Expand Down Expand Up @@ -174,26 +175,6 @@ def test_subscription_publisher_count() -> None:
sub.destroy()

node.destroy_node()
<<<<<<< HEAD
=======


def test_on_new_message_callback(test_node) -> None:
topic_name = '/topic'
cb = Mock()
sub = test_node.create_subscription(
msg_type=Empty,
topic=topic_name,
qos_profile=10,
callback=cb)
pub = test_node.create_publisher(Empty, topic_name, 10)
sub.handle.set_on_new_message_callback(cb)
cb.assert_not_called()
pub.publish(Empty())
cb.assert_called_once_with(1)
sub.handle.clear_on_new_message_callback()
pub.publish(Empty())
cb.assert_called_once()


def test_subscription_set_content_filter(test_node) -> None:
Expand Down Expand Up @@ -469,4 +450,3 @@ def publish_messages(pub):

pub.destroy()
sub.destroy()
>>>>>>> 8d42eaa (Add content-filtered-topic interfaces (#1506))