Skip to content

Commit 8525ee2

Browse files
alsoraclalancette
authored andcommitted
New Intra-Process Communication (#778)
* basic ipc implementation from alsora/new_ipc_proposal Signed-off-by: alberto <alberto.soragna@gmail.com> better use of node_topic create subscription Signed-off-by: alberto <alberto.soragna@gmail.com> added intra process manager test Signed-off-by: alberto <alberto.soragna@gmail.com> fixed ring buffer and added test Signed-off-by: alberto <alberto.soragna@gmail.com> added intra process buffer test Signed-off-by: alberto <alberto.soragna@gmail.com> added intra process buffer test Signed-off-by: alberto <alberto.soragna@gmail.com> Signed-off-by: alberto <alberto.soragna@gmail.com> removed intra-process methods from subscription base Signed-off-by: alberto <alberto.soragna@gmail.com> using lock_guard instead of unique_lock, renamed var without camel case Signed-off-by: alberto <alberto.soragna@gmail.com> using unordered set and references in intra process manager Signed-off-by: alberto <alberto.soragna@gmail.com> subscription intra-process does not depend anymore on subscription, but has a copy of the callback Signed-off-by: alberto <alberto.soragna@gmail.com> changed buffer API to use rvo Signed-off-by: Alberto <alberto.soragna@gmail.com> avoid copying shared_ptr Signed-off-by: alberto <alberto.soragna@gmail.com> revert not needed changes to create_subscription Signed-off-by: alberto <alberto.soragna@gmail.com> updated tests according to new buffer APIs Signed-off-by: alberto <alberto.soragna@gmail.com> updated types in ring buffer implementation avoid using uint32_t Signed-off-by: alberto <alberto.soragna@gmail.com> using unique ptr for buffers in subscription_intra_process Signed-off-by: alberto <alberto.soragna@gmail.com> added missing std::move in subscription_intra_process constructor Signed-off-by: alberto <alberto.soragna@gmail.com> use consisting names for ring_buffer_implementation members Signed-off-by: alberto <alberto.soragna@gmail.com> addressing typos, one-liners and similar from ivanpauno review Signed-off-by: alberto <alberto.soragna@gmail.com> moved subscription_intra_process_base to its own files and moved non templated method from derived class Signed-off-by: alberto <alberto.soragna@gmail.com> removed forward declarations, fixed include subscription_intra_process_base Signed-off-by: alberto <alberto.soragna@gmail.com> removed member variable from do_intra_process_publish signature Signed-off-by: alberto <alberto.soragna@gmail.com> declare public before private in intra_process_manager_impl Signed-off-by: alberto <alberto.soragna@gmail.com> made matches_any_intra_process_publishers const Signed-off-by: alberto <alberto.soragna@gmail.com> using const reference in get_all_matching_publishers Signed-off-by: alberto <alberto.soragna@gmail.com> added deleter and alloc templates in intra_process_buffer Signed-off-by: alberto <alberto.soragna@gmail.com> added RCLCPP_WARN to intra_process_manager_impl Signed-off-by: alberto <alberto.soragna@gmail.com> passing context from node to subscription_intra_process Signed-off-by: alberto <alberto.soragna@gmail.com> using allocators in intra_process_manager Signed-off-by: alberto <alberto.soragna@gmail.com> use size_t instead of int in ring buffer indices Signed-off-by: alberto <alberto.soragna@gmail.com> creating buffer inside subscription_intra_process constructor Signed-off-by: alberto <alberto.soragna@gmail.com> fix lint errors Signed-off-by: alberto <alberto.soragna@gmail.com> throw error if trying to dequeue when buffer empty; remove duplicated methods in intra_process_buffer Signed-off-by: alberto <alberto.soragna@gmail.com> added todo for creating an rmw function for checking qos compatibility Signed-off-by: alberto <alberto.soragna@gmail.com> test fixes Signed-off-by: alberto <alberto.soragna@gmail.com> refactored intra_process_manager, removed ipm impl Signed-off-by: alberto <alberto.soragna@gmail.com> added mutex in intra_process_manager add_* methods Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> added allocator to intra_process_buffer Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> added invalid intra_process qos test for subscription Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> throw error if history size is 0 with keep last and ipc Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> using allocator when creating unique_ptr from shared_ptr Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> adding deleter template argument to intra_process buffer Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> fix linter Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> throw error with callbackT different from messageT Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> updated deleter template argument in subscription factory Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> Fix typo in test fixture tear down method name (#787) Signed-off-by: Jacob Perron <jacob@openrobotics.org> Add free function for creating service clients (#788) Equivalent to the free function for creating a service. Resolves #768 Signed-off-by: Jacob Perron <jacob@openrobotics.org> Cmake infrastructure for creating components (#784) *cmake macro to create components for libraries with multiple nodes Signed-off-by: Siddharth Kucheria <kucheria@usc.edu> Allow registering multiple on_parameters_set_callback (#772) Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> fix for multiple nodes not being recognized (#790) Signed-off-by: Siddharth Kucheria <kucheria@usc.edu> Remove non-package from ament_target_dependencies() (#793) Signed-off-by: Shane Loretz <sloretz@osrfoundation.org> fix linter issue (#795) Signed-off-by: Siddharth Kucheria <kucheria@usc.edu> Make TimeSource ignore use_sim_time events coming from other nodes. (#799) Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> passing deleter template parameter Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> small fixes for failing tests Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> fixed imports in test_intra_process_manager Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> using RCLCPP_SMART_PTR_ALIASES_ONLY and RCLCPP_PUBLIC macros Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> added RCLCPP_PUBLIC macros and virtual destructor to sub intra_process base Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> added unique_ptr alias to macros Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> updated test_intra_process_manager.cpp Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> remove mock msgs from rclcpp (#800) Signed-off-by: Karsten Knese <karsten@openrobotics.org> Add line break after first open paren in multiline function call (#785) * Add line break after first open paren in multiline function call as per developer guide: https://index.ros.org/doc/ros2/Contributing/Developer-Guide/#open-versus-cuddled-braces see ament/ament_lint#148 Signed-off-by: Dan Rose <dan@digilabs.io> Fix dedent when first function argument starts with a brace Signed-off-by: Dan Rose <dan@digilabs.io> Line break with multiline if condition Remove line breaks where allowed. Signed-off-by: Dan Rose <dan@digilabs.io> Fixup after rebase Signed-off-by: Dan Rose <dan@digilabs.io> Fixup again after reverting indent_paren_open_brace Signed-off-by: Dan Rose <dan@digilabs.io> * Revert comment spacing change, condense some lines Signed-off-by: Dan Rose <dan@digilabs.io> Adapt to '--ros-args ... [--]'-based ROS args extraction (#816) * Use --ros-args to deal with node arguments in rclcpp. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Document implicit --ros-args flag in NodeOptions::arguments(). Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Add missing size_t to int cast. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Only add implicit --ros-args flag if not present already. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Add some rclcpp::NodeOptions test coverage. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Address peer review comments. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Please cpplint and uncrustify. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> Guard against making multiple result requests for a goal handle (#808) This fixes a runtime error caused by a race condition when making consecutive requests for the result. Specifically, this happens if the user provides a result callback when sending a goal and then calls async_get_result shortly after. Resolves #783 Signed-off-by: Jacob Perron <jacob@openrobotics.org> Explain return value of spin_until_future_complete (#792) Signed-off-by: Dan Rose <dan@digilabs.io> Allow passing logger by const ref (#820) Signed-off-by: Karsten Knese <karsten@openrobotics.org> Delete unnecessary call for get_node_by_group (#823) Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com> Fix get_node_interfaces functions taking a pointer (#821) Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> add callback group as member variable and constructor arg (#811) Signed-off-by: bpwilcox <bpwilcox@eng.ucsd.edu> remove callback group as member variable Wrap documentation examples in code blocks (#830) This makes the code examples easier to read in the generated documentation. Signed-off-by: Jacob Perron <jacob@openrobotics.org> Crash in callback group pointer vector iterator (#814) Signed-off-by: Guillaume Autran <gautran@clearpath.ai> add mutex in add/remove_node and wait_for_work to protect concurrent use/change of memory_strategy_ (#837) Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com> Fix hang with timers in MultiThreadedExecutor (#835) (#836) Signed-off-by: Todd Malsbary <todd.malsbary@intel.com> Use of -r/--remap flags where appropriate. (#834) Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> Force explicit --ros-args in NodeOptions::arguments(). (#845) Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> Fail on invalid and unknown ROS specific arguments (#842) * Fail on invalid and unknown ROS specific arguments. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Revert changes to utilities.hpp in rclcpp Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Fully revert change to utilities.hpp Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> Fix typo in deprecated warning. (#848) "it's" instead of its Signed-off-by: Luca Della Vedova <luca@openrobotics.org> Add throwing parameter name if parameter is not set (#833) * added throwing parameter name if parameter is not set Signed-off-by: Alex <cvbn127@gmail.com> Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com> check valid timer handler 1st to reduce the time window for scan. (#841) Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com> remove features and related code which were deprecated in dashing (#852) Signed-off-by: William Woodall <william@osrfoundation.org> reset error message before setting a new one, embed the original one (#854) Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com> restored virtual destructor in publisher_base Signed-off-by: Soragna, Alberto <alberto.soragna@gmail.com> * fixup a few things after rebase Signed-off-by: William Woodall <william@osrfoundation.org> * refactor some API's and get code compiling again Signed-off-by: William Woodall <william@osrfoundation.org> * docs and style changes (whitespace) Signed-off-by: William Woodall <william@osrfoundation.org> * move new intra process internals into experimental namespace Signed-off-by: William Woodall <william@osrfoundation.org> * uncrustify Signed-off-by: William Woodall <william@osrfoundation.org> * fix issues with LoanedMessages after rebase Signed-off-by: William Woodall <william@osrfoundation.org> * more fixups Signed-off-by: William Woodall <william@osrfoundation.org> * readd logic for avoiding in compatible QoS Signed-off-by: William Woodall <william@osrfoundation.org> * avoid an error when intra process is disabled Signed-off-by: William Woodall <william@osrfoundation.org> * change intra process to preserve pointer in cyclic_pipeline Signed-off-by: William Woodall <william@osrfoundation.org> * fix issue matching topics in intra process Signed-off-by: William Woodall <william@osrfoundation.org> * fix some issues with the tests after latest behavior change Signed-off-by: William Woodall <william@osrfoundation.org> * address review feedback Signed-off-by: William Woodall <william@osrfoundation.org> * fix the initialization order Signed-off-by: William Woodall <william@osrfoundation.org> * avoid possible loss of data warning Signed-off-by: William Woodall <william@osrfoundation.org> * more fixes related to initialization Signed-off-by: William Woodall <william@osrfoundation.org> * fix use of custom allocators Signed-off-by: William Woodall <william@osrfoundation.org>
1 parent 8fd9a0a commit 8525ee2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2601
-2636
lines changed

rclcpp/CMakeLists.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ set(${PROJECT_NAME}_SRCS
4747
src/rclcpp/graph_listener.cpp
4848
src/rclcpp/init_options.cpp
4949
src/rclcpp/intra_process_manager.cpp
50-
src/rclcpp/intra_process_manager_impl.cpp
5150
src/rclcpp/logger.cpp
5251
src/rclcpp/memory_strategies.cpp
5352
src/rclcpp/memory_strategy.cpp
@@ -75,6 +74,7 @@ set(${PROJECT_NAME}_SRCS
7574
src/rclcpp/service.cpp
7675
src/rclcpp/signal_handler.cpp
7776
src/rclcpp/subscription_base.cpp
77+
src/rclcpp/subscription_intra_process_base.cpp
7878
src/rclcpp/time.cpp
7979
src/rclcpp/time_source.cpp
8080
src/rclcpp/timer.cpp
@@ -200,25 +200,36 @@ if(BUILD_TESTING)
200200
"rosidl_typesupport_cpp"
201201
)
202202
endif()
203-
ament_add_gtest(test_mapped_ring_buffer test/test_mapped_ring_buffer.cpp)
204-
if(TARGET test_mapped_ring_buffer)
205-
ament_target_dependencies(test_mapped_ring_buffer
203+
ament_add_gmock(test_intra_process_manager test/test_intra_process_manager.cpp)
204+
if(TARGET test_intra_process_manager)
205+
ament_target_dependencies(test_intra_process_manager
206206
"rcl"
207207
"rcl_interfaces"
208208
"rmw"
209209
"rosidl_generator_cpp"
210210
"rosidl_typesupport_cpp"
211211
)
212+
target_link_libraries(test_intra_process_manager ${PROJECT_NAME})
212213
endif()
213-
ament_add_gtest(test_intra_process_manager test/test_intra_process_manager.cpp)
214-
if(TARGET test_intra_process_manager)
215-
ament_target_dependencies(test_intra_process_manager
216-
"rcl"
214+
ament_add_gtest(test_ring_buffer_implementation test/test_ring_buffer_implementation.cpp)
215+
if(TARGET test_ring_buffer_implementation)
216+
ament_target_dependencies(test_ring_buffer_implementation
217+
"rcl_interfaces"
218+
"rmw"
219+
"rosidl_generator_cpp"
220+
"rosidl_typesupport_cpp"
221+
)
222+
target_link_libraries(test_ring_buffer_implementation ${PROJECT_NAME})
223+
endif()
224+
ament_add_gtest(test_intra_process_buffer test/test_intra_process_buffer.cpp)
225+
if(TARGET test_intra_process_buffer)
226+
ament_target_dependencies(test_intra_process_buffer
217227
"rcl_interfaces"
218228
"rmw"
219229
"rosidl_generator_cpp"
220230
"rosidl_typesupport_cpp"
221231
)
232+
target_link_libraries(test_intra_process_buffer ${PROJECT_NAME})
222233
endif()
223234

224235
ament_add_gtest(test_loaned_message test/test_loaned_message.cpp)

rclcpp/include/rclcpp/any_executable.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct AnyExecutable
4242

4343
// Only one of the following pointers will be set.
4444
rclcpp::SubscriptionBase::SharedPtr subscription;
45-
rclcpp::SubscriptionBase::SharedPtr subscription_intra_process;
4645
rclcpp::TimerBase::SharedPtr timer;
4746
rclcpp::ServiceBase::SharedPtr service;
4847
rclcpp::ClientBase::SharedPtr client;

rclcpp/include/rclcpp/any_subscription_callback.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class AnySubscriptionCallback
227227
TRACEPOINT(callback_end, (const void *)this);
228228
}
229229

230-
bool use_take_shared_method()
230+
bool use_take_shared_method() const
231231
{
232232
return const_shared_ptr_callback_ || const_shared_ptr_with_info_callback_;
233233
}

rclcpp/include/rclcpp/create_subscription.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ create_subscription(
7272

7373
auto sub = node_topics->create_subscription(topic_name, factory, qos);
7474
node_topics->add_subscription(sub, options.callback_group);
75+
7576
return std::dynamic_pointer_cast<SubscriptionT>(sub);
7677
}
7778

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2019 Open Source Robotics Foundation, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef RCLCPP__DETAIL__RESOLVE_INTRA_PROCESS_BUFFER_TYPE_HPP_
16+
#define RCLCPP__DETAIL__RESOLVE_INTRA_PROCESS_BUFFER_TYPE_HPP_
17+
18+
#include <stdexcept>
19+
20+
#include "rclcpp/any_subscription_callback.hpp"
21+
#include "rclcpp/intra_process_buffer_type.hpp"
22+
23+
namespace rclcpp
24+
{
25+
26+
namespace detail
27+
{
28+
29+
/// Return the buffer type, resolving the "CallbackDefault" type to an actual type if needed.
30+
template<typename CallbackMessageT, typename AllocatorT>
31+
rclcpp::IntraProcessBufferType
32+
resolve_intra_process_buffer_type(
33+
const rclcpp::IntraProcessBufferType buffer_type,
34+
const rclcpp::AnySubscriptionCallback<CallbackMessageT, AllocatorT> & any_subscription_callback)
35+
{
36+
rclcpp::IntraProcessBufferType resolved_buffer_type = buffer_type;
37+
38+
// If the user has not specified a type for the intra-process buffer, use the callback's type.
39+
if (resolved_buffer_type == IntraProcessBufferType::CallbackDefault) {
40+
if (any_subscription_callback.use_take_shared_method()) {
41+
resolved_buffer_type = IntraProcessBufferType::SharedPtr;
42+
} else {
43+
resolved_buffer_type = IntraProcessBufferType::UniquePtr;
44+
}
45+
}
46+
47+
return resolved_buffer_type;
48+
}
49+
50+
} // namespace detail
51+
52+
} // namespace rclcpp
53+
54+
#endif // RCLCPP__DETAIL__RESOLVE_INTRA_PROCESS_BUFFER_TYPE_HPP_

rclcpp/include/rclcpp/detail/resolve_use_intra_process.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace rclcpp
2525
namespace detail
2626
{
2727

28+
/// Return whether or not intra process is enabled, resolving "NodeDefault" if needed.
2829
template<typename OptionsT, typename NodeBaseT>
2930
bool
3031
resolve_use_intra_process(const OptionsT & options, const NodeBaseT & node_base)

rclcpp/include/rclcpp/executor.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,6 @@ class Executor
305305
execute_subscription(
306306
rclcpp::SubscriptionBase::SharedPtr subscription);
307307

308-
RCLCPP_PUBLIC
309-
static void
310-
execute_intra_process_subscription(
311-
rclcpp::SubscriptionBase::SharedPtr subscription);
312-
313308
RCLCPP_PUBLIC
314309
static void
315310
execute_timer(rclcpp::TimerBase::SharedPtr timer);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Notice that headers in this folder should only provide symbols in the rclcpp::experimental namespace.
2+
3+
Also notice that these headers are not considered part of the public API as they have not yet been stabilized.
4+
And therefore they are subject to change without notice.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2019 Open Source Robotics Foundation, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef RCLCPP__EXPERIMENTAL__BUFFERS__BUFFER_IMPLEMENTATION_BASE_HPP_
16+
#define RCLCPP__EXPERIMENTAL__BUFFERS__BUFFER_IMPLEMENTATION_BASE_HPP_
17+
18+
namespace rclcpp
19+
{
20+
namespace experimental
21+
{
22+
namespace buffers
23+
{
24+
25+
template<typename BufferT>
26+
class BufferImplementationBase
27+
{
28+
public:
29+
virtual ~BufferImplementationBase() {}
30+
31+
virtual BufferT dequeue() = 0;
32+
virtual void enqueue(BufferT request) = 0;
33+
34+
virtual void clear() = 0;
35+
virtual bool has_data() const = 0;
36+
};
37+
38+
} // namespace buffers
39+
} // namespace experimental
40+
} // namespace rclcpp
41+
42+
#endif // RCLCPP__EXPERIMENTAL__BUFFERS__BUFFER_IMPLEMENTATION_BASE_HPP_

0 commit comments

Comments
 (0)