-
Notifications
You must be signed in to change notification settings - Fork 227
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
Add SubscriptionOptions wrapper #1074
base: rolling
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2023 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy | ||
|
||
|
||
class SubscriptionOptions(_rclpy.rmw_subscription_options_t): | ||
pass | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,10 +46,11 @@ class Subscription : public Destroyable, public std::enable_shared_from_this<Sub | |
* \param[in] pymsg_type Message module associated with the subscriber | ||
* \param[in] topic The topic name | ||
* \param[in] pyqos_profile rmw_qos_profile_t object for this subscription | ||
* \param[in] pysubscription_options rmw_subscription_options_t object for this subscription | ||
*/ | ||
Subscription( | ||
Node & node, py::object pymsg_type, std::string topic, | ||
py::object pyqos_profile); | ||
py::object pyqos_profile, py::object pysubscription_options); | ||
|
||
/// Take a message and its metadata from a subscription | ||
/** | ||
|
@@ -100,7 +101,7 @@ class Subscription : public Destroyable, public std::enable_shared_from_this<Sub | |
Node node_; | ||
std::shared_ptr<rcl_subscription_t> rcl_subscription_; | ||
}; | ||
/// Define a pybind11 wrapper for an rclpy::Service | ||
/// Define a pybind11 wrapper for an rclpy::Subscription | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good eye 👍 |
||
void define_subscription(py::object module); | ||
} // namespace rclpy | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2023 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
#include <rmw/types.h> | ||
#include <rmw/subscription_options.h> | ||
|
||
#include "subscription_options.hpp" | ||
|
||
using pybind11::literals::operator""_a; | ||
|
||
namespace rclpy | ||
{ | ||
void | ||
define_subscription_options(py::object module) | ||
{ | ||
py::class_<rmw_subscription_options_t>(module, "rmw_subscription_options_t") | ||
.def(py::init<>(&rmw_get_default_subscription_options)) | ||
.def_readwrite( | ||
"ignore_local_publications", | ||
&rmw_subscription_options_t::ignore_local_publications); | ||
} | ||
} // namespace rclpy |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2023 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef RCLPY__SUBSCRIPTION_OPTIONS_HPP_ | ||
#define RCLPY__SUBSCRIPTION_OPTIONS_HPP_ | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace py = pybind11; | ||
|
||
namespace rclpy | ||
{ | ||
/// Define a pybind11 wrapper for an rclpy::SubscriptionOptions | ||
void define_subscription_options(py::object module); | ||
} // namespace rclpy | ||
|
||
#endif // RCLPY__SUBSCRIPTION_OPTIONS_HPP_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,12 @@ def __init__(self, node): | |
|
||
with node.handle: | ||
self.subscription = _rclpy.Subscription( | ||
node.handle, EmptyMsg, 'test_topic', QoSProfile(depth=10).get_c_qos_profile()) | ||
node.handle, | ||
EmptyMsg, | ||
'test_topic', | ||
QoSProfile(depth=10).get_c_qos_profile(), | ||
None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that we need to add more test cases here,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. I'll add a test case for this. |
||
) | ||
self.subscription_index = None | ||
self.subscription_is_ready = False | ||
|
||
|
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 was expecting that abstraction class such as
QoSProfile
with initialization, setter and getter accessors? so that it would be useful as python client library, and conceal implementation details with C/C++ language.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 was trying to keep the implementation more in line with the rclcpp interface, but can look at the changes this might require.