Compare commits
13 Commits
30.1.5
...
native_buf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b4d3d01c6 | ||
|
|
b6e9b4c9b4 | ||
|
|
8cd4d47ec5 | ||
|
|
f145c9ee04 | ||
|
|
dea57660b5 | ||
|
|
aea98d665a | ||
|
|
87be5fbfd4 | ||
|
|
1bf4e6a810 | ||
|
|
fc1afcb3bc | ||
|
|
b6730f9d4e | ||
|
|
9f79f40621 | ||
|
|
6ff4d83498 | ||
|
|
4d950baa15 |
@@ -27,10 +27,39 @@ namespace rclcpp
|
||||
namespace allocator
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
using clean_t = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
|
||||
// Primary template: false
|
||||
template<typename, typename = std::void_t<>>
|
||||
struct has_get_rcl_allocator : std::false_type {};
|
||||
|
||||
// Specialization: true if expression is valid
|
||||
template<typename T>
|
||||
struct has_get_rcl_allocator<T,
|
||||
std::void_t<
|
||||
decltype(std::declval<clean_t<T> &>().get_rcl_allocator())
|
||||
>
|
||||
>
|
||||
: std::bool_constant<
|
||||
std::is_same_v<
|
||||
decltype(std::declval<clean_t<T> &>().get_rcl_allocator()),
|
||||
rcl_allocator_t
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
// Helper variable template
|
||||
template<typename T>
|
||||
inline constexpr bool has_get_rcl_allocator_v =
|
||||
has_get_rcl_allocator<T>::value;
|
||||
|
||||
template<typename T, typename Alloc>
|
||||
using AllocRebind = typename std::allocator_traits<Alloc>::template rebind_traits<T>;
|
||||
|
||||
template<typename Alloc>
|
||||
[[deprecated("Conversion of C++ allocators to C style is not valid, as the size on deallocate"
|
||||
"can not be determined. This will be remove in future versions of ros.")]]
|
||||
void * retyped_allocate(size_t size, void * untyped_allocator)
|
||||
{
|
||||
auto typed_allocator = static_cast<Alloc *>(untyped_allocator);
|
||||
@@ -41,6 +70,8 @@ void * retyped_allocate(size_t size, void * untyped_allocator)
|
||||
}
|
||||
|
||||
template<typename Alloc>
|
||||
[[deprecated("Conversion of C++ allocators to C style is not valid, as the size on deallocate"
|
||||
"can not be determined. This will be remove in future versions of ros.")]]
|
||||
void * retyped_zero_allocate(size_t number_of_elem, size_t size_of_elem, void * untyped_allocator)
|
||||
{
|
||||
auto typed_allocator = static_cast<Alloc *>(untyped_allocator);
|
||||
@@ -57,6 +88,8 @@ void * retyped_zero_allocate(size_t number_of_elem, size_t size_of_elem, void *
|
||||
}
|
||||
|
||||
template<typename T, typename Alloc>
|
||||
[[deprecated("Conversion of C++ allocators to C style is not valid, as the size on deallocate"
|
||||
"can not be determined. This will be remove in future versions of ros.")]]
|
||||
void retyped_deallocate(void * untyped_pointer, void * untyped_allocator)
|
||||
{
|
||||
auto typed_allocator = static_cast<Alloc *>(untyped_allocator);
|
||||
@@ -68,6 +101,8 @@ void retyped_deallocate(void * untyped_pointer, void * untyped_allocator)
|
||||
}
|
||||
|
||||
template<typename T, typename Alloc>
|
||||
[[deprecated("Conversion of C++ allocators to C style is not valid, as the size on deallocate"
|
||||
"can not be determined. This will be remove in future versions of ros.")]]
|
||||
void * retyped_reallocate(void * untyped_pointer, size_t size, void * untyped_allocator)
|
||||
{
|
||||
auto typed_allocator = static_cast<Alloc *>(untyped_allocator);
|
||||
@@ -85,6 +120,9 @@ template<
|
||||
typename T,
|
||||
typename Alloc,
|
||||
typename std::enable_if<!std::is_same<Alloc, std::allocator<void>>::value>::type * = nullptr>
|
||||
[[deprecated("Conversion of C++ allocators to C style is not valid, as the size on deallocate"
|
||||
"can not be determined. This will be remove in future versions of ros. To suppress this warning"
|
||||
"define the method 'rcl_allocator_t get_rcl_allocator()' on your allocator")]]
|
||||
rcl_allocator_t get_rcl_allocator(Alloc & allocator)
|
||||
{
|
||||
rcl_allocator_t rcl_allocator = rcl_get_default_allocator();
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
explicit CallbackGroup(
|
||||
CallbackGroupType group_type,
|
||||
rclcpp::Context::WeakPtr context,
|
||||
const rclcpp::Context::WeakPtr & context,
|
||||
bool automatically_add_to_executor_with_node = true);
|
||||
|
||||
/// Default destructor.
|
||||
@@ -106,35 +106,35 @@ public:
|
||||
|
||||
template<typename Function>
|
||||
rclcpp::SubscriptionBase::SharedPtr
|
||||
find_subscription_ptrs_if(Function func) const
|
||||
find_subscription_ptrs_if(const Function & func) const
|
||||
{
|
||||
return _find_ptrs_if_impl<rclcpp::SubscriptionBase, Function>(func, subscription_ptrs_);
|
||||
}
|
||||
|
||||
template<typename Function>
|
||||
rclcpp::TimerBase::SharedPtr
|
||||
find_timer_ptrs_if(Function func) const
|
||||
find_timer_ptrs_if(const Function & func) const
|
||||
{
|
||||
return _find_ptrs_if_impl<rclcpp::TimerBase, Function>(func, timer_ptrs_);
|
||||
}
|
||||
|
||||
template<typename Function>
|
||||
rclcpp::ServiceBase::SharedPtr
|
||||
find_service_ptrs_if(Function func) const
|
||||
find_service_ptrs_if(const Function & func) const
|
||||
{
|
||||
return _find_ptrs_if_impl<rclcpp::ServiceBase, Function>(func, service_ptrs_);
|
||||
}
|
||||
|
||||
template<typename Function>
|
||||
rclcpp::ClientBase::SharedPtr
|
||||
find_client_ptrs_if(Function func) const
|
||||
find_client_ptrs_if(const Function & func) const
|
||||
{
|
||||
return _find_ptrs_if_impl<rclcpp::ClientBase, Function>(func, client_ptrs_);
|
||||
}
|
||||
|
||||
template<typename Function>
|
||||
rclcpp::Waitable::SharedPtr
|
||||
find_waitable_ptrs_if(Function func) const
|
||||
find_waitable_ptrs_if(const Function & func) const
|
||||
{
|
||||
return _find_ptrs_if_impl<rclcpp::Waitable, Function>(func, waitable_ptrs_);
|
||||
}
|
||||
@@ -179,11 +179,11 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
collect_all_ptrs(
|
||||
std::function<void(const rclcpp::SubscriptionBase::SharedPtr &)> sub_func,
|
||||
std::function<void(const rclcpp::ServiceBase::SharedPtr &)> service_func,
|
||||
std::function<void(const rclcpp::ClientBase::SharedPtr &)> client_func,
|
||||
std::function<void(const rclcpp::TimerBase::SharedPtr &)> timer_func,
|
||||
std::function<void(const rclcpp::Waitable::SharedPtr &)> waitable_func) const;
|
||||
const std::function<void(const rclcpp::SubscriptionBase::SharedPtr &)> & sub_func,
|
||||
const std::function<void(const rclcpp::ServiceBase::SharedPtr &)> & service_func,
|
||||
const std::function<void(const rclcpp::ClientBase::SharedPtr &)> & client_func,
|
||||
const std::function<void(const rclcpp::TimerBase::SharedPtr &)> & timer_func,
|
||||
const std::function<void(const rclcpp::Waitable::SharedPtr &)> & waitable_func) const;
|
||||
|
||||
/// Return a reference to the 'associated with executor' atomic boolean.
|
||||
/**
|
||||
@@ -228,31 +228,31 @@ protected:
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_publisher(const rclcpp::PublisherBase::SharedPtr publisher_ptr);
|
||||
add_publisher(const rclcpp::PublisherBase::SharedPtr & publisher_ptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_subscription(const rclcpp::SubscriptionBase::SharedPtr subscription_ptr);
|
||||
add_subscription(const rclcpp::SubscriptionBase::SharedPtr & subscription_ptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_timer(const rclcpp::TimerBase::SharedPtr timer_ptr);
|
||||
add_timer(const rclcpp::TimerBase::SharedPtr & timer_ptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_service(const rclcpp::ServiceBase::SharedPtr service_ptr);
|
||||
add_service(const rclcpp::ServiceBase::SharedPtr & service_ptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_client(const rclcpp::ClientBase::SharedPtr client_ptr);
|
||||
add_client(const rclcpp::ClientBase::SharedPtr & client_ptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_waitable(const rclcpp::Waitable::SharedPtr waitable_ptr);
|
||||
add_waitable(const rclcpp::Waitable::SharedPtr & waitable_ptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
remove_waitable(const rclcpp::Waitable::SharedPtr waitable_ptr) noexcept;
|
||||
remove_waitable(const rclcpp::Waitable::SharedPtr & waitable_ptr) noexcept;
|
||||
|
||||
CallbackGroupType type_;
|
||||
// Mutex to protect the subsequent vectors of pointers.
|
||||
@@ -274,7 +274,7 @@ protected:
|
||||
private:
|
||||
template<typename TypeT, typename Function>
|
||||
typename TypeT::SharedPtr _find_ptrs_if_impl(
|
||||
Function func, const std::vector<typename TypeT::WeakPtr> & vect_ptrs) const
|
||||
const Function & func, const std::vector<typename TypeT::WeakPtr> & vect_ptrs) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
for (auto & weak_ptr : vect_ptrs) {
|
||||
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
ClientBase(
|
||||
rclcpp::node_interfaces::NodeBaseInterface * node_base,
|
||||
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph);
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr & node_graph);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
virtual ~ClientBase() = default;
|
||||
@@ -221,7 +221,8 @@ public:
|
||||
virtual std::shared_ptr<void> create_response() = 0;
|
||||
virtual std::shared_ptr<rmw_request_id_t> create_request_header() = 0;
|
||||
virtual void handle_response(
|
||||
std::shared_ptr<rmw_request_id_t> request_header, std::shared_ptr<void> response) = 0;
|
||||
const std::shared_ptr<rmw_request_id_t> & request_header,
|
||||
const std::shared_ptr<void> & response) = 0;
|
||||
|
||||
/// Exchange the "in use by wait set" state for this client.
|
||||
/**
|
||||
@@ -296,7 +297,7 @@ public:
|
||||
* \param[in] callback functor to be called when a new response is received
|
||||
*/
|
||||
void
|
||||
set_on_new_response_callback(std::function<void(size_t)> callback)
|
||||
set_on_new_response_callback(const std::function<void(size_t)> & callback)
|
||||
{
|
||||
if (!callback) {
|
||||
throw std::invalid_argument(
|
||||
@@ -477,7 +478,7 @@ public:
|
||||
*/
|
||||
Client(
|
||||
rclcpp::node_interfaces::NodeBaseInterface * node_base,
|
||||
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr & node_graph,
|
||||
const std::string & service_name,
|
||||
rcl_client_options_t & client_options)
|
||||
: ClientBase(node_base, node_graph),
|
||||
@@ -556,8 +557,8 @@ public:
|
||||
*/
|
||||
void
|
||||
handle_response(
|
||||
std::shared_ptr<rmw_request_id_t> request_header,
|
||||
std::shared_ptr<void> response) override
|
||||
const std::shared_ptr<rmw_request_id_t> & request_header,
|
||||
const std::shared_ptr<void> & response) override
|
||||
{
|
||||
std::optional<CallbackInfoVariant>
|
||||
optional_pending_request = this->get_and_erase_pending_request(request_header->sequence_number);
|
||||
@@ -566,7 +567,7 @@ public:
|
||||
}
|
||||
auto & value = *optional_pending_request;
|
||||
auto typed_response = std::static_pointer_cast<typename ServiceT::Response>(
|
||||
std::move(response));
|
||||
response);
|
||||
if (std::holds_alternative<Promise>(value)) {
|
||||
auto & promise = std::get<Promise>(value);
|
||||
promise.set_value(std::move(typed_response));
|
||||
@@ -617,7 +618,7 @@ public:
|
||||
* \return a FutureAndRequestId instance.
|
||||
*/
|
||||
FutureAndRequestId
|
||||
async_send_request(SharedRequest request)
|
||||
async_send_request(const SharedRequest & request)
|
||||
{
|
||||
Promise promise;
|
||||
auto future = promise.get_future();
|
||||
@@ -652,7 +653,7 @@ public:
|
||||
>::type * = nullptr
|
||||
>
|
||||
SharedFutureAndRequestId
|
||||
async_send_request(SharedRequest request, CallbackT && cb)
|
||||
async_send_request(const SharedRequest & request, CallbackT && cb)
|
||||
{
|
||||
Promise promise;
|
||||
auto shared_future = promise.get_future().share();
|
||||
@@ -683,7 +684,7 @@ public:
|
||||
>::type * = nullptr
|
||||
>
|
||||
SharedFutureWithRequestAndRequestId
|
||||
async_send_request(SharedRequest request, CallbackT && cb)
|
||||
async_send_request(const SharedRequest & request, CallbackT && cb)
|
||||
{
|
||||
PromiseWithRequest promise;
|
||||
auto shared_future = promise.get_future().share();
|
||||
@@ -795,7 +796,7 @@ public:
|
||||
*/
|
||||
void
|
||||
configure_introspection(
|
||||
Clock::SharedPtr clock, const QoS & qos_service_event_pub,
|
||||
const Clock::SharedPtr & clock, const QoS & qos_service_event_pub,
|
||||
rcl_service_introspection_state_t introspection_state)
|
||||
{
|
||||
rcl_publisher_options_t pub_opts = rcl_publisher_get_default_options();
|
||||
|
||||
@@ -117,8 +117,8 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
bool
|
||||
sleep_until(
|
||||
Time until,
|
||||
Context::SharedPtr context = contexts::get_global_default_context());
|
||||
const Time & until,
|
||||
const Context::SharedPtr & context = contexts::get_global_default_context());
|
||||
|
||||
/**
|
||||
* Sleep for a specified Duration.
|
||||
@@ -141,8 +141,8 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
bool
|
||||
sleep_for(
|
||||
Duration rel_time,
|
||||
Context::SharedPtr context = contexts::get_global_default_context());
|
||||
const Duration & rel_time,
|
||||
const Context::SharedPtr & context = contexts::get_global_default_context());
|
||||
|
||||
/**
|
||||
* Check if the clock is started.
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
bool
|
||||
wait_until_started(Context::SharedPtr context = contexts::get_global_default_context());
|
||||
wait_until_started(const Context::SharedPtr & context = contexts::get_global_default_context());
|
||||
|
||||
/**
|
||||
* Wait for clock to start, with timeout.
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
bool
|
||||
wait_until_started(
|
||||
const rclcpp::Duration & timeout,
|
||||
Context::SharedPtr context = contexts::get_global_default_context(),
|
||||
const Context::SharedPtr & context = contexts::get_global_default_context(),
|
||||
const rclcpp::Duration & wait_tick_ns = rclcpp::Duration(0, static_cast<uint32_t>(1e7)));
|
||||
|
||||
/**
|
||||
@@ -238,8 +238,8 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
JumpHandler::SharedPtr
|
||||
create_jump_callback(
|
||||
JumpHandler::pre_callback_t pre_callback,
|
||||
JumpHandler::post_callback_t post_callback,
|
||||
const JumpHandler::pre_callback_t & pre_callback,
|
||||
const JumpHandler::post_callback_t & post_callback,
|
||||
const rcl_jump_threshold_t & threshold);
|
||||
|
||||
private:
|
||||
@@ -327,7 +327,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
ClockConditionalVariable(
|
||||
const rclcpp::Clock::SharedPtr & clock,
|
||||
rclcpp::Context::SharedPtr context = rclcpp::contexts::get_global_default_context());
|
||||
const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context());
|
||||
RCLCPP_PUBLIC
|
||||
~ClockConditionalVariable();
|
||||
|
||||
@@ -347,7 +347,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
bool
|
||||
wait_until(
|
||||
std::unique_lock<std::mutex> & lock, rclcpp::Time until,
|
||||
std::unique_lock<std::mutex> & lock, const rclcpp::Time & until,
|
||||
const std::function<bool ()> & pred);
|
||||
|
||||
/**
|
||||
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
virtual
|
||||
OnShutdownCallback
|
||||
on_shutdown(OnShutdownCallback callback);
|
||||
on_shutdown(const OnShutdownCallback & callback);
|
||||
|
||||
/// Add a on_shutdown callback to be called when shutdown is called for this context.
|
||||
/**
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
virtual
|
||||
OnShutdownCallbackHandle
|
||||
add_on_shutdown_callback(OnShutdownCallback callback);
|
||||
add_on_shutdown_callback(const OnShutdownCallback & callback);
|
||||
|
||||
/// Remove an registered on_shutdown callbacks.
|
||||
/**
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
virtual
|
||||
PreShutdownCallbackHandle
|
||||
add_pre_shutdown_callback(PreShutdownCallback callback);
|
||||
add_pre_shutdown_callback(const PreShutdownCallback & callback);
|
||||
|
||||
/// Remove an registered pre_shutdown callback.
|
||||
/**
|
||||
@@ -417,7 +417,7 @@ private:
|
||||
RCLCPP_LOCAL
|
||||
ShutdownCallbackHandle
|
||||
add_shutdown_callback(
|
||||
ShutdownCallback callback);
|
||||
const ShutdownCallback & callback);
|
||||
|
||||
template<ShutdownType shutdown_type>
|
||||
RCLCPP_LOCAL
|
||||
|
||||
@@ -46,13 +46,13 @@ namespace rclcpp
|
||||
RCLCPP_PUBLIC
|
||||
rclcpp::GenericClient::SharedPtr
|
||||
create_generic_client(
|
||||
std::shared_ptr<node_interfaces::NodeBaseInterface> node_base,
|
||||
std::shared_ptr<node_interfaces::NodeGraphInterface> node_graph,
|
||||
std::shared_ptr<node_interfaces::NodeServicesInterface> node_services,
|
||||
const std::shared_ptr<node_interfaces::NodeBaseInterface> & node_base,
|
||||
const std::shared_ptr<node_interfaces::NodeGraphInterface> & node_graph,
|
||||
const std::shared_ptr<node_interfaces::NodeServicesInterface> & node_services,
|
||||
const std::string & service_name,
|
||||
const std::string & service_type,
|
||||
const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr);
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = rclcpp::CallbackGroup::SharedPtr());
|
||||
|
||||
/// Create a generic service client with a name of given type.
|
||||
/**
|
||||
|
||||
@@ -102,8 +102,8 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
add_callback_group(
|
||||
rclcpp::CallbackGroup::SharedPtr group_ptr,
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
|
||||
const rclcpp::CallbackGroup::SharedPtr & group_ptr,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
bool notify = true);
|
||||
|
||||
/// Get callback groups that belong to executor.
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
remove_callback_group(
|
||||
rclcpp::CallbackGroup::SharedPtr group_ptr,
|
||||
const rclcpp::CallbackGroup::SharedPtr & group_ptr,
|
||||
bool notify = true);
|
||||
|
||||
/// Add a node to the executor.
|
||||
@@ -197,7 +197,9 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify = true);
|
||||
add_node(
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
bool notify = true);
|
||||
|
||||
/// Convenience function which takes Node and forwards NodeBaseInterface.
|
||||
/**
|
||||
@@ -205,7 +207,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
add_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true);
|
||||
add_node(const std::shared_ptr<rclcpp::Node> & node_ptr, bool notify = true);
|
||||
|
||||
/// Remove a node from the executor.
|
||||
/**
|
||||
@@ -225,7 +227,9 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify = true);
|
||||
remove_node(
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
bool notify = true);
|
||||
|
||||
/// Convenience function which takes Node and forwards NodeBaseInterface.
|
||||
/**
|
||||
@@ -233,7 +237,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
remove_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true);
|
||||
remove_node(const std::shared_ptr<rclcpp::Node> & node_ptr, bool notify = true);
|
||||
|
||||
/// Add a node to executor, execute the next available unit of work, and remove the node.
|
||||
/**
|
||||
@@ -245,7 +249,7 @@ public:
|
||||
template<typename RepT = int64_t, typename T = std::milli>
|
||||
void
|
||||
spin_node_once(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node,
|
||||
std::chrono::duration<RepT, T> timeout = std::chrono::duration<RepT, T>(-1))
|
||||
{
|
||||
return spin_node_once_nanoseconds(
|
||||
@@ -258,7 +262,7 @@ public:
|
||||
template<typename NodeT = rclcpp::Node, typename RepT = int64_t, typename T = std::milli>
|
||||
void
|
||||
spin_node_once(
|
||||
std::shared_ptr<NodeT> node,
|
||||
const std::shared_ptr<NodeT> & node,
|
||||
std::chrono::duration<RepT, T> timeout = std::chrono::duration<RepT, T>(-1))
|
||||
{
|
||||
return spin_node_once_nanoseconds(
|
||||
@@ -273,12 +277,12 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node);
|
||||
spin_node_some(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node);
|
||||
|
||||
/// Convenience function which takes Node and forwards NodeBaseInterface.
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
spin_node_some(std::shared_ptr<rclcpp::Node> node);
|
||||
spin_node_some(const std::shared_ptr<rclcpp::Node> & node);
|
||||
|
||||
/// Collect work once and execute all available work, optionally within a max duration.
|
||||
/**
|
||||
@@ -321,13 +325,13 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
spin_node_all(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node,
|
||||
std::chrono::nanoseconds max_duration);
|
||||
|
||||
/// Convenience function which takes Node and forwards NodeBaseInterface.
|
||||
RCLCPP_PUBLIC
|
||||
virtual void
|
||||
spin_node_all(std::shared_ptr<rclcpp::Node> node, std::chrono::nanoseconds max_duration);
|
||||
spin_node_all(const std::shared_ptr<rclcpp::Node> & node, std::chrono::nanoseconds max_duration);
|
||||
|
||||
/// Collect and execute work repeatedly within a duration or until no more work is available.
|
||||
/**
|
||||
@@ -427,7 +431,7 @@ protected:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
spin_node_once_nanoseconds(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node,
|
||||
std::chrono::nanoseconds timeout);
|
||||
|
||||
/// Spin (blocking) until the future is complete, it times out waiting, or rclcpp is interrupted.
|
||||
@@ -478,7 +482,7 @@ protected:
|
||||
RCLCPP_PUBLIC
|
||||
static void
|
||||
execute_subscription(
|
||||
rclcpp::SubscriptionBase::SharedPtr subscription);
|
||||
const rclcpp::SubscriptionBase::SharedPtr & subscription);
|
||||
|
||||
/// Run timer executable.
|
||||
/**
|
||||
@@ -487,7 +491,7 @@ protected:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
static void
|
||||
execute_timer(rclcpp::TimerBase::SharedPtr timer, const std::shared_ptr<void> & data_ptr);
|
||||
execute_timer(const rclcpp::TimerBase::SharedPtr & timer, const std::shared_ptr<void> & data_ptr);
|
||||
|
||||
/// Run service server executable.
|
||||
/**
|
||||
@@ -496,7 +500,7 @@ protected:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
static void
|
||||
execute_service(rclcpp::ServiceBase::SharedPtr service);
|
||||
execute_service(const rclcpp::ServiceBase::SharedPtr & service);
|
||||
|
||||
/// Run service client executable.
|
||||
/**
|
||||
@@ -505,7 +509,7 @@ protected:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
static void
|
||||
execute_client(rclcpp::ClientBase::SharedPtr client);
|
||||
execute_client(const rclcpp::ClientBase::SharedPtr & client);
|
||||
|
||||
/// Gather all of the waitable entities from associated nodes and callback groups.
|
||||
RCLCPP_PUBLIC
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace rclcpp
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
spin_all(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
std::chrono::nanoseconds max_duration);
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ spin_all(
|
||||
[[deprecated("use SingleThreadedExecutor::spin_all instead")]]
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
spin_all(rclcpp::Node::SharedPtr node_ptr, std::chrono::nanoseconds max_duration);
|
||||
spin_all(const rclcpp::Node::SharedPtr & node_ptr, std::chrono::nanoseconds max_duration);
|
||||
|
||||
/**
|
||||
* @brief Create a default single-threaded executor and execute any immediately available work.
|
||||
@@ -87,7 +87,7 @@ spin_all(rclcpp::Node::SharedPtr node_ptr, std::chrono::nanoseconds max_duration
|
||||
[[deprecated("use SingleThreadedExecutor::spin_some instead")]]
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
spin_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
|
||||
spin_some(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr);
|
||||
|
||||
/**
|
||||
* @brief Create a default single-threaded executor and execute any immediately available work.
|
||||
@@ -106,17 +106,17 @@ spin_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
|
||||
[[deprecated("use SingleThreadedExecutor::spin_some instead")]]
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
spin_some(rclcpp::Node::SharedPtr node_ptr);
|
||||
spin_some(const rclcpp::Node::SharedPtr & node_ptr);
|
||||
|
||||
/// Create a default single-threaded executor and spin the specified node.
|
||||
/** \param[in] node_ptr Shared pointer to the node to spin. */
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
spin(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
|
||||
spin(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
spin(rclcpp::Node::SharedPtr node_ptr);
|
||||
spin(const rclcpp::Node::SharedPtr & node_ptr);
|
||||
|
||||
namespace executors
|
||||
{
|
||||
@@ -140,7 +140,7 @@ template<typename FutureT, typename TimeRepT = int64_t, typename TimeT = std::mi
|
||||
rclcpp::FutureReturnCode
|
||||
spin_node_until_future_complete(
|
||||
rclcpp::Executor & executor,
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
const FutureT & future,
|
||||
std::chrono::duration<TimeRepT, TimeT> timeout = std::chrono::duration<TimeRepT, TimeT>(-1))
|
||||
{
|
||||
@@ -157,7 +157,7 @@ template<typename NodeT = rclcpp::Node, typename FutureT, typename TimeRepT = in
|
||||
rclcpp::FutureReturnCode
|
||||
spin_node_until_future_complete(
|
||||
rclcpp::Executor & executor,
|
||||
std::shared_ptr<NodeT> node_ptr,
|
||||
const std::shared_ptr<NodeT> & node_ptr,
|
||||
const FutureT & future,
|
||||
std::chrono::duration<TimeRepT, TimeT> timeout = std::chrono::duration<TimeRepT, TimeT>(-1))
|
||||
{
|
||||
@@ -173,7 +173,7 @@ spin_node_until_future_complete(
|
||||
template<typename FutureT, typename TimeRepT = int64_t, typename TimeT = std::milli>
|
||||
rclcpp::FutureReturnCode
|
||||
spin_until_future_complete(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
const FutureT & future,
|
||||
std::chrono::duration<TimeRepT, TimeT> timeout = std::chrono::duration<TimeRepT, TimeT>(-1))
|
||||
{
|
||||
@@ -187,7 +187,7 @@ template<typename NodeT = rclcpp::Node, typename FutureT, typename TimeRepT = in
|
||||
typename TimeT = std::milli>
|
||||
rclcpp::FutureReturnCode
|
||||
spin_until_future_complete(
|
||||
std::shared_ptr<NodeT> node_ptr,
|
||||
const std::shared_ptr<NodeT> & node_ptr,
|
||||
const FutureT & future,
|
||||
std::chrono::duration<TimeRepT, TimeT> timeout = std::chrono::duration<TimeRepT, TimeT>(-1))
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
explicit ExecutorEntitiesCollector(
|
||||
std::shared_ptr<ExecutorNotifyWaitable> notify_waitable);
|
||||
const std::shared_ptr<ExecutorNotifyWaitable> & notify_waitable);
|
||||
|
||||
/// Destructor
|
||||
RCLCPP_PUBLIC
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
|
||||
add_node(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr);
|
||||
|
||||
/// Remove a node from the entity collector
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
|
||||
remove_node(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr);
|
||||
|
||||
/// Add a callback group to the entity collector
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr);
|
||||
add_callback_group(const rclcpp::CallbackGroup::SharedPtr & group_ptr);
|
||||
|
||||
/// Remove a callback group from the entity collector
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
remove_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr);
|
||||
remove_callback_group(const rclcpp::CallbackGroup::SharedPtr & group_ptr);
|
||||
|
||||
/// Get all callback groups known to this entity collector
|
||||
/**
|
||||
@@ -211,7 +211,7 @@ protected:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_callback_group_to_collection(
|
||||
rclcpp::CallbackGroup::SharedPtr group_ptr,
|
||||
const rclcpp::CallbackGroup::SharedPtr & group_ptr,
|
||||
CallbackGroupCollection & collection) RCPPUTILS_TSA_REQUIRES(mutex_);
|
||||
|
||||
/// Iterate over queued added/remove nodes and callback_groups
|
||||
|
||||
@@ -43,7 +43,8 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
explicit ExecutorNotifyWaitable(
|
||||
std::function<void(void)> on_execute_callback = {}, const rclcpp::Context::SharedPtr & context =
|
||||
const std::function<void(void)> & on_execute_callback = {},
|
||||
const rclcpp::Context::SharedPtr & context =
|
||||
rclcpp::contexts::get_global_default_context());
|
||||
|
||||
// Destructor
|
||||
@@ -115,7 +116,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
add_guard_condition(rclcpp::GuardCondition::WeakPtr guard_condition);
|
||||
add_guard_condition(const rclcpp::GuardCondition::WeakPtr & guard_condition);
|
||||
|
||||
/// Unset any callback registered via set_on_ready_callback.
|
||||
/**
|
||||
@@ -139,7 +140,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
remove_guard_condition(rclcpp::GuardCondition::WeakPtr weak_guard_condition);
|
||||
remove_guard_condition(const rclcpp::GuardCondition::WeakPtr & weak_guard_condition);
|
||||
|
||||
/// Get the number of ready guard_conditions
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <shared_mutex>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
@@ -118,7 +119,8 @@ public:
|
||||
typename Alloc = std::allocator<ROSMessageType>
|
||||
>
|
||||
uint64_t
|
||||
add_subscription(rclcpp::experimental::SubscriptionIntraProcessBase::SharedPtr subscription)
|
||||
add_subscription(
|
||||
const rclcpp::experimental::SubscriptionIntraProcessBase::SharedPtr & subscription)
|
||||
{
|
||||
std::unique_lock<std::shared_timed_mutex> lock(mutex_);
|
||||
|
||||
@@ -175,8 +177,8 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
uint64_t
|
||||
add_publisher(
|
||||
rclcpp::PublisherBase::SharedPtr publisher,
|
||||
rclcpp::experimental::buffers::IntraProcessBufferBase::SharedPtr buffer =
|
||||
const rclcpp::PublisherBase::SharedPtr & publisher,
|
||||
const rclcpp::experimental::buffers::IntraProcessBufferBase::SharedPtr & buffer =
|
||||
rclcpp::experimental::buffers::IntraProcessBufferBase::SharedPtr());
|
||||
|
||||
/// Unregister a publisher using the publisher's unique id.
|
||||
@@ -386,6 +388,39 @@ private:
|
||||
std::vector<uint64_t> take_ownership_subscriptions;
|
||||
};
|
||||
|
||||
/// Hash function for rmw_gid_t to enable use in unordered_map
|
||||
struct rmw_gid_hash
|
||||
{
|
||||
std::size_t operator()(const rmw_gid_t & gid) const noexcept
|
||||
{
|
||||
// Using the FNV-1a hash algorithm on the gid data
|
||||
constexpr std::size_t FNV_prime = 1099511628211u;
|
||||
std::size_t result = 14695981039346656037u;
|
||||
|
||||
for (std::size_t i = 0; i < RMW_GID_STORAGE_SIZE; ++i) {
|
||||
result ^= gid.data[i];
|
||||
result *= FNV_prime;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
/// Equality comparison for rmw_gid_t to enable use in unordered_map
|
||||
struct rmw_gid_equal
|
||||
{
|
||||
bool operator()(const rmw_gid_t & lhs, const rmw_gid_t & rhs) const noexcept
|
||||
{
|
||||
// Compare the data bytes only.
|
||||
// implementation_identifier pointer comparison is not used here because
|
||||
// intra-process communication is always within the same process and RMW,
|
||||
// and pointer comparison is fragile across dynamically loaded components.
|
||||
return std::equal(
|
||||
std::begin(lhs.data),
|
||||
std::end(lhs.data),
|
||||
std::begin(rhs.data));
|
||||
}
|
||||
};
|
||||
|
||||
using SubscriptionMap =
|
||||
std::unordered_map<uint64_t, rclcpp::experimental::SubscriptionIntraProcessBase::WeakPtr>;
|
||||
|
||||
@@ -398,6 +433,16 @@ private:
|
||||
using PublisherToSubscriptionIdsMap =
|
||||
std::unordered_map<uint64_t, SplittedSubscriptions>;
|
||||
|
||||
/// Structure to store publisher information in GID lookup map
|
||||
struct PublisherInfo
|
||||
{
|
||||
uint64_t pub_id;
|
||||
rclcpp::PublisherBase::WeakPtr publisher;
|
||||
};
|
||||
|
||||
using GidToPublisherInfoMap =
|
||||
std::unordered_map<rmw_gid_t, PublisherInfo, rmw_gid_hash, rmw_gid_equal>;
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
static
|
||||
uint64_t
|
||||
@@ -410,8 +455,8 @@ private:
|
||||
RCLCPP_PUBLIC
|
||||
bool
|
||||
can_communicate(
|
||||
rclcpp::PublisherBase::SharedPtr pub,
|
||||
rclcpp::experimental::SubscriptionIntraProcessBase::SharedPtr sub) const;
|
||||
const rclcpp::PublisherBase::SharedPtr & pub,
|
||||
const rclcpp::experimental::SubscriptionIntraProcessBase::SharedPtr & sub) const;
|
||||
|
||||
template<
|
||||
typename ROSMessageType,
|
||||
@@ -642,6 +687,8 @@ private:
|
||||
PublisherBufferMap publisher_buffers_;
|
||||
|
||||
mutable std::shared_timed_mutex mutex_;
|
||||
|
||||
GidToPublisherInfoMap gid_to_publisher_info_;
|
||||
};
|
||||
|
||||
} // namespace experimental
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
* @throws std::invalid_argument if timer is a nullptr.
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void add_timer(rclcpp::TimerBase::SharedPtr timer);
|
||||
void add_timer(const rclcpp::TimerBase::SharedPtr & timer);
|
||||
|
||||
/**
|
||||
* @brief Remove a single timer from the object storage.
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
* @param timer the timer to remove.
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void remove_timer(rclcpp::TimerBase::SharedPtr timer);
|
||||
void remove_timer(const rclcpp::TimerBase::SharedPtr & timer);
|
||||
|
||||
/**
|
||||
* @brief Remove all the timers stored in the object.
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
|
||||
GenericClient(
|
||||
rclcpp::node_interfaces::NodeBaseInterface * node_base,
|
||||
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr & node_graph,
|
||||
const std::string & service_name,
|
||||
const std::string & service_type,
|
||||
rcl_client_options_t & client_options);
|
||||
@@ -111,8 +111,8 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
handle_response(
|
||||
std::shared_ptr<rmw_request_id_t> request_header,
|
||||
std::shared_ptr<void> response) override;
|
||||
const std::shared_ptr<rmw_request_id_t> & request_header,
|
||||
const std::shared_ptr<void> & response) override;
|
||||
|
||||
/// Send a request to the service server.
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
FutureAndRequestId
|
||||
async_send_request(const Request request);
|
||||
async_send_request(const Request & request);
|
||||
|
||||
/// Send a request to the service server and schedule a callback in the executor.
|
||||
/**
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
>::type * = nullptr
|
||||
>
|
||||
SharedFutureAndRequestId
|
||||
async_send_request(const Request request, CallbackT && cb)
|
||||
async_send_request(const Request & request, CallbackT && cb)
|
||||
{
|
||||
Promise promise;
|
||||
auto shared_future = promise.get_future().share();
|
||||
@@ -280,7 +280,7 @@ protected:
|
||||
RCLCPP_PUBLIC
|
||||
int64_t
|
||||
async_send_request_impl(
|
||||
const Request request,
|
||||
const Request & request,
|
||||
CallbackInfoVariant value);
|
||||
|
||||
std::optional<CallbackInfoVariant>
|
||||
|
||||
@@ -159,10 +159,10 @@ public:
|
||||
if (std::holds_alternative<SharedPtrCallback>(callback_)) {
|
||||
(void)request_header;
|
||||
const auto & cb = std::get<SharedPtrCallback>(callback_);
|
||||
cb(std::move(request), std::move(response));
|
||||
cb(std::move(request), response);
|
||||
} else if (std::holds_alternative<SharedPtrWithRequestHeaderCallback>(callback_)) {
|
||||
const auto & cb = std::get<SharedPtrWithRequestHeaderCallback>(callback_);
|
||||
cb(request_header, std::move(request), std::move(response));
|
||||
cb(request_header, std::move(request), response);
|
||||
}
|
||||
TRACETOOLS_TRACEPOINT(callback_end, static_cast<const void *>(this));
|
||||
return response;
|
||||
@@ -245,7 +245,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
GenericService(
|
||||
std::shared_ptr<rcl_node_t> node_handle,
|
||||
const std::shared_ptr<rcl_node_t> & node_handle,
|
||||
const std::string & service_name,
|
||||
const std::string & service_type,
|
||||
GenericServiceCallback any_callback,
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
bool
|
||||
take_request(SharedRequest request_out, rmw_request_id_t & request_id_out);
|
||||
take_request(SharedRequest & request_out, rmw_request_id_t & request_id_out);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
std::shared_ptr<void>
|
||||
@@ -287,8 +287,8 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
handle_request(
|
||||
std::shared_ptr<rmw_request_id_t> request_header,
|
||||
std::shared_ptr<void> request) override;
|
||||
const std::shared_ptr<rmw_request_id_t> & request_header,
|
||||
const std::shared_ptr<void> & request) override;
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
node_base,
|
||||
*rclcpp::get_message_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *ts_lib),
|
||||
topic_name,
|
||||
options.to_rcl_subscription_options(qos),
|
||||
force_cpu_buffer_backend_(options).to_rcl_subscription_options(qos),
|
||||
options.event_callbacks,
|
||||
options.use_default_callbacks,
|
||||
DeliveredMessageKind::SERIALIZED_MESSAGE),
|
||||
@@ -182,6 +182,17 @@ public:
|
||||
|
||||
private:
|
||||
RCLCPP_DISABLE_COPY(GenericSubscription)
|
||||
|
||||
template<typename AllocatorT>
|
||||
static rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>
|
||||
force_cpu_buffer_backend_(
|
||||
const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & options)
|
||||
{
|
||||
auto opts = options;
|
||||
opts.acceptable_buffer_backends = "cpu";
|
||||
return opts;
|
||||
}
|
||||
|
||||
AnySubscriptionCallback<rclcpp::SerializedMessage, std::allocator<void>> any_callback_;
|
||||
// The type support library should stay loaded, so it is stored in the GenericSubscription
|
||||
std::shared_ptr<rcpputils::SharedLibrary> ts_lib_;
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
set_on_trigger_callback(std::function<void(size_t)> callback);
|
||||
set_on_trigger_callback(const std::function<void(size_t)> & callback);
|
||||
|
||||
protected:
|
||||
rcl_guard_condition_t rcl_guard_condition_;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "rcl/allocator.h"
|
||||
#include "rcl/types.h"
|
||||
|
||||
#include "rclcpp/allocator/allocator_common.hpp"
|
||||
@@ -61,7 +62,16 @@ public:
|
||||
message_allocator_ = std::make_shared<MessageAlloc>();
|
||||
serialized_message_allocator_ = std::make_shared<SerializedMessageAlloc>();
|
||||
buffer_allocator_ = std::make_shared<BufferAlloc>();
|
||||
rcutils_allocator_ = allocator::get_rcl_allocator<char, BufferAlloc>(*buffer_allocator_.get());
|
||||
if constexpr (std::is_same_v<Alloc, std::allocator<void>>) {
|
||||
rcutils_allocator_ = rcl_get_default_allocator();
|
||||
} else {
|
||||
if constexpr (rclcpp::allocator::has_get_rcl_allocator_v<Alloc>) {
|
||||
rcutils_allocator_ = message_allocator_->get_rcl_allocator();
|
||||
} else {
|
||||
rcutils_allocator_ = allocator::get_rcl_allocator<char,
|
||||
BufferAlloc>(*buffer_allocator_.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
explicit MessageMemoryStrategy(std::shared_ptr<Alloc> allocator)
|
||||
@@ -69,7 +79,16 @@ public:
|
||||
message_allocator_ = std::make_shared<MessageAlloc>(*allocator.get());
|
||||
serialized_message_allocator_ = std::make_shared<SerializedMessageAlloc>(*allocator.get());
|
||||
buffer_allocator_ = std::make_shared<BufferAlloc>(*allocator.get());
|
||||
rcutils_allocator_ = allocator::get_rcl_allocator<char, BufferAlloc>(*buffer_allocator_.get());
|
||||
if constexpr (std::is_same_v<Alloc, std::allocator<void>>) {
|
||||
rcutils_allocator_ = rcl_get_default_allocator();
|
||||
} else {
|
||||
if constexpr (rclcpp::allocator::has_get_rcl_allocator_v<Alloc>) {
|
||||
rcutils_allocator_ = allocator->get_rcl_allocator();
|
||||
} else {
|
||||
rcutils_allocator_ = allocator::get_rcl_allocator<char,
|
||||
BufferAlloc>(*buffer_allocator_.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~MessageMemoryStrategy() = default;
|
||||
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
create_wall_timer(
|
||||
std::chrono::duration<DurationRepT, DurationT> period,
|
||||
CallbackT callback,
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr,
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr,
|
||||
bool autostart = true);
|
||||
|
||||
/// Create a timer that uses the node clock to drive the callback.
|
||||
@@ -256,7 +256,7 @@ public:
|
||||
create_timer(
|
||||
std::chrono::duration<DurationRepT, DurationT> period,
|
||||
CallbackT callback,
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr);
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
|
||||
|
||||
/// Create and return a Client.
|
||||
/**
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
create_client(
|
||||
const std::string & service_name,
|
||||
const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr);
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
|
||||
|
||||
/// Create and return a Service.
|
||||
/**
|
||||
@@ -286,7 +286,7 @@ public:
|
||||
const std::string & service_name,
|
||||
CallbackT && callback,
|
||||
const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr);
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
|
||||
|
||||
/// Create and return a GenericClient.
|
||||
/**
|
||||
@@ -302,7 +302,7 @@ public:
|
||||
const std::string & service_name,
|
||||
const std::string & service_type,
|
||||
const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr);
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
|
||||
|
||||
/// Create and return a GenericService.
|
||||
/**
|
||||
@@ -320,7 +320,7 @@ public:
|
||||
const std::string & service_type,
|
||||
CallbackT && callback,
|
||||
const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr);
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
|
||||
|
||||
/// Create and return a GenericPublisher.
|
||||
/**
|
||||
@@ -1471,7 +1471,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
wait_for_graph_change(
|
||||
rclcpp::Event::SharedPtr event,
|
||||
const rclcpp::Event::SharedPtr & event,
|
||||
std::chrono::nanoseconds timeout);
|
||||
|
||||
/// Get a clock as a non-const shared pointer which is managed by the node.
|
||||
|
||||
@@ -111,7 +111,7 @@ typename rclcpp::WallTimer<CallbackT>::SharedPtr
|
||||
Node::create_wall_timer(
|
||||
std::chrono::duration<DurationRepT, DurationT> period,
|
||||
CallbackT callback,
|
||||
rclcpp::CallbackGroup::SharedPtr group,
|
||||
const rclcpp::CallbackGroup::SharedPtr & group,
|
||||
bool autostart)
|
||||
{
|
||||
return rclcpp::create_wall_timer(
|
||||
@@ -128,7 +128,7 @@ typename rclcpp::GenericTimer<CallbackT>::SharedPtr
|
||||
Node::create_timer(
|
||||
std::chrono::duration<DurationRepT, DurationT> period,
|
||||
CallbackT callback,
|
||||
rclcpp::CallbackGroup::SharedPtr group)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group)
|
||||
{
|
||||
return rclcpp::create_timer(
|
||||
this->get_clock(),
|
||||
@@ -144,7 +144,7 @@ typename Client<ServiceT>::SharedPtr
|
||||
Node::create_client(
|
||||
const std::string & service_name,
|
||||
const rclcpp::QoS & qos,
|
||||
rclcpp::CallbackGroup::SharedPtr group)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group)
|
||||
{
|
||||
return rclcpp::create_client<ServiceT>(
|
||||
node_base_,
|
||||
@@ -161,7 +161,7 @@ Node::create_service(
|
||||
const std::string & service_name,
|
||||
CallbackT && callback,
|
||||
const rclcpp::QoS & qos,
|
||||
rclcpp::CallbackGroup::SharedPtr group)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group)
|
||||
{
|
||||
return rclcpp::create_service<ServiceT, CallbackT>(
|
||||
node_base_,
|
||||
@@ -179,7 +179,7 @@ Node::create_generic_service(
|
||||
const std::string & service_type,
|
||||
CallbackT && callback,
|
||||
const rclcpp::QoS & qos,
|
||||
rclcpp::CallbackGroup::SharedPtr group)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group)
|
||||
{
|
||||
return rclcpp::create_generic_service<CallbackT>(
|
||||
node_base_,
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
RCLCPP_SMART_PTR_ALIASES_ONLY(NodeLoggingInterface)
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
explicit NodeLogging(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base);
|
||||
explicit NodeLogging(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_base);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
virtual
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
create_logger_services(
|
||||
node_interfaces::NodeServicesInterface::SharedPtr node_services) override;
|
||||
const node_interfaces::NodeServicesInterface::SharedPtr & node_services) override;
|
||||
|
||||
private:
|
||||
RCLCPP_DISABLE_COPY(NodeLogging)
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
virtual
|
||||
void
|
||||
create_logger_services(
|
||||
node_interfaces::NodeServicesInterface::SharedPtr node_services) = 0;
|
||||
const node_interfaces::NodeServicesInterface::SharedPtr & node_services) = 0;
|
||||
};
|
||||
|
||||
} // namespace node_interfaces
|
||||
|
||||
@@ -39,10 +39,10 @@ public:
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
explicit NodeTypeDescriptions(
|
||||
NodeBaseInterface::SharedPtr node_base,
|
||||
NodeLoggingInterface::SharedPtr node_logging,
|
||||
NodeParametersInterface::SharedPtr node_parameters,
|
||||
NodeServicesInterface::SharedPtr node_services);
|
||||
const NodeBaseInterface::SharedPtr & node_base,
|
||||
const NodeLoggingInterface::SharedPtr & node_logging,
|
||||
const NodeParametersInterface::SharedPtr & node_parameters,
|
||||
const NodeServicesInterface::SharedPtr & node_services);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
virtual
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
/// Set the context, return this for parameter idiom.
|
||||
RCLCPP_PUBLIC
|
||||
NodeOptions &
|
||||
context(rclcpp::Context::SharedPtr context);
|
||||
context(const rclcpp::Context::SharedPtr & context);
|
||||
|
||||
/// Return a reference to the list of arguments for the node.
|
||||
RCLCPP_PUBLIC
|
||||
|
||||
@@ -64,13 +64,13 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
AsyncParametersClient(
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface,
|
||||
const rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics_interface,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_interface,
|
||||
const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_interface,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_base_interface,
|
||||
const rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr & node_topics_interface,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr & node_graph_interface,
|
||||
const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr & node_services_interface,
|
||||
const std::string & remote_node_name = "",
|
||||
const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS(),
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr);
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr);
|
||||
|
||||
/**
|
||||
* \param[in] node The async parameters client will be added to this node.
|
||||
@@ -80,10 +80,10 @@ public:
|
||||
*/
|
||||
template<typename NodeT>
|
||||
explicit AsyncParametersClient(
|
||||
const std::shared_ptr<NodeT> node,
|
||||
const std::shared_ptr<NodeT> & node,
|
||||
const std::string & remote_node_name = "",
|
||||
const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS(),
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr)
|
||||
: AsyncParametersClient(
|
||||
node->get_node_base_interface(),
|
||||
node->get_node_topics_interface(),
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
NodeT * node,
|
||||
const std::string & remote_node_name = "",
|
||||
const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS(),
|
||||
rclcpp::CallbackGroup::SharedPtr group = nullptr)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group = nullptr)
|
||||
: AsyncParametersClient(
|
||||
node->get_node_base_interface(),
|
||||
node->get_node_topics_interface(),
|
||||
@@ -120,41 +120,41 @@ public:
|
||||
std::shared_future<std::vector<rclcpp::Parameter>>
|
||||
get_parameters(
|
||||
const std::vector<std::string> & names,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<std::vector<rclcpp::Parameter>>)
|
||||
> callback = nullptr);
|
||||
> & callback = nullptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
std::shared_future<std::vector<rcl_interfaces::msg::ParameterDescriptor>>
|
||||
describe_parameters(
|
||||
const std::vector<std::string> & names,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<std::vector<rcl_interfaces::msg::ParameterDescriptor>>)
|
||||
> callback = nullptr);
|
||||
> & callback = nullptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
std::shared_future<std::vector<rclcpp::ParameterType>>
|
||||
get_parameter_types(
|
||||
const std::vector<std::string> & names,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<std::vector<rclcpp::ParameterType>>)
|
||||
> callback = nullptr);
|
||||
> & callback = nullptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
std::shared_future<std::vector<rcl_interfaces::msg::SetParametersResult>>
|
||||
set_parameters(
|
||||
const std::vector<rclcpp::Parameter> & parameters,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<std::vector<rcl_interfaces::msg::SetParametersResult>>)
|
||||
> callback = nullptr);
|
||||
> & callback = nullptr);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
std::shared_future<rcl_interfaces::msg::SetParametersResult>
|
||||
set_parameters_atomically(
|
||||
const std::vector<rclcpp::Parameter> & parameters,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<rcl_interfaces::msg::SetParametersResult>)
|
||||
> callback = nullptr);
|
||||
> & callback = nullptr);
|
||||
|
||||
/// Delete several parameters at once.
|
||||
/**
|
||||
@@ -200,9 +200,9 @@ public:
|
||||
list_parameters(
|
||||
const std::vector<std::string> & prefixes,
|
||||
uint64_t depth,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<rcl_interfaces::msg::ListParametersResult>)
|
||||
> callback = nullptr);
|
||||
> & callback = nullptr);
|
||||
|
||||
template<
|
||||
typename CallbackT,
|
||||
@@ -304,7 +304,7 @@ public:
|
||||
|
||||
template<typename NodeT>
|
||||
explicit SyncParametersClient(
|
||||
std::shared_ptr<NodeT> node,
|
||||
const std::shared_ptr<NodeT> & node,
|
||||
const std::string & remote_node_name = "",
|
||||
const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS())
|
||||
: SyncParametersClient(
|
||||
@@ -316,8 +316,8 @@ public:
|
||||
|
||||
template<typename NodeT>
|
||||
SyncParametersClient(
|
||||
rclcpp::Executor::SharedPtr executor,
|
||||
std::shared_ptr<NodeT> node,
|
||||
const rclcpp::Executor::SharedPtr & executor,
|
||||
const std::shared_ptr<NodeT> & node,
|
||||
const std::string & remote_node_name = "",
|
||||
const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS())
|
||||
: SyncParametersClient(
|
||||
@@ -344,7 +344,7 @@ public:
|
||||
|
||||
template<typename NodeT>
|
||||
SyncParametersClient(
|
||||
rclcpp::Executor::SharedPtr executor,
|
||||
const rclcpp::Executor::SharedPtr & executor,
|
||||
NodeT * node,
|
||||
const std::string & remote_node_name = "",
|
||||
const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS())
|
||||
@@ -360,11 +360,11 @@ public:
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
SyncParametersClient(
|
||||
rclcpp::Executor::SharedPtr executor,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface,
|
||||
const rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics_interface,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_interface,
|
||||
const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_interface,
|
||||
const rclcpp::Executor::SharedPtr & executor,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_base_interface,
|
||||
const rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr & node_topics_interface,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr & node_graph_interface,
|
||||
const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr & node_services_interface,
|
||||
const std::string & remote_node_name = "",
|
||||
const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS())
|
||||
: executor_(executor), node_base_interface_(node_base_interface)
|
||||
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
*/
|
||||
template<typename NodeT>
|
||||
explicit ParameterEventHandler(
|
||||
NodeT node,
|
||||
const NodeT & node,
|
||||
const rclcpp::QoS & qos =
|
||||
rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_parameter_events)))
|
||||
: node_base_(rclcpp::node_interfaces::get_node_base_interface(node))
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
RCUTILS_WARN_UNUSED
|
||||
ParameterEventCallbackHandle::SharedPtr
|
||||
add_parameter_event_callback(
|
||||
ParameterEventCallbackType callback);
|
||||
const ParameterEventCallbackType & callback);
|
||||
|
||||
/// Remove parameter event callback registered with add_parameter_event_callback.
|
||||
/**
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
remove_parameter_event_callback(
|
||||
ParameterEventCallbackHandle::SharedPtr callback_handle);
|
||||
const ParameterEventCallbackHandle::SharedPtr & callback_handle);
|
||||
|
||||
using ParameterCallbackType = ParameterCallbackHandle::ParameterCallbackType;
|
||||
|
||||
@@ -252,7 +252,7 @@ public:
|
||||
ParameterCallbackHandle::SharedPtr
|
||||
add_parameter_callback(
|
||||
const std::string & parameter_name,
|
||||
ParameterCallbackType callback,
|
||||
const ParameterCallbackType & callback,
|
||||
const std::string & node_name = "");
|
||||
|
||||
/// Configure which node parameter events will be received.
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
remove_parameter_callback(
|
||||
ParameterCallbackHandle::SharedPtr callback_handle);
|
||||
const ParameterCallbackHandle::SharedPtr & callback_handle);
|
||||
|
||||
/// Get an rclcpp::Parameter from a parameter event.
|
||||
/**
|
||||
|
||||
@@ -42,8 +42,8 @@ public:
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
ParameterService(
|
||||
const std::shared_ptr<node_interfaces::NodeBaseInterface> node_base,
|
||||
const std::shared_ptr<node_interfaces::NodeServicesInterface> node_services,
|
||||
const std::shared_ptr<node_interfaces::NodeBaseInterface> & node_base,
|
||||
const std::shared_ptr<node_interfaces::NodeServicesInterface> & node_services,
|
||||
rclcpp::node_interfaces::NodeParametersInterface * node_params,
|
||||
const rclcpp::QoS & qos_profile = rclcpp::ParametersQoS());
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
void
|
||||
setup_intra_process(
|
||||
uint64_t intra_process_publisher_id,
|
||||
IntraProcessManagerSharedPtr ipm);
|
||||
const IntraProcessManagerSharedPtr & ipm);
|
||||
|
||||
/// Get network flow endpoints
|
||||
/**
|
||||
@@ -300,7 +300,7 @@ public:
|
||||
*/
|
||||
void
|
||||
set_on_new_qos_event_callback(
|
||||
std::function<void(size_t)> callback,
|
||||
const std::function<void(size_t)> & callback,
|
||||
rcl_publisher_event_type_t event_type)
|
||||
{
|
||||
if (event_handlers_.count(event_type) == 0) {
|
||||
@@ -319,7 +319,7 @@ public:
|
||||
// The on_ready_callback signature has an extra `int` argument used to disambiguate between
|
||||
// possible different entities within a generic waitable.
|
||||
// We hide that detail to users of this method.
|
||||
std::function<void(size_t, int)> new_callback = std::bind(callback, std::placeholders::_1);
|
||||
std::function<void(size_t, int)> new_callback = [callback] (size_t nr, int) {callback(nr);};
|
||||
event_handlers_[event_type]->set_on_ready_callback(new_callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,11 +123,20 @@ private:
|
||||
rcl_allocator_t
|
||||
get_rcl_allocator() const
|
||||
{
|
||||
if (!plain_allocator_storage_) {
|
||||
plain_allocator_storage_ =
|
||||
std::make_shared<PlainAllocator>(*this->get_allocator());
|
||||
if constexpr (std::is_same_v<Allocator, std::allocator<void>>) {
|
||||
return rcl_get_default_allocator();
|
||||
} else {
|
||||
if constexpr (rclcpp::allocator::has_get_rcl_allocator_v<Allocator>) {
|
||||
return get_allocator()->get_rcl_allocator();
|
||||
} else {
|
||||
if (!plain_allocator_storage_) {
|
||||
plain_allocator_storage_ =
|
||||
std::make_shared<PlainAllocator>(*this->get_allocator());
|
||||
}
|
||||
|
||||
return rclcpp::allocator::get_rcl_allocator<char>(*plain_allocator_storage_);
|
||||
}
|
||||
}
|
||||
return rclcpp::allocator::get_rcl_allocator<char>(*plain_allocator_storage_);
|
||||
}
|
||||
|
||||
// This is a temporal workaround, to make sure that get_allocator()
|
||||
|
||||
@@ -58,12 +58,12 @@ public:
|
||||
RCLCPP_PUBLIC
|
||||
explicit Rate(
|
||||
const double rate,
|
||||
Clock::SharedPtr clock = std::make_shared<Clock>(RCL_SYSTEM_TIME));
|
||||
const Clock::SharedPtr & clock = std::make_shared<Clock>(RCL_SYSTEM_TIME));
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
explicit Rate(
|
||||
const Duration & period,
|
||||
Clock::SharedPtr clock = std::make_shared<Clock>(RCL_SYSTEM_TIME));
|
||||
const Clock::SharedPtr & clock = std::make_shared<Clock>(RCL_SYSTEM_TIME));
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
virtual bool
|
||||
|
||||
@@ -58,10 +58,10 @@ public:
|
||||
explicit SerializedMessage(const rcl_serialized_message_t & other);
|
||||
|
||||
/// Move Constructor for a SerializedMessage
|
||||
SerializedMessage(SerializedMessage && other);
|
||||
SerializedMessage(SerializedMessage && other) noexcept;
|
||||
|
||||
/// Constructor for a SerializedMessage from a moved rcl_serialized_message_t
|
||||
explicit SerializedMessage(rcl_serialized_message_t && other);
|
||||
explicit SerializedMessage(rcl_serialized_message_t && other) noexcept;
|
||||
|
||||
/// Copy assignment operator
|
||||
SerializedMessage & operator=(const SerializedMessage & other);
|
||||
@@ -70,10 +70,10 @@ public:
|
||||
SerializedMessage & operator=(const rcl_serialized_message_t & other);
|
||||
|
||||
/// Move assignment operator
|
||||
SerializedMessage & operator=(SerializedMessage && other);
|
||||
SerializedMessage & operator=(SerializedMessage && other) noexcept;
|
||||
|
||||
/// Move assignment operator from a rcl_serialized_message_t
|
||||
SerializedMessage & operator=(rcl_serialized_message_t && other);
|
||||
SerializedMessage & operator=(rcl_serialized_message_t && other) noexcept;
|
||||
|
||||
/// Destructor for a SerializedMessage
|
||||
virtual ~SerializedMessage();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "rcl/error_handling.h"
|
||||
#include "rcl/event_callback.h"
|
||||
@@ -54,7 +55,7 @@ public:
|
||||
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(ServiceBase)
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
explicit ServiceBase(std::shared_ptr<rcl_node_t> node_handle);
|
||||
explicit ServiceBase(const std::shared_ptr<rcl_node_t> & node_handle);
|
||||
|
||||
RCLCPP_PUBLIC
|
||||
virtual ~ServiceBase() = default;
|
||||
@@ -113,8 +114,8 @@ public:
|
||||
virtual
|
||||
void
|
||||
handle_request(
|
||||
std::shared_ptr<rmw_request_id_t> request_header,
|
||||
std::shared_ptr<void> request) = 0;
|
||||
const std::shared_ptr<rmw_request_id_t> & request_header,
|
||||
const std::shared_ptr<void> & request) = 0;
|
||||
|
||||
/// Exchange the "in use by wait set" state for this service.
|
||||
/**
|
||||
@@ -190,7 +191,7 @@ public:
|
||||
* \param[in] callback functor to be called when a new request is received
|
||||
*/
|
||||
void
|
||||
set_on_new_request_callback(std::function<void(size_t)> callback)
|
||||
set_on_new_request_callback(const std::function<void(size_t)> & callback)
|
||||
{
|
||||
if (!callback) {
|
||||
throw std::invalid_argument(
|
||||
@@ -286,6 +287,7 @@ class Service
|
||||
public std::enable_shared_from_this<Service<ServiceT>>
|
||||
{
|
||||
public:
|
||||
using ServiceType = ServiceT;
|
||||
using CallbackType = std::function<
|
||||
void (
|
||||
const std::shared_ptr<typename ServiceT::Request>,
|
||||
@@ -372,10 +374,10 @@ public:
|
||||
* \param[in] any_callback User defined callback to call when a client request is received.
|
||||
*/
|
||||
Service(
|
||||
std::shared_ptr<rcl_node_t> node_handle,
|
||||
std::shared_ptr<rcl_service_t> service_handle,
|
||||
const std::shared_ptr<rcl_node_t> & node_handle,
|
||||
const std::shared_ptr<rcl_service_t> & service_handle,
|
||||
AnyServiceCallback<ServiceT> any_callback)
|
||||
: ServiceBase(node_handle), any_callback_(any_callback),
|
||||
: ServiceBase(node_handle), any_callback_(std::move(any_callback)),
|
||||
srv_type_support_handle_(rosidl_typesupport_cpp::get_service_type_support_handle<ServiceT>())
|
||||
{
|
||||
// check if service handle was initialized
|
||||
@@ -407,10 +409,10 @@ public:
|
||||
* \param[in] any_callback User defined callback to call when a client request is received.
|
||||
*/
|
||||
Service(
|
||||
std::shared_ptr<rcl_node_t> node_handle,
|
||||
const std::shared_ptr<rcl_node_t> & node_handle,
|
||||
rcl_service_t * service_handle,
|
||||
AnyServiceCallback<ServiceT> any_callback)
|
||||
: ServiceBase(node_handle), any_callback_(any_callback),
|
||||
: ServiceBase(node_handle), any_callback_(std::move(any_callback)),
|
||||
srv_type_support_handle_(rosidl_typesupport_cpp::get_service_type_support_handle<ServiceT>())
|
||||
{
|
||||
// check if service handle was initialized
|
||||
@@ -471,8 +473,8 @@ public:
|
||||
|
||||
void
|
||||
handle_request(
|
||||
std::shared_ptr<rmw_request_id_t> request_header,
|
||||
std::shared_ptr<void> request) override
|
||||
const std::shared_ptr<rmw_request_id_t> & request_header,
|
||||
const std::shared_ptr<void> & request) override
|
||||
{
|
||||
auto typed_request = std::static_pointer_cast<typename ServiceT::Request>(request);
|
||||
auto response = any_callback_.dispatch(this->shared_from_this(), request_header, typed_request);
|
||||
@@ -510,7 +512,7 @@ public:
|
||||
*/
|
||||
void
|
||||
configure_introspection(
|
||||
Clock::SharedPtr clock, const QoS & qos_service_event_pub,
|
||||
const Clock::SharedPtr & clock, const QoS & qos_service_event_pub,
|
||||
rcl_service_introspection_state_t introspection_state)
|
||||
{
|
||||
rcl_publisher_options_t pub_opts = rcl_publisher_get_default_options();
|
||||
|
||||
@@ -515,7 +515,11 @@ public:
|
||||
|
||||
rcl_allocator_t get_allocator() override
|
||||
{
|
||||
return rclcpp::allocator::get_rcl_allocator<void *, VoidAlloc>(*allocator_.get());
|
||||
if constexpr (std::is_same_v<Alloc, std::allocator<void>>) {
|
||||
return rcl_get_default_allocator();
|
||||
} else {
|
||||
return rclcpp::allocator::get_rcl_allocator<void *, VoidAlloc>(*allocator_.get());
|
||||
}
|
||||
}
|
||||
|
||||
size_t number_of_ready_subscriptions() const override
|
||||
|
||||
@@ -372,7 +372,7 @@ public:
|
||||
* \param[in] callback functor to be called when a new message is received
|
||||
*/
|
||||
void
|
||||
set_on_new_message_callback(std::function<void(size_t)> callback)
|
||||
set_on_new_message_callback(const std::function<void(size_t)> & callback)
|
||||
{
|
||||
if (!callback) {
|
||||
throw std::invalid_argument(
|
||||
@@ -450,7 +450,7 @@ public:
|
||||
* \param[in] callback functor to be called when a new message is received
|
||||
*/
|
||||
void
|
||||
set_on_new_intra_process_message_callback(std::function<void(size_t)> callback)
|
||||
set_on_new_intra_process_message_callback(const std::function<void(size_t)> & callback)
|
||||
{
|
||||
if (!use_intra_process_) {
|
||||
RCLCPP_WARN(
|
||||
@@ -468,7 +468,7 @@ public:
|
||||
// The on_ready_callback signature has an extra `int` argument used to disambiguate between
|
||||
// possible different entities within a generic waitable.
|
||||
// We hide that detail to users of this method.
|
||||
std::function<void(size_t, int)> new_callback = std::bind(callback, std::placeholders::_1);
|
||||
std::function<void(size_t, int)> new_callback = [callback] (size_t nr, int) {callback(nr);};
|
||||
subscription_intra_process_->set_on_ready_callback(new_callback);
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ public:
|
||||
*/
|
||||
void
|
||||
set_on_new_qos_event_callback(
|
||||
std::function<void(size_t)> callback,
|
||||
const std::function<void(size_t)> & callback,
|
||||
rcl_subscription_event_type_t event_type)
|
||||
{
|
||||
if (event_handlers_.count(event_type) == 0) {
|
||||
@@ -533,7 +533,7 @@ public:
|
||||
// The on_ready_callback signature has an extra `int` argument used to disambiguate between
|
||||
// possible different entities within a generic waitable.
|
||||
// We hide that detail to users of this method.
|
||||
std::function<void(size_t, int)> new_callback = std::bind(callback, std::placeholders::_1);
|
||||
std::function<void(size_t, int)> new_callback = [callback] (size_t nr, int) {callback(nr);};
|
||||
event_handlers_[event_type]->set_on_ready_callback(new_callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,15 @@ struct SubscriptionOptionsBase
|
||||
QosOverridingOptions qos_overriding_options;
|
||||
|
||||
ContentFilterOptions content_filter_options;
|
||||
|
||||
/// Acceptable buffer backend names for this subscription.
|
||||
/**
|
||||
* Empty string or "cpu" means CPU-only (default for backward compatibility).
|
||||
* "any" means all installed backends are acceptable.
|
||||
* Comma-separated for specific backends, e.g. "cuda,demo".
|
||||
* CPU is always implicitly acceptable regardless of this value.
|
||||
*/
|
||||
std::string acceptable_buffer_backends{"cpu"};
|
||||
};
|
||||
|
||||
/// Structure containing optional configuration for Subscriptions.
|
||||
@@ -145,6 +154,11 @@ struct SubscriptionOptionsWithAllocator : public SubscriptionOptionsBase
|
||||
}
|
||||
}
|
||||
|
||||
if (!acceptable_buffer_backends.empty()) {
|
||||
result.rmw_subscription_options.acceptable_buffer_backends =
|
||||
acceptable_buffer_backends.c_str();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -167,11 +181,20 @@ private:
|
||||
rcl_allocator_t
|
||||
get_rcl_allocator() const
|
||||
{
|
||||
if (!plain_allocator_storage_) {
|
||||
plain_allocator_storage_ =
|
||||
std::make_shared<PlainAllocator>(*this->get_allocator());
|
||||
if constexpr (std::is_same_v<Allocator, std::allocator<void>>) {
|
||||
return rcl_get_default_allocator();
|
||||
} else {
|
||||
if constexpr (rclcpp::allocator::has_get_rcl_allocator_v<Allocator>) {
|
||||
return get_allocator()->get_rcl_allocator();
|
||||
} else {
|
||||
if (!plain_allocator_storage_) {
|
||||
plain_allocator_storage_ =
|
||||
std::make_shared<PlainAllocator>(*this->get_allocator());
|
||||
}
|
||||
|
||||
return rclcpp::allocator::get_rcl_allocator<char>(*plain_allocator_storage_);
|
||||
}
|
||||
}
|
||||
return rclcpp::allocator::get_rcl_allocator<char>(*plain_allocator_storage_);
|
||||
}
|
||||
|
||||
// This is a temporal workaround, to make sure that get_allocator()
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
explicit TimeSource(
|
||||
rclcpp::Node::SharedPtr node,
|
||||
const rclcpp::Node::SharedPtr & node,
|
||||
const rclcpp::QoS & qos = rclcpp::ClockQoS(),
|
||||
bool use_clock_thread = true);
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
* \param node std::shared pointer to a initialized node
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void attachNode(rclcpp::Node::SharedPtr node);
|
||||
void attachNode(const rclcpp::Node::SharedPtr & node);
|
||||
|
||||
/// Attach node to the time source.
|
||||
/**
|
||||
@@ -124,11 +124,11 @@ public:
|
||||
* \throws std::invalid_argument the time source must be a RCL_ROS_TIME otherwise throws an exception
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void attachClock(rclcpp::Clock::SharedPtr clock);
|
||||
void attachClock(const rclcpp::Clock::SharedPtr & clock);
|
||||
|
||||
/// Detach a clock from the time source
|
||||
RCLCPP_PUBLIC
|
||||
void detachClock(rclcpp::Clock::SharedPtr clock);
|
||||
void detachClock(const rclcpp::Clock::SharedPtr & clock);
|
||||
|
||||
/// Get whether a separate clock thread is used or not
|
||||
RCLCPP_PUBLIC
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
set_on_reset_callback(std::function<void(size_t)> callback);
|
||||
set_on_reset_callback(const std::function<void(size_t)> & callback);
|
||||
|
||||
/// Unset the callback registered for reset timer
|
||||
RCLCPP_PUBLIC
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "rclcpp/context.hpp"
|
||||
#include "rclcpp/contexts/default_context.hpp"
|
||||
#include "rclcpp/init_options.hpp"
|
||||
#include "rclcpp/visibility_control.hpp"
|
||||
|
||||
@@ -173,7 +174,7 @@ remove_ros_arguments(int argc, char const * const * argv);
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
bool
|
||||
ok(rclcpp::Context::SharedPtr context = nullptr);
|
||||
ok(const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context());
|
||||
|
||||
/// Shutdown rclcpp context, invalidating it for derived entities.
|
||||
/**
|
||||
@@ -192,7 +193,7 @@ ok(rclcpp::Context::SharedPtr context = nullptr);
|
||||
RCLCPP_PUBLIC
|
||||
bool
|
||||
shutdown(
|
||||
rclcpp::Context::SharedPtr context = nullptr,
|
||||
const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context(),
|
||||
const std::string & reason = "user called rclcpp::shutdown()");
|
||||
|
||||
/// Register a function to be called when shutdown is called on the context.
|
||||
@@ -212,7 +213,9 @@ shutdown(
|
||||
*/
|
||||
RCLCPP_PUBLIC
|
||||
void
|
||||
on_shutdown(std::function<void()> callback, rclcpp::Context::SharedPtr context = nullptr);
|
||||
on_shutdown(
|
||||
const std::function<void()> & callback,
|
||||
const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context());
|
||||
|
||||
/// Use the global condition variable to block for the specified amount of time.
|
||||
/**
|
||||
@@ -231,7 +234,7 @@ RCLCPP_PUBLIC
|
||||
bool
|
||||
sleep_for(
|
||||
const std::chrono::nanoseconds & nanoseconds,
|
||||
rclcpp::Context::SharedPtr context = nullptr);
|
||||
const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context());
|
||||
|
||||
/// Safely check if addition will overflow.
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ using rclcpp::CallbackGroupType;
|
||||
|
||||
CallbackGroup::CallbackGroup(
|
||||
CallbackGroupType group_type,
|
||||
rclcpp::Context::WeakPtr context,
|
||||
const rclcpp::Context::WeakPtr & context,
|
||||
bool automatically_add_to_executor_with_node)
|
||||
: type_(group_type), associated_with_executor_(false),
|
||||
can_be_taken_from_(true),
|
||||
@@ -59,6 +59,7 @@ CallbackGroup::type() const
|
||||
size_t
|
||||
CallbackGroup::size() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
return
|
||||
subscription_ptrs_.size() +
|
||||
service_ptrs_.size() +
|
||||
@@ -68,11 +69,11 @@ CallbackGroup::size() const
|
||||
}
|
||||
|
||||
void CallbackGroup::collect_all_ptrs(
|
||||
std::function<void(const rclcpp::SubscriptionBase::SharedPtr &)> sub_func,
|
||||
std::function<void(const rclcpp::ServiceBase::SharedPtr &)> service_func,
|
||||
std::function<void(const rclcpp::ClientBase::SharedPtr &)> client_func,
|
||||
std::function<void(const rclcpp::TimerBase::SharedPtr &)> timer_func,
|
||||
std::function<void(const rclcpp::Waitable::SharedPtr &)> waitable_func) const
|
||||
const std::function<void(const rclcpp::SubscriptionBase::SharedPtr &)> & sub_func,
|
||||
const std::function<void(const rclcpp::ServiceBase::SharedPtr &)> & service_func,
|
||||
const std::function<void(const rclcpp::ClientBase::SharedPtr &)> & client_func,
|
||||
const std::function<void(const rclcpp::TimerBase::SharedPtr &)> & timer_func,
|
||||
const std::function<void(const rclcpp::Waitable::SharedPtr &)> & waitable_func) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
@@ -149,7 +150,7 @@ CallbackGroup::trigger_notify_guard_condition()
|
||||
|
||||
void
|
||||
CallbackGroup::add_subscription(
|
||||
const rclcpp::SubscriptionBase::SharedPtr subscription_ptr)
|
||||
const rclcpp::SubscriptionBase::SharedPtr & subscription_ptr)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
subscription_ptrs_.push_back(subscription_ptr);
|
||||
@@ -157,12 +158,12 @@ CallbackGroup::add_subscription(
|
||||
std::remove_if(
|
||||
subscription_ptrs_.begin(),
|
||||
subscription_ptrs_.end(),
|
||||
[](rclcpp::SubscriptionBase::WeakPtr x) {return x.expired();}),
|
||||
[](const rclcpp::SubscriptionBase::WeakPtr & x) {return x.expired();}),
|
||||
subscription_ptrs_.end());
|
||||
}
|
||||
|
||||
void
|
||||
CallbackGroup::add_timer(const rclcpp::TimerBase::SharedPtr timer_ptr)
|
||||
CallbackGroup::add_timer(const rclcpp::TimerBase::SharedPtr & timer_ptr)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
timer_ptrs_.push_back(timer_ptr);
|
||||
@@ -170,12 +171,12 @@ CallbackGroup::add_timer(const rclcpp::TimerBase::SharedPtr timer_ptr)
|
||||
std::remove_if(
|
||||
timer_ptrs_.begin(),
|
||||
timer_ptrs_.end(),
|
||||
[](rclcpp::TimerBase::WeakPtr x) {return x.expired();}),
|
||||
[](const rclcpp::TimerBase::WeakPtr & x) {return x.expired();}),
|
||||
timer_ptrs_.end());
|
||||
}
|
||||
|
||||
void
|
||||
CallbackGroup::add_service(const rclcpp::ServiceBase::SharedPtr service_ptr)
|
||||
CallbackGroup::add_service(const rclcpp::ServiceBase::SharedPtr & service_ptr)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
service_ptrs_.push_back(service_ptr);
|
||||
@@ -183,12 +184,12 @@ CallbackGroup::add_service(const rclcpp::ServiceBase::SharedPtr service_ptr)
|
||||
std::remove_if(
|
||||
service_ptrs_.begin(),
|
||||
service_ptrs_.end(),
|
||||
[](rclcpp::ServiceBase::WeakPtr x) {return x.expired();}),
|
||||
[](const rclcpp::ServiceBase::WeakPtr & x) {return x.expired();}),
|
||||
service_ptrs_.end());
|
||||
}
|
||||
|
||||
void
|
||||
CallbackGroup::add_client(const rclcpp::ClientBase::SharedPtr client_ptr)
|
||||
CallbackGroup::add_client(const rclcpp::ClientBase::SharedPtr & client_ptr)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
client_ptrs_.push_back(client_ptr);
|
||||
@@ -196,12 +197,12 @@ CallbackGroup::add_client(const rclcpp::ClientBase::SharedPtr client_ptr)
|
||||
std::remove_if(
|
||||
client_ptrs_.begin(),
|
||||
client_ptrs_.end(),
|
||||
[](rclcpp::ClientBase::WeakPtr x) {return x.expired();}),
|
||||
[](const rclcpp::ClientBase::WeakPtr & x) {return x.expired();}),
|
||||
client_ptrs_.end());
|
||||
}
|
||||
|
||||
void
|
||||
CallbackGroup::add_waitable(const rclcpp::Waitable::SharedPtr waitable_ptr)
|
||||
CallbackGroup::add_waitable(const rclcpp::Waitable::SharedPtr & waitable_ptr)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
waitable_ptrs_.push_back(waitable_ptr);
|
||||
@@ -209,12 +210,12 @@ CallbackGroup::add_waitable(const rclcpp::Waitable::SharedPtr waitable_ptr)
|
||||
std::remove_if(
|
||||
waitable_ptrs_.begin(),
|
||||
waitable_ptrs_.end(),
|
||||
[](rclcpp::Waitable::WeakPtr x) {return x.expired();}),
|
||||
[](const rclcpp::Waitable::WeakPtr & x) {return x.expired();}),
|
||||
waitable_ptrs_.end());
|
||||
}
|
||||
|
||||
void
|
||||
CallbackGroup::remove_waitable(const rclcpp::Waitable::SharedPtr waitable_ptr) noexcept
|
||||
CallbackGroup::remove_waitable(const rclcpp::Waitable::SharedPtr & waitable_ptr) noexcept
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
for (auto iter = waitable_ptrs_.begin(); iter != waitable_ptrs_.end(); ++iter) {
|
||||
|
||||
@@ -37,7 +37,7 @@ using rclcpp::exceptions::throw_from_rcl_error;
|
||||
|
||||
ClientBase::ClientBase(
|
||||
rclcpp::node_interfaces::NodeBaseInterface * node_base,
|
||||
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph)
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr & node_graph)
|
||||
: node_graph_(node_graph),
|
||||
node_handle_(node_base->get_shared_rcl_node_handle()),
|
||||
context_(node_base->get_context()),
|
||||
|
||||
@@ -60,8 +60,8 @@ JumpHandler::JumpHandler(
|
||||
pre_callback_t pre_callback,
|
||||
post_callback_t post_callback,
|
||||
const rcl_jump_threshold_t & threshold)
|
||||
: pre_callback(pre_callback),
|
||||
post_callback(post_callback),
|
||||
: pre_callback(std::move(pre_callback)),
|
||||
post_callback(std::move(post_callback)),
|
||||
notice_threshold(threshold)
|
||||
{}
|
||||
|
||||
@@ -85,8 +85,8 @@ Clock::now() const
|
||||
|
||||
bool
|
||||
Clock::sleep_until(
|
||||
Time until,
|
||||
Context::SharedPtr context)
|
||||
const Time & until,
|
||||
const Context::SharedPtr & context)
|
||||
{
|
||||
if (!context || !context->is_valid()) {
|
||||
throw std::runtime_error("context cannot be slept with because it's invalid");
|
||||
@@ -194,7 +194,7 @@ Clock::sleep_until(
|
||||
}
|
||||
|
||||
bool
|
||||
Clock::sleep_for(Duration rel_time, Context::SharedPtr context)
|
||||
Clock::sleep_for(const Duration & rel_time, const Context::SharedPtr & context)
|
||||
{
|
||||
return sleep_until(now() + rel_time, context);
|
||||
}
|
||||
@@ -209,7 +209,7 @@ Clock::started()
|
||||
}
|
||||
|
||||
bool
|
||||
Clock::wait_until_started(Context::SharedPtr context)
|
||||
Clock::wait_until_started(const Context::SharedPtr & context)
|
||||
{
|
||||
if (!context || !context->is_valid()) {
|
||||
throw std::runtime_error("context cannot be slept with because it's invalid");
|
||||
@@ -229,7 +229,7 @@ Clock::wait_until_started(Context::SharedPtr context)
|
||||
bool
|
||||
Clock::wait_until_started(
|
||||
const Duration & timeout,
|
||||
Context::SharedPtr context,
|
||||
const Context::SharedPtr & context,
|
||||
const Duration & wait_tick_ns)
|
||||
{
|
||||
if (!context || !context->is_valid()) {
|
||||
@@ -318,8 +318,8 @@ Clock::on_time_jump(
|
||||
|
||||
JumpHandler::SharedPtr
|
||||
Clock::create_jump_callback(
|
||||
JumpHandler::pre_callback_t pre_callback,
|
||||
JumpHandler::post_callback_t post_callback,
|
||||
const JumpHandler::pre_callback_t & pre_callback,
|
||||
const JumpHandler::post_callback_t & post_callback,
|
||||
const rcl_jump_threshold_t & threshold)
|
||||
{
|
||||
// Allocate a new jump handler
|
||||
@@ -516,7 +516,7 @@ class ClockConditionalVariable::Impl
|
||||
ClockWaiter::UniquePtr clock_;
|
||||
|
||||
public:
|
||||
Impl(const rclcpp::Clock::SharedPtr & clock, rclcpp::Context::SharedPtr context)
|
||||
Impl(const rclcpp::Clock::SharedPtr & clock, const rclcpp::Context::SharedPtr & context)
|
||||
:context_(context),
|
||||
clock_(std::make_unique<ClockWaiter>(clock))
|
||||
{
|
||||
@@ -541,7 +541,7 @@ public:
|
||||
|
||||
bool
|
||||
wait_until(
|
||||
std::unique_lock<std::mutex> & lock, rclcpp::Time until,
|
||||
std::unique_lock<std::mutex> & lock, const rclcpp::Time & until,
|
||||
const std::function<bool ()> & pred)
|
||||
{
|
||||
if(lock.mutex() != &pred_mutex_) {
|
||||
@@ -571,7 +571,7 @@ public:
|
||||
|
||||
ClockConditionalVariable::ClockConditionalVariable(
|
||||
const rclcpp::Clock::SharedPtr & clock,
|
||||
rclcpp::Context::SharedPtr context)
|
||||
const rclcpp::Context::SharedPtr & context)
|
||||
:impl_(std::make_unique<Impl>(clock, context))
|
||||
{
|
||||
}
|
||||
@@ -586,7 +586,7 @@ ClockConditionalVariable::notify_one()
|
||||
|
||||
bool
|
||||
ClockConditionalVariable::wait_until(
|
||||
std::unique_lock<std::mutex> & lock, rclcpp::Time until,
|
||||
std::unique_lock<std::mutex> & lock, const rclcpp::Time & until,
|
||||
const std::function<bool ()> & pred)
|
||||
{
|
||||
return impl_->wait_until(lock, until, pred);
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
std::remove_if(
|
||||
weak_contexts_.begin(),
|
||||
weak_contexts_.end(),
|
||||
[context](const Context::WeakPtr weak_context) {
|
||||
[context](const Context::WeakPtr & weak_context) {
|
||||
auto locked_context = weak_context.lock();
|
||||
if (!locked_context) {
|
||||
// take advantage and removed expired contexts
|
||||
@@ -388,14 +388,14 @@ Context::shutdown(const std::string & reason)
|
||||
}
|
||||
|
||||
rclcpp::Context::OnShutdownCallback
|
||||
Context::on_shutdown(OnShutdownCallback callback)
|
||||
Context::on_shutdown(const OnShutdownCallback & callback)
|
||||
{
|
||||
add_on_shutdown_callback(callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
rclcpp::OnShutdownCallbackHandle
|
||||
Context::add_on_shutdown_callback(OnShutdownCallback callback)
|
||||
Context::add_on_shutdown_callback(const OnShutdownCallback & callback)
|
||||
{
|
||||
return add_shutdown_callback<ShutdownType::on_shutdown>(callback);
|
||||
}
|
||||
@@ -407,7 +407,7 @@ Context::remove_on_shutdown_callback(const OnShutdownCallbackHandle & callback_h
|
||||
}
|
||||
|
||||
rclcpp::PreShutdownCallbackHandle
|
||||
Context::add_pre_shutdown_callback(PreShutdownCallback callback)
|
||||
Context::add_pre_shutdown_callback(const PreShutdownCallback & callback)
|
||||
{
|
||||
return add_shutdown_callback<ShutdownType::pre_shutdown>(callback);
|
||||
}
|
||||
@@ -422,7 +422,7 @@ Context::remove_pre_shutdown_callback(
|
||||
template<Context::ShutdownType shutdown_type>
|
||||
rclcpp::ShutdownCallbackHandle
|
||||
Context::add_shutdown_callback(
|
||||
ShutdownCallback callback)
|
||||
const ShutdownCallback & callback)
|
||||
{
|
||||
auto callback_shared_ptr =
|
||||
std::make_shared<ShutdownCallbackHandle::ShutdownCallbackType>(callback);
|
||||
@@ -497,8 +497,9 @@ Context::get_shutdown_callback() const
|
||||
const auto get_callback_vector = [](auto & mutex, auto & callback_set) {
|
||||
const std::lock_guard<std::recursive_mutex> lock(mutex);
|
||||
std::vector<rclcpp::Context::ShutdownCallback> callbacks;
|
||||
callbacks.reserve(callback_set.size());
|
||||
for (auto & callback : callback_set) {
|
||||
callbacks.push_back(*callback);
|
||||
callbacks.emplace_back(*callback);
|
||||
}
|
||||
return callbacks;
|
||||
};
|
||||
|
||||
@@ -19,13 +19,13 @@ namespace rclcpp
|
||||
{
|
||||
rclcpp::GenericClient::SharedPtr
|
||||
create_generic_client(
|
||||
std::shared_ptr<node_interfaces::NodeBaseInterface> node_base,
|
||||
std::shared_ptr<node_interfaces::NodeGraphInterface> node_graph,
|
||||
std::shared_ptr<node_interfaces::NodeServicesInterface> node_services,
|
||||
const std::shared_ptr<node_interfaces::NodeBaseInterface> & node_base,
|
||||
const std::shared_ptr<node_interfaces::NodeGraphInterface> & node_graph,
|
||||
const std::shared_ptr<node_interfaces::NodeServicesInterface> & node_services,
|
||||
const std::string & service_name,
|
||||
const std::string & service_type,
|
||||
const rclcpp::QoS & qos,
|
||||
rclcpp::CallbackGroup::SharedPtr group)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group)
|
||||
{
|
||||
rcl_client_options_t options = rcl_client_get_default_options();
|
||||
options.qos = qos.get_rmw_qos_profile();
|
||||
|
||||
@@ -99,29 +99,29 @@ Executor::~Executor()
|
||||
notify_waitable_->remove_guard_condition(shutdown_guard_condition_);
|
||||
current_collection_.timers.update(
|
||||
{}, {},
|
||||
[this](auto timer) {wait_set_.remove_timer(timer);});
|
||||
[this](auto timer) {wait_set_.remove_timer(std::move(timer));});
|
||||
|
||||
current_collection_.subscriptions.update(
|
||||
{}, {},
|
||||
[this](auto subscription) {
|
||||
wait_set_.remove_subscription(subscription, kDefaultSubscriptionMask);
|
||||
wait_set_.remove_subscription(std::move(subscription), kDefaultSubscriptionMask);
|
||||
});
|
||||
|
||||
current_collection_.clients.update(
|
||||
{}, {},
|
||||
[this](auto client) {wait_set_.remove_client(client);});
|
||||
[this](auto client) {wait_set_.remove_client(std::move(client));});
|
||||
|
||||
current_collection_.services.update(
|
||||
{}, {},
|
||||
[this](auto service) {wait_set_.remove_service(service);});
|
||||
[this](auto service) {wait_set_.remove_service(std::move(service));});
|
||||
|
||||
current_collection_.guard_conditions.update(
|
||||
{}, {},
|
||||
[this](auto guard_condition) {wait_set_.remove_guard_condition(guard_condition);});
|
||||
[this](auto guard_condition) {wait_set_.remove_guard_condition(std::move(guard_condition));});
|
||||
|
||||
current_collection_.waitables.update(
|
||||
{}, {},
|
||||
[this](auto waitable) {wait_set_.remove_waitable(waitable);});
|
||||
[this](auto waitable) {wait_set_.remove_waitable(std::move(waitable));});
|
||||
|
||||
// Remove shutdown callback handle registered to Context
|
||||
if (!context_->remove_on_shutdown_callback(shutdown_callback_handle_)) {
|
||||
@@ -170,8 +170,8 @@ Executor::get_automatically_added_callback_groups_from_nodes()
|
||||
|
||||
void
|
||||
Executor::add_callback_group(
|
||||
rclcpp::CallbackGroup::SharedPtr group_ptr,
|
||||
[[maybe_unused]] rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
|
||||
const rclcpp::CallbackGroup::SharedPtr & group_ptr,
|
||||
[[maybe_unused]] const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
bool notify)
|
||||
{
|
||||
this->collector_.add_callback_group(group_ptr);
|
||||
@@ -186,7 +186,9 @@ Executor::add_callback_group(
|
||||
}
|
||||
|
||||
void
|
||||
Executor::add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify)
|
||||
Executor::add_node(
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
bool notify)
|
||||
{
|
||||
if (node_ptr->get_context() != context_) {
|
||||
throw std::runtime_error(
|
||||
@@ -206,7 +208,7 @@ Executor::add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_pt
|
||||
|
||||
void
|
||||
Executor::remove_callback_group(
|
||||
rclcpp::CallbackGroup::SharedPtr group_ptr,
|
||||
const rclcpp::CallbackGroup::SharedPtr & group_ptr,
|
||||
bool notify)
|
||||
{
|
||||
this->collector_.remove_callback_group(group_ptr);
|
||||
@@ -221,13 +223,15 @@ Executor::remove_callback_group(
|
||||
}
|
||||
|
||||
void
|
||||
Executor::add_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify)
|
||||
Executor::add_node(const std::shared_ptr<rclcpp::Node> & node_ptr, bool notify)
|
||||
{
|
||||
this->add_node(node_ptr->get_node_base_interface(), notify);
|
||||
}
|
||||
|
||||
void
|
||||
Executor::remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify)
|
||||
Executor::remove_node(
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
bool notify)
|
||||
{
|
||||
this->collector_.remove_node(node_ptr);
|
||||
|
||||
@@ -241,14 +245,14 @@ Executor::remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node
|
||||
}
|
||||
|
||||
void
|
||||
Executor::remove_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify)
|
||||
Executor::remove_node(const std::shared_ptr<rclcpp::Node> & node_ptr, bool notify)
|
||||
{
|
||||
this->remove_node(node_ptr->get_node_base_interface(), notify);
|
||||
}
|
||||
|
||||
void
|
||||
Executor::spin_node_once_nanoseconds(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node,
|
||||
std::chrono::nanoseconds timeout)
|
||||
{
|
||||
this->add_node(node, false);
|
||||
@@ -311,7 +315,7 @@ Executor::spin_until_future_complete_impl(
|
||||
}
|
||||
|
||||
void
|
||||
Executor::spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node)
|
||||
Executor::spin_node_some(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node)
|
||||
{
|
||||
this->add_node(node, false);
|
||||
spin_some();
|
||||
@@ -319,7 +323,7 @@ Executor::spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr n
|
||||
}
|
||||
|
||||
void
|
||||
Executor::spin_node_some(std::shared_ptr<rclcpp::Node> node)
|
||||
Executor::spin_node_some(const std::shared_ptr<rclcpp::Node> & node)
|
||||
{
|
||||
this->spin_node_some(node->get_node_base_interface());
|
||||
}
|
||||
@@ -331,7 +335,7 @@ void Executor::spin_some(std::chrono::nanoseconds max_duration)
|
||||
|
||||
void
|
||||
Executor::spin_node_all(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node,
|
||||
std::chrono::nanoseconds max_duration)
|
||||
{
|
||||
this->add_node(node, false);
|
||||
@@ -340,7 +344,9 @@ Executor::spin_node_all(
|
||||
}
|
||||
|
||||
void
|
||||
Executor::spin_node_all(std::shared_ptr<rclcpp::Node> node, std::chrono::nanoseconds max_duration)
|
||||
Executor::spin_node_all(
|
||||
const std::shared_ptr<rclcpp::Node> & node,
|
||||
std::chrono::nanoseconds max_duration)
|
||||
{
|
||||
this->spin_node_all(node->get_node_base_interface(), max_duration);
|
||||
}
|
||||
@@ -546,7 +552,7 @@ take_and_do_error_handling(
|
||||
}
|
||||
|
||||
void
|
||||
Executor::execute_subscription(rclcpp::SubscriptionBase::SharedPtr subscription)
|
||||
Executor::execute_subscription(const rclcpp::SubscriptionBase::SharedPtr & subscription)
|
||||
{
|
||||
using rclcpp::dynamic_typesupport::DynamicMessage;
|
||||
|
||||
@@ -648,13 +654,15 @@ Executor::execute_subscription(rclcpp::SubscriptionBase::SharedPtr subscription)
|
||||
}
|
||||
|
||||
void
|
||||
Executor::execute_timer(rclcpp::TimerBase::SharedPtr timer, const std::shared_ptr<void> & data_ptr)
|
||||
Executor::execute_timer(
|
||||
const rclcpp::TimerBase::SharedPtr & timer,
|
||||
const std::shared_ptr<void> & data_ptr)
|
||||
{
|
||||
timer->execute_callback(data_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
Executor::execute_service(rclcpp::ServiceBase::SharedPtr service)
|
||||
Executor::execute_service(const rclcpp::ServiceBase::SharedPtr & service)
|
||||
{
|
||||
auto request_header = service->create_request_header();
|
||||
std::shared_ptr<void> request = service->create_request();
|
||||
@@ -666,7 +674,7 @@ Executor::execute_service(rclcpp::ServiceBase::SharedPtr service)
|
||||
}
|
||||
|
||||
void
|
||||
Executor::execute_client(rclcpp::ClientBase::SharedPtr client)
|
||||
Executor::execute_client(const rclcpp::ClientBase::SharedPtr & client)
|
||||
{
|
||||
auto request_header = client->create_request_header();
|
||||
std::shared_ptr<void> response = client->create_response();
|
||||
@@ -708,37 +716,37 @@ Executor::collect_entities()
|
||||
// from the wait set as necessary.
|
||||
current_collection_.timers.update(
|
||||
collection.timers,
|
||||
[this](auto timer) {wait_set_.add_timer(timer);},
|
||||
[this](auto timer) {wait_set_.remove_timer(timer);});
|
||||
[this](auto timer) {wait_set_.add_timer(std::move(timer));},
|
||||
[this](auto timer) {wait_set_.remove_timer(std::move(timer));});
|
||||
|
||||
current_collection_.subscriptions.update(
|
||||
collection.subscriptions,
|
||||
[this](auto subscription) {
|
||||
wait_set_.add_subscription(subscription, kDefaultSubscriptionMask);
|
||||
wait_set_.add_subscription(std::move(subscription), kDefaultSubscriptionMask);
|
||||
},
|
||||
[this](auto subscription) {
|
||||
wait_set_.remove_subscription(subscription, kDefaultSubscriptionMask);
|
||||
wait_set_.remove_subscription(std::move(subscription), kDefaultSubscriptionMask);
|
||||
});
|
||||
|
||||
current_collection_.clients.update(
|
||||
collection.clients,
|
||||
[this](auto client) {wait_set_.add_client(client);},
|
||||
[this](auto client) {wait_set_.remove_client(client);});
|
||||
[this](auto client) {wait_set_.add_client(std::move(client));},
|
||||
[this](auto client) {wait_set_.remove_client(std::move(client));});
|
||||
|
||||
current_collection_.services.update(
|
||||
collection.services,
|
||||
[this](auto service) {wait_set_.add_service(service);},
|
||||
[this](auto service) {wait_set_.remove_service(service);});
|
||||
[this](auto service) {wait_set_.add_service(std::move(service));},
|
||||
[this](auto service) {wait_set_.remove_service(std::move(service));});
|
||||
|
||||
current_collection_.guard_conditions.update(
|
||||
collection.guard_conditions,
|
||||
[this](auto guard_condition) {wait_set_.add_guard_condition(guard_condition);},
|
||||
[this](auto guard_condition) {wait_set_.remove_guard_condition(guard_condition);});
|
||||
[this](auto guard_condition) {wait_set_.add_guard_condition(std::move(guard_condition));},
|
||||
[this](auto guard_condition) {wait_set_.remove_guard_condition(std::move(guard_condition));});
|
||||
|
||||
current_collection_.waitables.update(
|
||||
collection.waitables,
|
||||
[this](auto waitable) {wait_set_.add_waitable(waitable);},
|
||||
[this](auto waitable) {wait_set_.remove_waitable(waitable);});
|
||||
[this](auto waitable) {wait_set_.add_waitable(std::move(waitable));},
|
||||
[this](auto waitable) {wait_set_.remove_waitable(std::move(waitable));});
|
||||
|
||||
// In the case that an entity already has an expired weak pointer
|
||||
// before being removed from the waitset, additionally prune the waitset.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
void
|
||||
rclcpp::spin_all(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr,
|
||||
std::chrono::nanoseconds max_duration)
|
||||
{
|
||||
rclcpp::ExecutorOptions options;
|
||||
@@ -27,7 +27,7 @@ rclcpp::spin_all(
|
||||
}
|
||||
|
||||
void
|
||||
rclcpp::spin_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
|
||||
rclcpp::spin_some(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr)
|
||||
{
|
||||
rclcpp::ExecutorOptions options;
|
||||
options.context = node_ptr->get_context();
|
||||
@@ -36,7 +36,7 @@ rclcpp::spin_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr
|
||||
}
|
||||
|
||||
void
|
||||
rclcpp::spin(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
|
||||
rclcpp::spin(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr)
|
||||
{
|
||||
rclcpp::ExecutorOptions options;
|
||||
options.context = node_ptr->get_context();
|
||||
@@ -47,13 +47,13 @@ rclcpp::spin(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
|
||||
}
|
||||
|
||||
void
|
||||
rclcpp::spin(rclcpp::Node::SharedPtr node_ptr)
|
||||
rclcpp::spin(const rclcpp::Node::SharedPtr & node_ptr)
|
||||
{
|
||||
rclcpp::spin(node_ptr->get_node_base_interface());
|
||||
}
|
||||
|
||||
void
|
||||
rclcpp::spin_all(rclcpp::Node::SharedPtr node_ptr, std::chrono::nanoseconds max_duration)
|
||||
rclcpp::spin_all(const rclcpp::Node::SharedPtr & node_ptr, std::chrono::nanoseconds max_duration)
|
||||
{
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_START
|
||||
rclcpp::spin_all(node_ptr->get_node_base_interface(), max_duration);
|
||||
@@ -61,7 +61,7 @@ rclcpp::spin_all(rclcpp::Node::SharedPtr node_ptr, std::chrono::nanoseconds max_
|
||||
}
|
||||
|
||||
void
|
||||
rclcpp::spin_some(rclcpp::Node::SharedPtr node_ptr)
|
||||
rclcpp::spin_some(const rclcpp::Node::SharedPtr & node_ptr)
|
||||
{
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_START
|
||||
rclcpp::spin_some(node_ptr->get_node_base_interface());
|
||||
|
||||
@@ -70,7 +70,7 @@ build_entities_collection(
|
||||
{
|
||||
collection.clear();
|
||||
|
||||
for (auto weak_group_ptr : callback_groups) {
|
||||
for (const auto & weak_group_ptr : callback_groups) {
|
||||
auto group_ptr = weak_group_ptr.lock();
|
||||
if (!group_ptr) {
|
||||
continue;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace executors
|
||||
{
|
||||
|
||||
ExecutorEntitiesCollector::ExecutorEntitiesCollector(
|
||||
std::shared_ptr<ExecutorNotifyWaitable> notify_waitable)
|
||||
const std::shared_ptr<ExecutorNotifyWaitable> & notify_waitable)
|
||||
: notify_waitable_(notify_waitable)
|
||||
{
|
||||
}
|
||||
@@ -47,7 +47,7 @@ ExecutorEntitiesCollector::~ExecutorEntitiesCollector()
|
||||
weak_group_it = remove_weak_callback_group(weak_group_it, manually_added_groups_);
|
||||
}
|
||||
|
||||
for (auto weak_node_ptr : pending_added_nodes_) {
|
||||
for (const auto & weak_node_ptr : pending_added_nodes_) {
|
||||
auto node_ptr = weak_node_ptr.lock();
|
||||
if (node_ptr) {
|
||||
node_ptr->get_associated_with_executor_atomic().store(false);
|
||||
@@ -56,7 +56,7 @@ ExecutorEntitiesCollector::~ExecutorEntitiesCollector()
|
||||
pending_added_nodes_.clear();
|
||||
pending_removed_nodes_.clear();
|
||||
|
||||
for (auto weak_group_ptr : pending_manually_added_groups_) {
|
||||
for (const auto & weak_group_ptr : pending_manually_added_groups_) {
|
||||
auto group_ptr = weak_group_ptr.lock();
|
||||
if (group_ptr) {
|
||||
group_ptr->get_associated_with_executor_atomic().store(false);
|
||||
@@ -83,7 +83,8 @@ ExecutorEntitiesCollector::has_pending() const
|
||||
}
|
||||
|
||||
void
|
||||
ExecutorEntitiesCollector::add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
|
||||
ExecutorEntitiesCollector::add_node(
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr)
|
||||
{
|
||||
// If the node already has an executor
|
||||
std::atomic_bool & has_executor = node_ptr->get_associated_with_executor_atomic();
|
||||
@@ -109,7 +110,7 @@ ExecutorEntitiesCollector::add_node(rclcpp::node_interfaces::NodeBaseInterface::
|
||||
|
||||
void
|
||||
ExecutorEntitiesCollector::remove_node(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_ptr)
|
||||
{
|
||||
std::atomic_bool & has_executor = node_ptr->get_associated_with_executor_atomic();
|
||||
if (!has_executor.exchange(false)) {
|
||||
@@ -133,7 +134,7 @@ ExecutorEntitiesCollector::remove_node(
|
||||
}
|
||||
|
||||
void
|
||||
ExecutorEntitiesCollector::add_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr)
|
||||
ExecutorEntitiesCollector::add_callback_group(const rclcpp::CallbackGroup::SharedPtr & group_ptr)
|
||||
{
|
||||
std::atomic_bool & has_executor = group_ptr->get_associated_with_executor_atomic();
|
||||
if (has_executor.exchange(true)) {
|
||||
@@ -158,7 +159,7 @@ ExecutorEntitiesCollector::add_callback_group(rclcpp::CallbackGroup::SharedPtr g
|
||||
}
|
||||
|
||||
void
|
||||
ExecutorEntitiesCollector::remove_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr)
|
||||
ExecutorEntitiesCollector::remove_callback_group(const rclcpp::CallbackGroup::SharedPtr & group_ptr)
|
||||
{
|
||||
if (!group_ptr->get_associated_with_executor_atomic().load()) {
|
||||
throw std::runtime_error("Callback group needs to be associated with an executor.");
|
||||
@@ -288,7 +289,7 @@ ExecutorEntitiesCollector::remove_weak_callback_group(
|
||||
|
||||
void
|
||||
ExecutorEntitiesCollector::add_callback_group_to_collection(
|
||||
rclcpp::CallbackGroup::SharedPtr group_ptr,
|
||||
const rclcpp::CallbackGroup::SharedPtr & group_ptr,
|
||||
CallbackGroupCollection & collection)
|
||||
{
|
||||
auto iter = collection.insert(group_ptr);
|
||||
@@ -305,7 +306,7 @@ ExecutorEntitiesCollector::add_callback_group_to_collection(
|
||||
void
|
||||
ExecutorEntitiesCollector::process_queues()
|
||||
{
|
||||
for (auto weak_node_ptr : pending_added_nodes_) {
|
||||
for (const auto & weak_node_ptr : pending_added_nodes_) {
|
||||
auto node_ptr = weak_node_ptr.lock();
|
||||
if (!node_ptr) {
|
||||
continue;
|
||||
@@ -320,7 +321,7 @@ ExecutorEntitiesCollector::process_queues()
|
||||
}
|
||||
pending_added_nodes_.clear();
|
||||
|
||||
for (auto weak_node_ptr : pending_removed_nodes_) {
|
||||
for (const auto & weak_node_ptr : pending_removed_nodes_) {
|
||||
auto node_it = weak_nodes_.find(weak_node_ptr);
|
||||
if (node_it != weak_nodes_.end()) {
|
||||
remove_weak_node(node_it);
|
||||
@@ -348,7 +349,7 @@ ExecutorEntitiesCollector::process_queues()
|
||||
}
|
||||
pending_removed_nodes_.clear();
|
||||
|
||||
for (auto weak_group_ptr : pending_manually_added_groups_) {
|
||||
for (const auto & weak_group_ptr : pending_manually_added_groups_) {
|
||||
auto group_ptr = weak_group_ptr.lock();
|
||||
if (group_ptr) {
|
||||
this->add_callback_group_to_collection(group_ptr, manually_added_groups_);
|
||||
@@ -363,7 +364,7 @@ ExecutorEntitiesCollector::process_queues()
|
||||
}
|
||||
pending_manually_added_groups_.clear();
|
||||
|
||||
for (auto weak_group_ptr : pending_manually_removed_groups_) {
|
||||
for (const auto & weak_group_ptr : pending_manually_removed_groups_) {
|
||||
auto group_ptr = weak_group_ptr.lock();
|
||||
if (group_ptr) {
|
||||
auto group_it = manually_added_groups_.find(group_ptr);
|
||||
@@ -386,7 +387,7 @@ ExecutorEntitiesCollector::add_automatically_associated_callback_groups(
|
||||
auto node = weak_node.lock();
|
||||
if (node) {
|
||||
node->for_each_callback_group(
|
||||
[this, node](rclcpp::CallbackGroup::SharedPtr group_ptr)
|
||||
[this, node](const rclcpp::CallbackGroup::SharedPtr & group_ptr)
|
||||
{
|
||||
if (!group_ptr->get_associated_with_executor_atomic().load() &&
|
||||
group_ptr->automatically_add_to_executor_with_node())
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace executors
|
||||
{
|
||||
|
||||
ExecutorNotifyWaitable::ExecutorNotifyWaitable(
|
||||
std::function<void(void)> on_execute_callback,
|
||||
const std::function<void(void)> & on_execute_callback,
|
||||
const rclcpp::Context::SharedPtr & context)
|
||||
: execute_callback_(on_execute_callback),
|
||||
guard_condition_(std::make_shared<rclcpp::GuardCondition>(context))
|
||||
@@ -144,13 +144,13 @@ ExecutorNotifyWaitable::take_data_by_entity_id([[maybe_unused]] size_t id)
|
||||
}
|
||||
|
||||
void
|
||||
ExecutorNotifyWaitable::set_on_ready_callback(std::function<void(size_t, int)> callback)
|
||||
ExecutorNotifyWaitable::set_on_ready_callback(std::function<void(size_t, int)> callback_in)
|
||||
{
|
||||
// The second argument of the callback could be used to identify which guard condition
|
||||
// triggered the event.
|
||||
// We could indicate which of the guard conditions was triggered, but the executor
|
||||
// is already going to check that.
|
||||
auto gc_callback = [callback](size_t count) {
|
||||
auto gc_callback = [callback = std::move(callback_in)](size_t count) {
|
||||
callback(count, 0);
|
||||
};
|
||||
|
||||
@@ -179,11 +179,12 @@ void
|
||||
ExecutorNotifyWaitable::set_execute_callback(std::function<void(void)> on_execute_callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(execute_mutex_);
|
||||
execute_callback_ = on_execute_callback;
|
||||
execute_callback_ = std::move(on_execute_callback);
|
||||
}
|
||||
|
||||
void
|
||||
ExecutorNotifyWaitable::add_guard_condition(rclcpp::GuardCondition::WeakPtr weak_guard_condition)
|
||||
ExecutorNotifyWaitable::add_guard_condition(
|
||||
const rclcpp::GuardCondition::WeakPtr & weak_guard_condition)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(guard_condition_mutex_);
|
||||
const auto & guard_condition = weak_guard_condition.lock();
|
||||
@@ -196,7 +197,8 @@ ExecutorNotifyWaitable::add_guard_condition(rclcpp::GuardCondition::WeakPtr weak
|
||||
}
|
||||
|
||||
void
|
||||
ExecutorNotifyWaitable::remove_guard_condition(rclcpp::GuardCondition::WeakPtr weak_guard_condition)
|
||||
ExecutorNotifyWaitable::remove_guard_condition(
|
||||
const rclcpp::GuardCondition::WeakPtr & weak_guard_condition)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(guard_condition_mutex_);
|
||||
const auto & guard_condition = weak_guard_condition.lock();
|
||||
|
||||
@@ -29,7 +29,7 @@ TimersManager::TimersManager(
|
||||
std::shared_ptr<rclcpp::Context> context,
|
||||
std::function<void(const rclcpp::TimerBase *, const std::shared_ptr<void> &)> on_ready_callback)
|
||||
: on_ready_callback_(on_ready_callback),
|
||||
context_(context)
|
||||
context_(std::move(context))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ TimersManager::~TimersManager()
|
||||
this->stop();
|
||||
}
|
||||
|
||||
void TimersManager::add_timer(rclcpp::TimerBase::SharedPtr timer)
|
||||
void TimersManager::add_timer(const rclcpp::TimerBase::SharedPtr & timer)
|
||||
{
|
||||
if (!timer) {
|
||||
throw std::invalid_argument("TimersManager::add_timer() trying to add nullptr timer");
|
||||
@@ -311,7 +311,7 @@ void TimersManager::clear()
|
||||
timers_cv_.notify_one();
|
||||
}
|
||||
|
||||
void TimersManager::remove_timer(TimerPtr timer)
|
||||
void TimersManager::remove_timer(const TimerPtr & timer)
|
||||
{
|
||||
bool removed = false;
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace rclcpp
|
||||
{
|
||||
GenericClient::GenericClient(
|
||||
rclcpp::node_interfaces::NodeBaseInterface * node_base,
|
||||
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr & node_graph,
|
||||
const std::string & service_name,
|
||||
const std::string & service_type,
|
||||
rcl_client_options_t & client_options)
|
||||
@@ -97,8 +97,8 @@ GenericClient::create_request_header()
|
||||
|
||||
void
|
||||
GenericClient::handle_response(
|
||||
std::shared_ptr<rmw_request_id_t> request_header,
|
||||
std::shared_ptr<void> response)
|
||||
const std::shared_ptr<rmw_request_id_t> & request_header,
|
||||
const std::shared_ptr<void> & response)
|
||||
{
|
||||
auto optional_pending_request =
|
||||
this->get_and_erase_pending_request(request_header->sequence_number);
|
||||
@@ -108,13 +108,13 @@ GenericClient::handle_response(
|
||||
auto & value = *optional_pending_request;
|
||||
if (std::holds_alternative<Promise>(value)) {
|
||||
auto & promise = std::get<Promise>(value);
|
||||
promise.set_value(std::move(response));
|
||||
promise.set_value(response);
|
||||
} else if (std::holds_alternative<CallbackTypeValueVariant>(value)) {
|
||||
auto & inner = std::get<CallbackTypeValueVariant>(value);
|
||||
const auto & callback = std::get<CallbackType>(inner);
|
||||
auto & promise = std::get<Promise>(inner);
|
||||
auto & future = std::get<SharedFuture>(inner);
|
||||
promise.set_value(std::move(response));
|
||||
promise.set_value(response);
|
||||
callback(std::move(future));
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ GenericClient::get_and_erase_pending_request(int64_t request_number)
|
||||
}
|
||||
|
||||
GenericClient::FutureAndRequestId
|
||||
GenericClient::async_send_request(const Request request)
|
||||
GenericClient::async_send_request(const Request & request)
|
||||
{
|
||||
Promise promise;
|
||||
auto future = promise.get_future();
|
||||
@@ -175,7 +175,7 @@ GenericClient::async_send_request(const Request request)
|
||||
}
|
||||
|
||||
int64_t
|
||||
GenericClient::async_send_request_impl(const Request request, CallbackInfoVariant value)
|
||||
GenericClient::async_send_request_impl(const Request & request, CallbackInfoVariant value)
|
||||
{
|
||||
int64_t sequence_number;
|
||||
std::lock_guard<std::mutex> lock(pending_requests_mutex_);
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
namespace rclcpp
|
||||
{
|
||||
GenericService::GenericService(
|
||||
std::shared_ptr<rcl_node_t> node_handle,
|
||||
const std::shared_ptr<rcl_node_t> & node_handle,
|
||||
const std::string & service_name,
|
||||
const std::string & service_type,
|
||||
GenericServiceCallback any_callback,
|
||||
rcl_service_options_t & service_options)
|
||||
: ServiceBase(node_handle),
|
||||
any_callback_(any_callback)
|
||||
any_callback_(std::move(any_callback))
|
||||
{
|
||||
const rosidl_service_type_support_t * service_ts;
|
||||
try {
|
||||
@@ -98,7 +98,7 @@ GenericService::GenericService(
|
||||
|
||||
bool
|
||||
GenericService::take_request(
|
||||
SharedRequest request_out,
|
||||
SharedRequest & request_out,
|
||||
rmw_request_id_t & request_id_out)
|
||||
{
|
||||
request_out = create_request();
|
||||
@@ -141,8 +141,8 @@ GenericService::create_request_header()
|
||||
|
||||
void
|
||||
GenericService::handle_request(
|
||||
std::shared_ptr<rmw_request_id_t> request_header,
|
||||
std::shared_ptr<void> request)
|
||||
const std::shared_ptr<rmw_request_id_t> & request_header,
|
||||
const std::shared_ptr<void> & request)
|
||||
{
|
||||
auto response = any_callback_.dispatch(
|
||||
this->shared_from_this(), request_header, request, create_response());
|
||||
|
||||
@@ -112,7 +112,7 @@ GuardCondition::add_to_wait_set(rcl_wait_set_t & wait_set)
|
||||
}
|
||||
|
||||
void
|
||||
GuardCondition::set_on_trigger_callback(std::function<void(size_t)> callback)
|
||||
GuardCondition::set_on_trigger_callback(const std::function<void(size_t)> & callback)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(reentrant_mutex_);
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ IntraProcessManager::~IntraProcessManager()
|
||||
|
||||
uint64_t
|
||||
IntraProcessManager::add_publisher(
|
||||
rclcpp::PublisherBase::SharedPtr publisher,
|
||||
rclcpp::experimental::buffers::IntraProcessBufferBase::SharedPtr buffer)
|
||||
const rclcpp::PublisherBase::SharedPtr & publisher,
|
||||
const rclcpp::experimental::buffers::IntraProcessBufferBase::SharedPtr & buffer)
|
||||
{
|
||||
std::unique_lock<std::shared_timed_mutex> lock(mutex_);
|
||||
|
||||
@@ -51,6 +51,9 @@ IntraProcessManager::add_publisher(
|
||||
}
|
||||
}
|
||||
|
||||
// Add GID to publisher info mapping for fast lookups (stores both ID and weak_ptr)
|
||||
gid_to_publisher_info_[publisher->get_gid()] = {pub_id, publisher};
|
||||
|
||||
// Initialize the subscriptions storage for this publisher.
|
||||
pub_to_subs_[pub_id] = SplittedSubscriptions();
|
||||
|
||||
@@ -98,6 +101,24 @@ IntraProcessManager::remove_publisher(uint64_t intra_process_publisher_id)
|
||||
{
|
||||
std::unique_lock<std::shared_timed_mutex> lock(mutex_);
|
||||
|
||||
// Remove GID to publisher info mapping.
|
||||
// First try via the publisher's own GID (fast path).
|
||||
auto pub_it = publishers_.find(intra_process_publisher_id);
|
||||
if (pub_it != publishers_.end()) {
|
||||
auto publisher = pub_it->second.lock();
|
||||
if (publisher) {
|
||||
gid_to_publisher_info_.erase(publisher->get_gid());
|
||||
} else {
|
||||
// Publisher weak_ptr already expired, fall back to linear scan by pub_id.
|
||||
for (auto git = gid_to_publisher_info_.begin(); git != gid_to_publisher_info_.end(); ++git) {
|
||||
if (git->second.pub_id == intra_process_publisher_id) {
|
||||
gid_to_publisher_info_.erase(git);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishers_.erase(intra_process_publisher_id);
|
||||
publisher_buffers_.erase(intra_process_publisher_id);
|
||||
pub_to_subs_.erase(intra_process_publisher_id);
|
||||
@@ -108,16 +129,15 @@ IntraProcessManager::matches_any_publishers(const rmw_gid_t * id) const
|
||||
{
|
||||
std::shared_lock<std::shared_timed_mutex> lock(mutex_);
|
||||
|
||||
for (auto & publisher_pair : publishers_) {
|
||||
auto publisher = publisher_pair.second.lock();
|
||||
if (!publisher) {
|
||||
continue;
|
||||
}
|
||||
if (*publisher.get() == id) {
|
||||
return true;
|
||||
}
|
||||
// Single O(1) hash map lookup - struct contains both ID and weak_ptr
|
||||
auto it = gid_to_publisher_info_.find(*id);
|
||||
if (it == gid_to_publisher_info_.end()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
// Verify the publisher still exists by checking the weak_ptr
|
||||
auto publisher = it->second.publisher.lock();
|
||||
return publisher != nullptr;
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -197,8 +217,8 @@ IntraProcessManager::insert_sub_id_for_pub(
|
||||
|
||||
bool
|
||||
IntraProcessManager::can_communicate(
|
||||
rclcpp::PublisherBase::SharedPtr pub,
|
||||
rclcpp::experimental::SubscriptionIntraProcessBase::SharedPtr sub) const
|
||||
const rclcpp::PublisherBase::SharedPtr & pub,
|
||||
const rclcpp::experimental::SubscriptionIntraProcessBase::SharedPtr & sub) const
|
||||
{
|
||||
// publisher and subscription must be on the same topic
|
||||
if (strcmp(pub->get_topic_name(), sub->get_topic_name()) != 0) {
|
||||
|
||||
@@ -574,7 +574,7 @@ Node::get_graph_event()
|
||||
|
||||
void
|
||||
Node::wait_for_graph_change(
|
||||
rclcpp::Event::SharedPtr event,
|
||||
const rclcpp::Event::SharedPtr & event,
|
||||
std::chrono::nanoseconds timeout)
|
||||
{
|
||||
node_graph_->wait_for_graph_change(event, timeout);
|
||||
@@ -695,7 +695,7 @@ Node::create_generic_client(
|
||||
const std::string & service_name,
|
||||
const std::string & service_type,
|
||||
const rclcpp::QoS & qos,
|
||||
rclcpp::CallbackGroup::SharedPtr group)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group)
|
||||
{
|
||||
return rclcpp::create_generic_client(
|
||||
node_base_,
|
||||
|
||||
@@ -42,13 +42,13 @@ NodeBase::NodeBase(
|
||||
bool use_intra_process_default,
|
||||
bool enable_topic_statistics_default,
|
||||
rclcpp::CallbackGroup::SharedPtr default_callback_group)
|
||||
: context_(context),
|
||||
: context_(std::move(context)),
|
||||
use_intra_process_default_(use_intra_process_default),
|
||||
enable_topic_statistics_default_(enable_topic_statistics_default),
|
||||
node_handle_(nullptr),
|
||||
default_callback_group_(default_callback_group),
|
||||
default_callback_group_(std::move(default_callback_group)),
|
||||
associated_with_executor_(false),
|
||||
notify_guard_condition_(std::make_shared<rclcpp::GuardCondition>(context)),
|
||||
notify_guard_condition_(std::make_shared<rclcpp::GuardCondition>(context_)),
|
||||
notify_guard_condition_is_valid_(false)
|
||||
{
|
||||
// Create the rcl node and store it in a shared_ptr with a custom destructor.
|
||||
|
||||
@@ -26,11 +26,11 @@ NodeClock::NodeClock(
|
||||
rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services,
|
||||
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
|
||||
rcl_clock_type_t clock_type)
|
||||
: node_base_(node_base),
|
||||
node_topics_(node_topics),
|
||||
node_graph_(node_graph),
|
||||
node_services_(node_services),
|
||||
node_logging_(node_logging),
|
||||
: node_base_(std::move(node_base)),
|
||||
node_topics_(std::move(node_topics)),
|
||||
node_graph_(std::move(node_graph)),
|
||||
node_services_(std::move(node_services)),
|
||||
node_logging_(std::move(node_logging)),
|
||||
clock_(std::make_shared<rclcpp::Clock>(clock_type))
|
||||
{}
|
||||
|
||||
|
||||
@@ -645,8 +645,9 @@ std::vector<rclcpp::TopicEndpointInfo>
|
||||
convert_to_topic_info_list(const rcl_topic_endpoint_info_array_t & info_array)
|
||||
{
|
||||
std::vector<rclcpp::TopicEndpointInfo> topic_info_list;
|
||||
topic_info_list.reserve(info_array.size);
|
||||
for (size_t i = 0; i < info_array.size; ++i) {
|
||||
topic_info_list.push_back(rclcpp::TopicEndpointInfo(info_array.info_array[i]));
|
||||
topic_info_list.emplace_back(info_array.info_array[i]);
|
||||
}
|
||||
return topic_info_list;
|
||||
}
|
||||
@@ -759,8 +760,9 @@ std::vector<rclcpp::ServiceEndpointInfo>
|
||||
convert_to_service_info_list(const rcl_service_endpoint_info_array_t & info_array)
|
||||
{
|
||||
std::vector<rclcpp::ServiceEndpointInfo> service_info_list;
|
||||
service_info_list.reserve(info_array.size);
|
||||
for (size_t i = 0; i < info_array.size; ++i) {
|
||||
service_info_list.push_back(rclcpp::ServiceEndpointInfo(info_array.info_array[i]));
|
||||
service_info_list.emplace_back(info_array.info_array[i]);
|
||||
}
|
||||
return service_info_list;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
using rclcpp::node_interfaces::NodeLogging;
|
||||
|
||||
NodeLogging::NodeLogging(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base)
|
||||
NodeLogging::NodeLogging(const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_base)
|
||||
: node_base_(node_base)
|
||||
{
|
||||
logger_ = rclcpp::get_logger(NodeLogging::get_logger_name());
|
||||
@@ -41,7 +41,7 @@ NodeLogging::get_logger_name() const
|
||||
}
|
||||
|
||||
void NodeLogging::create_logger_services(
|
||||
node_interfaces::NodeServicesInterface::SharedPtr node_services)
|
||||
const node_interfaces::NodeServicesInterface::SharedPtr & node_services)
|
||||
{
|
||||
rclcpp::ServicesQoS qos_profile;
|
||||
const std::string node_name = node_base_->get_name();
|
||||
@@ -51,8 +51,8 @@ void NodeLogging::create_logger_services(
|
||||
node_base_, node_services,
|
||||
node_name + "/get_logger_levels",
|
||||
[](
|
||||
const std::shared_ptr<rmw_request_id_t>,
|
||||
const std::shared_ptr<rcl_interfaces::srv::GetLoggerLevels::Request> request,
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<rcl_interfaces::srv::GetLoggerLevels::Request> & request,
|
||||
std::shared_ptr<rcl_interfaces::srv::GetLoggerLevels::Response> response)
|
||||
{
|
||||
for (auto & name : request->names) {
|
||||
@@ -73,8 +73,8 @@ void NodeLogging::create_logger_services(
|
||||
node_base_, node_services,
|
||||
node_name + "/set_logger_levels",
|
||||
[](
|
||||
const std::shared_ptr<rmw_request_id_t>,
|
||||
const std::shared_ptr<rcl_interfaces::srv::SetLoggerLevels::Request> request,
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<rcl_interfaces::srv::SetLoggerLevels::Request> & request,
|
||||
std::shared_ptr<rcl_interfaces::srv::SetLoggerLevels::Response> response)
|
||||
{
|
||||
rcl_interfaces::msg::SetLoggerLevelsResult result;
|
||||
|
||||
@@ -29,13 +29,13 @@ NodeTimeSource::NodeTimeSource(
|
||||
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters,
|
||||
const rclcpp::QoS & qos,
|
||||
bool use_clock_thread)
|
||||
: node_base_(node_base),
|
||||
node_topics_(node_topics),
|
||||
node_graph_(node_graph),
|
||||
node_services_(node_services),
|
||||
node_logging_(node_logging),
|
||||
node_clock_(node_clock),
|
||||
node_parameters_(node_parameters),
|
||||
: node_base_(std::move(node_base)),
|
||||
node_topics_(std::move(node_topics)),
|
||||
node_graph_(std::move(node_graph)),
|
||||
node_services_(std::move(node_services)),
|
||||
node_logging_(std::move(node_logging)),
|
||||
node_clock_(std::move(node_clock)),
|
||||
node_parameters_(std::move(node_parameters)),
|
||||
time_source_(qos, use_clock_thread)
|
||||
{
|
||||
time_source_.attachNode(
|
||||
|
||||
@@ -59,11 +59,11 @@ public:
|
||||
|
||||
NodeTypeDescriptionsImpl(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
|
||||
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
|
||||
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters,
|
||||
rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services)
|
||||
const rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr & node_logging,
|
||||
const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node_parameters,
|
||||
const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr & node_services)
|
||||
: logger_(node_logging->get_logger()),
|
||||
node_base_(node_base)
|
||||
node_base_(std::move(node_base))
|
||||
{
|
||||
rclcpp::ParameterValue enable_param;
|
||||
const std::string enable_param_name = "start_type_description_service";
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
}
|
||||
|
||||
if (enable_param.get<bool>()) {
|
||||
auto * rcl_node = node_base->get_rcl_node_handle();
|
||||
auto * rcl_node = node_base_->get_rcl_node_handle();
|
||||
std::shared_ptr<rcl_service_t> rcl_srv(
|
||||
new rcl_service_t,
|
||||
[rcl_node, logger = this->logger_](rcl_service_t * service)
|
||||
@@ -121,9 +121,9 @@ public:
|
||||
rclcpp::AnyServiceCallback<ServiceT> cb;
|
||||
cb.set(
|
||||
[this](
|
||||
std::shared_ptr<rmw_request_id_t> header,
|
||||
std::shared_ptr<ServiceT::Request> request,
|
||||
std::shared_ptr<ServiceT::Response> response
|
||||
const std::shared_ptr<rmw_request_id_t> & header,
|
||||
const std::shared_ptr<ServiceT::Request> & request,
|
||||
const std::shared_ptr<ServiceT::Response> & response
|
||||
) {
|
||||
rcl_node_type_description_service_handle_request(
|
||||
node_base_->get_rcl_node_handle(),
|
||||
@@ -144,10 +144,10 @@ public:
|
||||
};
|
||||
|
||||
NodeTypeDescriptions::NodeTypeDescriptions(
|
||||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
|
||||
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
|
||||
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters,
|
||||
rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services)
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_base,
|
||||
const rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr & node_logging,
|
||||
const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node_parameters,
|
||||
const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr & node_services)
|
||||
: impl_(new NodeTypeDescriptionsImpl(
|
||||
node_base,
|
||||
node_logging,
|
||||
|
||||
@@ -143,7 +143,7 @@ NodeOptions::context() const
|
||||
}
|
||||
|
||||
NodeOptions &
|
||||
NodeOptions::context(rclcpp::Context::SharedPtr context)
|
||||
NodeOptions::context(const rclcpp::Context::SharedPtr & context)
|
||||
{
|
||||
this->context_ = context;
|
||||
return *this;
|
||||
|
||||
@@ -30,13 +30,13 @@ using rclcpp::AsyncParametersClient;
|
||||
using rclcpp::SyncParametersClient;
|
||||
|
||||
AsyncParametersClient::AsyncParametersClient(
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface,
|
||||
const rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics_interface,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph_interface,
|
||||
const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services_interface,
|
||||
const rclcpp::node_interfaces::NodeBaseInterface::SharedPtr & node_base_interface,
|
||||
const rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr & node_topics_interface,
|
||||
const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr & node_graph_interface,
|
||||
const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr & node_services_interface,
|
||||
const std::string & remote_node_name,
|
||||
const rclcpp::QoS & qos_profile,
|
||||
rclcpp::CallbackGroup::SharedPtr group)
|
||||
const rclcpp::CallbackGroup::SharedPtr & group)
|
||||
: node_topics_interface_(node_topics_interface)
|
||||
{
|
||||
if (remote_node_name != "") {
|
||||
@@ -107,9 +107,9 @@ AsyncParametersClient::AsyncParametersClient(
|
||||
std::shared_future<std::vector<rclcpp::Parameter>>
|
||||
AsyncParametersClient::get_parameters(
|
||||
const std::vector<std::string> & names,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<std::vector<rclcpp::Parameter>>)
|
||||
> callback)
|
||||
> & callback)
|
||||
{
|
||||
auto promise_result =
|
||||
std::make_shared<std::promise<std::vector<rclcpp::Parameter>>>();
|
||||
@@ -147,9 +147,9 @@ AsyncParametersClient::get_parameters(
|
||||
std::shared_future<std::vector<rcl_interfaces::msg::ParameterDescriptor>>
|
||||
AsyncParametersClient::describe_parameters(
|
||||
const std::vector<std::string> & names,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<std::vector<rcl_interfaces::msg::ParameterDescriptor>>)
|
||||
> callback)
|
||||
> & callback)
|
||||
{
|
||||
auto promise_result =
|
||||
std::make_shared<std::promise<std::vector<rcl_interfaces::msg::ParameterDescriptor>>>();
|
||||
@@ -176,9 +176,9 @@ AsyncParametersClient::describe_parameters(
|
||||
std::shared_future<std::vector<rclcpp::ParameterType>>
|
||||
AsyncParametersClient::get_parameter_types(
|
||||
const std::vector<std::string> & names,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<std::vector<rclcpp::ParameterType>>)
|
||||
> callback)
|
||||
> & callback)
|
||||
{
|
||||
auto promise_result =
|
||||
std::make_shared<std::promise<std::vector<rclcpp::ParameterType>>>();
|
||||
@@ -210,9 +210,9 @@ AsyncParametersClient::get_parameter_types(
|
||||
std::shared_future<std::vector<rcl_interfaces::msg::SetParametersResult>>
|
||||
AsyncParametersClient::set_parameters(
|
||||
const std::vector<rclcpp::Parameter> & parameters,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<std::vector<rcl_interfaces::msg::SetParametersResult>>)
|
||||
> callback)
|
||||
> & callback)
|
||||
{
|
||||
auto promise_result =
|
||||
std::make_shared<std::promise<std::vector<rcl_interfaces::msg::SetParametersResult>>>();
|
||||
@@ -243,9 +243,9 @@ AsyncParametersClient::set_parameters(
|
||||
std::shared_future<rcl_interfaces::msg::SetParametersResult>
|
||||
AsyncParametersClient::set_parameters_atomically(
|
||||
const std::vector<rclcpp::Parameter> & parameters,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<rcl_interfaces::msg::SetParametersResult>)
|
||||
> callback)
|
||||
> & callback)
|
||||
{
|
||||
auto promise_result =
|
||||
std::make_shared<std::promise<rcl_interfaces::msg::SetParametersResult>>();
|
||||
@@ -322,9 +322,9 @@ std::shared_future<rcl_interfaces::msg::ListParametersResult>
|
||||
AsyncParametersClient::list_parameters(
|
||||
const std::vector<std::string> & prefixes,
|
||||
uint64_t depth,
|
||||
std::function<
|
||||
const std::function<
|
||||
void(std::shared_future<rcl_interfaces::msg::ListParametersResult>)
|
||||
> callback)
|
||||
> & callback)
|
||||
{
|
||||
auto promise_result =
|
||||
std::make_shared<std::promise<rcl_interfaces::msg::ListParametersResult>>();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace rclcpp
|
||||
|
||||
ParameterEventCallbackHandle::SharedPtr
|
||||
ParameterEventHandler::add_parameter_event_callback(
|
||||
ParameterEventCallbackType callback)
|
||||
const ParameterEventCallbackType & callback)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(callbacks_->mutex_);
|
||||
auto handle = std::make_shared<ParameterEventCallbackHandle>();
|
||||
@@ -39,7 +39,7 @@ ParameterEventHandler::add_parameter_event_callback(
|
||||
|
||||
void
|
||||
ParameterEventHandler::remove_parameter_event_callback(
|
||||
ParameterEventCallbackHandle::SharedPtr callback_handle)
|
||||
const ParameterEventCallbackHandle::SharedPtr & callback_handle)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(callbacks_->mutex_);
|
||||
auto it = std::find_if(
|
||||
@@ -58,7 +58,7 @@ ParameterEventHandler::remove_parameter_event_callback(
|
||||
ParameterCallbackHandle::SharedPtr
|
||||
ParameterEventHandler::add_parameter_callback(
|
||||
const std::string & parameter_name,
|
||||
ParameterCallbackType callback,
|
||||
const ParameterCallbackType & callback,
|
||||
const std::string & node_name)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(callbacks_->mutex_);
|
||||
@@ -108,7 +108,7 @@ ParameterEventHandler::configure_nodes_filter(const std::vector<std::string> & n
|
||||
|
||||
void
|
||||
ParameterEventHandler::remove_parameter_callback(
|
||||
ParameterCallbackHandle::SharedPtr callback_handle)
|
||||
const ParameterCallbackHandle::SharedPtr & callback_handle)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(callbacks_->mutex_);
|
||||
auto handle = callback_handle.get();
|
||||
|
||||
@@ -26,13 +26,13 @@ ParameterEventsFilter::ParameterEventsFilter(
|
||||
std::shared_ptr<const rcl_interfaces::msg::ParameterEvent> event,
|
||||
const std::vector<std::string> & names,
|
||||
const std::vector<EventType> & types)
|
||||
: event_(event)
|
||||
: event_(std::move(event))
|
||||
{
|
||||
if (!event) {
|
||||
if (!event_) {
|
||||
throw std::invalid_argument("event cannot be null");
|
||||
}
|
||||
if (std::find(types.begin(), types.end(), EventType::NEW) != types.end()) {
|
||||
for (auto & new_parameter : event->new_parameters) {
|
||||
for (auto & new_parameter : event_->new_parameters) {
|
||||
if (std::find(names.begin(), names.end(), new_parameter.name) != names.end()) {
|
||||
result_.push_back(
|
||||
EventPair(EventType::NEW, &new_parameter));
|
||||
@@ -40,7 +40,7 @@ ParameterEventsFilter::ParameterEventsFilter(
|
||||
}
|
||||
}
|
||||
if (std::find(types.begin(), types.end(), EventType::CHANGED) != types.end()) {
|
||||
for (auto & changed_parameter : event->changed_parameters) {
|
||||
for (auto & changed_parameter : event_->changed_parameters) {
|
||||
if (std::find(names.begin(), names.end(), changed_parameter.name) != names.end()) {
|
||||
result_.push_back(
|
||||
EventPair(EventType::CHANGED, &changed_parameter));
|
||||
@@ -48,7 +48,7 @@ ParameterEventsFilter::ParameterEventsFilter(
|
||||
}
|
||||
}
|
||||
if (std::find(types.begin(), types.end(), EventType::DELETED) != types.end()) {
|
||||
for (auto & deleted_parameter : event->deleted_parameters) {
|
||||
for (auto & deleted_parameter : event_->deleted_parameters) {
|
||||
if (std::find(names.begin(), names.end(), deleted_parameter.name) != names.end()) {
|
||||
result_.push_back(
|
||||
EventPair(EventType::DELETED, &deleted_parameter));
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
using rclcpp::ParameterService;
|
||||
|
||||
ParameterService::ParameterService(
|
||||
const std::shared_ptr<rclcpp::node_interfaces::NodeBaseInterface> node_base,
|
||||
const std::shared_ptr<rclcpp::node_interfaces::NodeServicesInterface> node_services,
|
||||
const std::shared_ptr<rclcpp::node_interfaces::NodeBaseInterface> & node_base,
|
||||
const std::shared_ptr<rclcpp::node_interfaces::NodeServicesInterface> & node_services,
|
||||
rclcpp::node_interfaces::NodeParametersInterface * node_params,
|
||||
const rclcpp::QoS & qos_profile)
|
||||
{
|
||||
@@ -37,8 +37,8 @@ ParameterService::ParameterService(
|
||||
node_base, node_services,
|
||||
node_name + "/" + parameter_service_names::get_parameters,
|
||||
[node_params](
|
||||
const std::shared_ptr<rmw_request_id_t>,
|
||||
const std::shared_ptr<rcl_interfaces::srv::GetParameters::Request> request,
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<rcl_interfaces::srv::GetParameters::Request> & request,
|
||||
std::shared_ptr<rcl_interfaces::srv::GetParameters::Response> response)
|
||||
{
|
||||
try {
|
||||
@@ -58,8 +58,8 @@ ParameterService::ParameterService(
|
||||
node_base, node_services,
|
||||
node_name + "/" + parameter_service_names::get_parameter_types,
|
||||
[node_params](
|
||||
const std::shared_ptr<rmw_request_id_t>,
|
||||
const std::shared_ptr<rcl_interfaces::srv::GetParameterTypes::Request> request,
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<rcl_interfaces::srv::GetParameterTypes::Request> & request,
|
||||
std::shared_ptr<rcl_interfaces::srv::GetParameterTypes::Response> response)
|
||||
{
|
||||
try {
|
||||
@@ -79,8 +79,8 @@ ParameterService::ParameterService(
|
||||
node_base, node_services,
|
||||
node_name + "/" + parameter_service_names::set_parameters,
|
||||
[node_params](
|
||||
const std::shared_ptr<rmw_request_id_t>,
|
||||
const std::shared_ptr<rcl_interfaces::srv::SetParameters::Request> request,
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<rcl_interfaces::srv::SetParameters::Request> & request,
|
||||
std::shared_ptr<rcl_interfaces::srv::SetParameters::Response> response)
|
||||
{
|
||||
// Set parameters one-by-one, since there's no way to return a partial result if
|
||||
@@ -104,8 +104,8 @@ ParameterService::ParameterService(
|
||||
node_base, node_services,
|
||||
node_name + "/" + parameter_service_names::set_parameters_atomically,
|
||||
[node_params](
|
||||
const std::shared_ptr<rmw_request_id_t>,
|
||||
const std::shared_ptr<rcl_interfaces::srv::SetParametersAtomically::Request> request,
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<rcl_interfaces::srv::SetParametersAtomically::Request> & request,
|
||||
std::shared_ptr<rcl_interfaces::srv::SetParametersAtomically::Response> response)
|
||||
{
|
||||
std::vector<rclcpp::Parameter> pvariants;
|
||||
@@ -131,8 +131,8 @@ ParameterService::ParameterService(
|
||||
node_base, node_services,
|
||||
node_name + "/" + parameter_service_names::describe_parameters,
|
||||
[node_params](
|
||||
const std::shared_ptr<rmw_request_id_t>,
|
||||
const std::shared_ptr<rcl_interfaces::srv::DescribeParameters::Request> request,
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<rcl_interfaces::srv::DescribeParameters::Request> & request,
|
||||
std::shared_ptr<rcl_interfaces::srv::DescribeParameters::Response> response)
|
||||
{
|
||||
try {
|
||||
@@ -148,8 +148,8 @@ ParameterService::ParameterService(
|
||||
node_base, node_services,
|
||||
node_name + "/" + parameter_service_names::list_parameters,
|
||||
[node_params](
|
||||
const std::shared_ptr<rmw_request_id_t>,
|
||||
const std::shared_ptr<rcl_interfaces::srv::ListParameters::Request> request,
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<rcl_interfaces::srv::ListParameters::Request> & request,
|
||||
std::shared_ptr<rcl_interfaces::srv::ListParameters::Response> response)
|
||||
{
|
||||
auto result = node_params->list_parameters(request->prefixes, request->depth);
|
||||
|
||||
@@ -344,7 +344,7 @@ PublisherBase::operator==(const rmw_gid_t * gid) const
|
||||
void
|
||||
PublisherBase::setup_intra_process(
|
||||
uint64_t intra_process_publisher_id,
|
||||
IntraProcessManagerSharedPtr ipm)
|
||||
const IntraProcessManagerSharedPtr & ipm)
|
||||
{
|
||||
intra_process_publisher_id_ = intra_process_publisher_id;
|
||||
weak_ipm_ = ipm;
|
||||
@@ -396,10 +396,10 @@ std::vector<rclcpp::NetworkFlowEndpoint> PublisherBase::get_network_flow_endpoin
|
||||
}
|
||||
|
||||
std::vector<rclcpp::NetworkFlowEndpoint> network_flow_endpoint_vector;
|
||||
network_flow_endpoint_vector.reserve(network_flow_endpoint_array.size);
|
||||
for (size_t i = 0; i < network_flow_endpoint_array.size; ++i) {
|
||||
network_flow_endpoint_vector.push_back(
|
||||
rclcpp::NetworkFlowEndpoint(
|
||||
network_flow_endpoint_array.network_flow_endpoint[i]));
|
||||
network_flow_endpoint_vector.emplace_back(
|
||||
network_flow_endpoint_array.network_flow_endpoint[i]);
|
||||
}
|
||||
|
||||
ret = rcl_network_flow_endpoint_array_fini(&network_flow_endpoint_array);
|
||||
|
||||
@@ -60,7 +60,7 @@ QosOverridingOptions::with_default_policies(
|
||||
QosCallback validation_callback,
|
||||
std::string id)
|
||||
{
|
||||
return QosOverridingOptions{kDefaultPolicies, validation_callback, id};
|
||||
return QosOverridingOptions{kDefaultPolicies, std::move(validation_callback), id};
|
||||
}
|
||||
|
||||
const std::string &
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace rclcpp
|
||||
{
|
||||
|
||||
Rate::Rate(
|
||||
const double rate, Clock::SharedPtr clock)
|
||||
const double rate, const Clock::SharedPtr & clock)
|
||||
: clock_(clock), period_(0, 0), last_interval_(clock_->now())
|
||||
{
|
||||
if (rate <= 0.0) {
|
||||
@@ -31,7 +31,7 @@ Rate::Rate(
|
||||
}
|
||||
|
||||
Rate::Rate(
|
||||
const Duration & period, Clock::SharedPtr clock)
|
||||
const Duration & period, const Clock::SharedPtr & clock)
|
||||
: clock_(clock), period_(period), last_interval_(clock_->now())
|
||||
{
|
||||
if (period <= Duration(0, 0)) {
|
||||
|
||||
@@ -70,12 +70,12 @@ SerializedMessage::SerializedMessage(const rcl_serialized_message_t & other)
|
||||
copy_rcl_message(other, serialized_message_);
|
||||
}
|
||||
|
||||
SerializedMessage::SerializedMessage(SerializedMessage && other)
|
||||
SerializedMessage::SerializedMessage(SerializedMessage && other) noexcept
|
||||
: serialized_message_(
|
||||
std::exchange(other.serialized_message_, rmw_get_zero_initialized_serialized_message()))
|
||||
{}
|
||||
|
||||
SerializedMessage::SerializedMessage(rcl_serialized_message_t && other)
|
||||
SerializedMessage::SerializedMessage(rcl_serialized_message_t && other) noexcept
|
||||
: serialized_message_(
|
||||
std::exchange(other, rmw_get_zero_initialized_serialized_message()))
|
||||
{}
|
||||
@@ -98,7 +98,7 @@ SerializedMessage & SerializedMessage::operator=(const rcl_serialized_message_t
|
||||
return *this;
|
||||
}
|
||||
|
||||
SerializedMessage & SerializedMessage::operator=(SerializedMessage && other)
|
||||
SerializedMessage & SerializedMessage::operator=(SerializedMessage && other) noexcept
|
||||
{
|
||||
if (this != &other) {
|
||||
if (nullptr != serialized_message_.buffer) {
|
||||
@@ -116,7 +116,7 @@ SerializedMessage & SerializedMessage::operator=(SerializedMessage && other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
SerializedMessage & SerializedMessage::operator=(rcl_serialized_message_t && other)
|
||||
SerializedMessage & SerializedMessage::operator=(rcl_serialized_message_t && other) noexcept
|
||||
{
|
||||
if (&serialized_message_ != &other) {
|
||||
if (nullptr != serialized_message_.buffer) {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
using rclcpp::ServiceBase;
|
||||
|
||||
ServiceBase::ServiceBase(std::shared_ptr<rcl_node_t> node_handle)
|
||||
ServiceBase::ServiceBase(const std::shared_ptr<rcl_node_t> & node_handle)
|
||||
: node_handle_(node_handle),
|
||||
node_logger_(rclcpp::get_node_logger(node_handle_.get()))
|
||||
{}
|
||||
|
||||
@@ -259,7 +259,7 @@ SignalHandler::deferred_signal_handler()
|
||||
int signum = signal_number_.load();
|
||||
RCLCPP_INFO(get_logger(), "signal_handler(signum=%d)", signum);
|
||||
RCLCPP_DEBUG(get_logger(), "deferred_signal_handler(): shutting down");
|
||||
for (auto context_ptr : rclcpp::get_contexts()) {
|
||||
for (const auto & context_ptr : rclcpp::get_contexts()) {
|
||||
if (context_ptr->get_init_options().shutdown_on_signal) {
|
||||
RCLCPP_DEBUG(
|
||||
get_logger(),
|
||||
|
||||
@@ -323,7 +323,7 @@ SubscriptionBase::setup_intra_process(
|
||||
IntraProcessManagerWeakPtr weak_ipm)
|
||||
{
|
||||
intra_process_subscription_id_ = intra_process_subscription_id;
|
||||
weak_ipm_ = weak_ipm;
|
||||
weak_ipm_ = std::move(weak_ipm);
|
||||
use_intra_process_ = true;
|
||||
}
|
||||
|
||||
@@ -449,11 +449,11 @@ SubscriptionBase::get_network_flow_endpoints() const
|
||||
}
|
||||
|
||||
std::vector<rclcpp::NetworkFlowEndpoint> network_flow_endpoint_vector;
|
||||
network_flow_endpoint_vector.reserve(network_flow_endpoint_array.size);
|
||||
for (size_t i = 0; i < network_flow_endpoint_array.size; ++i) {
|
||||
network_flow_endpoint_vector.push_back(
|
||||
rclcpp::NetworkFlowEndpoint(
|
||||
network_flow_endpoint_vector.emplace_back(
|
||||
network_flow_endpoint_array.
|
||||
network_flow_endpoint[i]));
|
||||
network_flow_endpoint[i]);
|
||||
}
|
||||
|
||||
ret = rcl_network_flow_endpoint_array_fini(&network_flow_endpoint_array);
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
// Attach a clock
|
||||
void attachClock(rclcpp::Clock::SharedPtr clock)
|
||||
void attachClock(const rclcpp::Clock::SharedPtr & clock)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> clock_guard(clock->get_clock_mutex());
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
}
|
||||
|
||||
// Detach a clock
|
||||
void detachClock(rclcpp::Clock::SharedPtr clock)
|
||||
void detachClock(const rclcpp::Clock::SharedPtr & clock)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(clock_list_lock_);
|
||||
auto removed = associated_clocks_.erase(clock);
|
||||
@@ -108,9 +108,9 @@ public:
|
||||
|
||||
// Internal helper function used inside iterators
|
||||
static void set_clock(
|
||||
const builtin_interfaces::msg::Time::SharedPtr msg,
|
||||
const builtin_interfaces::msg::Time::SharedPtr & msg,
|
||||
bool set_ros_time_enabled,
|
||||
rclcpp::Clock::SharedPtr clock)
|
||||
const rclcpp::Clock::SharedPtr & clock)
|
||||
{
|
||||
std::lock_guard<std::mutex> clock_guard(clock->get_clock_mutex());
|
||||
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
|
||||
// Internal helper function
|
||||
void set_all_clocks(
|
||||
const builtin_interfaces::msg::Time::SharedPtr msg,
|
||||
const builtin_interfaces::msg::Time::SharedPtr & msg,
|
||||
bool set_ros_time_enabled)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(clock_list_lock_);
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
}
|
||||
|
||||
// Cache the last clock message received
|
||||
void cache_last_msg(std::shared_ptr<const rosgraph_msgs::msg::Clock> msg)
|
||||
void cache_last_msg(const std::shared_ptr<const rosgraph_msgs::msg::Clock> & msg)
|
||||
{
|
||||
last_time_msg_ = std::make_shared<builtin_interfaces::msg::Time>(msg->clock);
|
||||
}
|
||||
@@ -237,13 +237,13 @@ public:
|
||||
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters_interface)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(node_base_lock_);
|
||||
node_base_ = node_base_interface;
|
||||
node_topics_ = node_topics_interface;
|
||||
node_graph_ = node_graph_interface;
|
||||
node_services_ = node_services_interface;
|
||||
node_logging_ = node_logging_interface;
|
||||
node_clock_ = node_clock_interface;
|
||||
node_parameters_ = node_parameters_interface;
|
||||
node_base_ = std::move(node_base_interface);
|
||||
node_topics_ = std::move(node_topics_interface);
|
||||
node_graph_ = std::move(node_graph_interface);
|
||||
node_services_ = std::move(node_services_interface);
|
||||
node_logging_ = std::move(node_logging_interface);
|
||||
node_clock_ = std::move(node_clock_interface);
|
||||
node_parameters_ = std::move(node_parameters_interface);
|
||||
// TODO(tfoote): Update QOS
|
||||
|
||||
logger_ = node_logging_->get_logger();
|
||||
@@ -262,7 +262,7 @@ public:
|
||||
}
|
||||
if (use_sim_time_param.get_type() == rclcpp::PARAMETER_BOOL) {
|
||||
if (use_sim_time_param.get<bool>()) {
|
||||
parameter_state_ = SET_TRUE;
|
||||
sim_time_parameter_state_ = true;
|
||||
clocks_state_.enable_ros_time();
|
||||
create_clock_sub();
|
||||
}
|
||||
@@ -305,14 +305,14 @@ public:
|
||||
node_parameters_.reset();
|
||||
}
|
||||
|
||||
void attachClock(std::shared_ptr<rclcpp::Clock> clock)
|
||||
void attachClock(const std::shared_ptr<rclcpp::Clock> & clock)
|
||||
{
|
||||
clocks_state_.attachClock(std::move(clock));
|
||||
clocks_state_.attachClock(clock);
|
||||
}
|
||||
|
||||
void detachClock(std::shared_ptr<rclcpp::Clock> clock)
|
||||
void detachClock(const std::shared_ptr<rclcpp::Clock> & clock)
|
||||
{
|
||||
clocks_state_.detachClock(std::move(clock));
|
||||
clocks_state_.detachClock(clock);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -346,16 +346,16 @@ private:
|
||||
rclcpp::executors::SingleThreadedExecutor::SharedPtr clock_executor_;
|
||||
|
||||
// The clock callback itself
|
||||
void clock_cb(std::shared_ptr<const rosgraph_msgs::msg::Clock> msg)
|
||||
void clock_cb(const std::shared_ptr<const rosgraph_msgs::msg::Clock> & msg)
|
||||
{
|
||||
if (!clocks_state_.is_ros_time_active() && SET_TRUE == this->parameter_state_) {
|
||||
if (!clocks_state_.is_ros_time_active() && sim_time_parameter_state_) {
|
||||
clocks_state_.enable_ros_time();
|
||||
}
|
||||
// Cache the last message in case a new clock is attached.
|
||||
clocks_state_.cache_last_msg(msg);
|
||||
auto time_msg = std::make_shared<builtin_interfaces::msg::Time>(msg->clock);
|
||||
|
||||
if (SET_TRUE == this->parameter_state_) {
|
||||
if (sim_time_parameter_state_) {
|
||||
clocks_state_.set_all_clocks(time_msg, true);
|
||||
}
|
||||
}
|
||||
@@ -403,7 +403,7 @@ private:
|
||||
node_topics_,
|
||||
"/clock",
|
||||
qos_,
|
||||
[this](std::shared_ptr<const rosgraph_msgs::msg::Clock> msg) {
|
||||
[this](const std::shared_ptr<const rosgraph_msgs::msg::Clock> & msg) {
|
||||
bool execute_cb = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(node_base_lock_);
|
||||
@@ -466,11 +466,11 @@ private:
|
||||
for (const auto & param : parameters) {
|
||||
if (param.get_name() == "use_sim_time") {
|
||||
if (param.as_bool()) {
|
||||
parameter_state_ = SET_TRUE;
|
||||
sim_time_parameter_state_ = true;
|
||||
clocks_state_.enable_ros_time();
|
||||
create_clock_sub();
|
||||
} else {
|
||||
parameter_state_ = SET_FALSE;
|
||||
sim_time_parameter_state_ = false;
|
||||
destroy_clock_sub();
|
||||
clocks_state_.disable_ros_time();
|
||||
}
|
||||
@@ -478,13 +478,11 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
// An enum to hold the parameter state
|
||||
enum UseSimTimeParameterState {SET_TRUE, SET_FALSE};
|
||||
UseSimTimeParameterState parameter_state_;
|
||||
bool sim_time_parameter_state_ = false;
|
||||
};
|
||||
|
||||
TimeSource::TimeSource(
|
||||
std::shared_ptr<rclcpp::Node> node,
|
||||
const std::shared_ptr<rclcpp::Node> & node,
|
||||
const rclcpp::QoS & qos,
|
||||
bool use_clock_thread)
|
||||
: TimeSource(qos, use_clock_thread)
|
||||
@@ -501,7 +499,7 @@ TimeSource::TimeSource(
|
||||
node_state_ = std::make_shared<NodeState>(qos, use_clock_thread);
|
||||
}
|
||||
|
||||
void TimeSource::attachNode(rclcpp::Node::SharedPtr node)
|
||||
void TimeSource::attachNode(const rclcpp::Node::SharedPtr & node)
|
||||
{
|
||||
node_state_->set_use_clock_thread(node->get_node_options().use_clock_thread());
|
||||
attachNode(
|
||||
@@ -541,14 +539,14 @@ void TimeSource::detachNode()
|
||||
constructed_use_clock_thread_);
|
||||
}
|
||||
|
||||
void TimeSource::attachClock(std::shared_ptr<rclcpp::Clock> clock)
|
||||
void TimeSource::attachClock(const std::shared_ptr<rclcpp::Clock> & clock)
|
||||
{
|
||||
node_state_->attachClock(std::move(clock));
|
||||
node_state_->attachClock(clock);
|
||||
}
|
||||
|
||||
void TimeSource::detachClock(std::shared_ptr<rclcpp::Clock> clock)
|
||||
void TimeSource::detachClock(const std::shared_ptr<rclcpp::Clock> & clock)
|
||||
{
|
||||
node_state_->detachClock(std::move(clock));
|
||||
node_state_->detachClock(clock);
|
||||
}
|
||||
|
||||
bool TimeSource::get_use_clock_thread()
|
||||
|
||||
@@ -150,7 +150,7 @@ TimerBase::exchange_in_use_by_wait_set_state(bool in_use_state)
|
||||
}
|
||||
|
||||
void
|
||||
TimerBase::set_on_reset_callback(std::function<void(size_t)> callback)
|
||||
TimerBase::set_on_reset_callback(const std::function<void(size_t)> & callback)
|
||||
{
|
||||
if (!callback) {
|
||||
throw std::invalid_argument(
|
||||
|
||||
@@ -158,46 +158,42 @@ remove_ros_arguments(int argc, char const * const * argv)
|
||||
}
|
||||
|
||||
bool
|
||||
ok(Context::SharedPtr context)
|
||||
ok(const Context::SharedPtr & context)
|
||||
{
|
||||
using rclcpp::contexts::get_global_default_context;
|
||||
if (nullptr == context) {
|
||||
context = get_global_default_context();
|
||||
if(!context) {
|
||||
return ok(rclcpp::contexts::get_global_default_context());
|
||||
}
|
||||
|
||||
return context->is_valid();
|
||||
}
|
||||
|
||||
bool
|
||||
shutdown(Context::SharedPtr context, const std::string & reason)
|
||||
shutdown(const Context::SharedPtr & context, const std::string & reason)
|
||||
{
|
||||
using rclcpp::contexts::get_global_default_context;
|
||||
auto default_context = get_global_default_context();
|
||||
if (nullptr == context) {
|
||||
context = default_context;
|
||||
if(!context) {
|
||||
return shutdown(rclcpp::contexts::get_global_default_context(), reason);
|
||||
}
|
||||
bool ret = context->shutdown(reason);
|
||||
if (context == default_context) {
|
||||
if (context == rclcpp::contexts::get_global_default_context()) {
|
||||
uninstall_signal_handlers();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
on_shutdown(std::function<void()> callback, Context::SharedPtr context)
|
||||
on_shutdown(const std::function<void()> & callback, const Context::SharedPtr & context)
|
||||
{
|
||||
using rclcpp::contexts::get_global_default_context;
|
||||
if (nullptr == context) {
|
||||
context = get_global_default_context();
|
||||
if(!context) {
|
||||
return on_shutdown(callback, rclcpp::contexts::get_global_default_context());
|
||||
}
|
||||
context->on_shutdown(callback);
|
||||
}
|
||||
|
||||
bool
|
||||
sleep_for(const std::chrono::nanoseconds & nanoseconds, Context::SharedPtr context)
|
||||
sleep_for(const std::chrono::nanoseconds & nanoseconds, const Context::SharedPtr & context)
|
||||
{
|
||||
using rclcpp::contexts::get_global_default_context;
|
||||
if (nullptr == context) {
|
||||
context = get_global_default_context();
|
||||
if (!context) {
|
||||
return sleep_for(nanoseconds, rclcpp::contexts::get_global_default_context());
|
||||
}
|
||||
return context->sleep_for(nanoseconds);
|
||||
}
|
||||
|
||||
@@ -16,19 +16,19 @@ rosidl_generate_interfaces(${PROJECT_NAME}_test_msgs
|
||||
# Need the target name to depend on generated interface libraries
|
||||
rosidl_get_typesupport_target(cpp_typesupport_target "${PROJECT_NAME}_test_msgs" "rosidl_typesupport_cpp")
|
||||
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_allocator_common
|
||||
allocator/test_allocator_common.cpp)
|
||||
if(TARGET test_allocator_common)
|
||||
target_link_libraries(test_allocator_common ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_allocator_deleter
|
||||
allocator/test_allocator_deleter.cpp)
|
||||
if(TARGET test_allocator_deleter)
|
||||
target_link_libraries(test_allocator_deleter ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_exceptions
|
||||
exceptions/test_exceptions.cpp)
|
||||
ament_add_test_label(test_exceptions mimick)
|
||||
@@ -36,42 +36,42 @@ if(TARGET test_exceptions)
|
||||
target_link_libraries(test_exceptions ${PROJECT_NAME} mimick)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_allocator_memory_strategy strategies/test_allocator_memory_strategy.cpp)
|
||||
ament_add_ros_isolated_gtest(test_allocator_memory_strategy strategies/test_allocator_memory_strategy.cpp)
|
||||
if(TARGET test_allocator_memory_strategy)
|
||||
target_link_libraries(test_allocator_memory_strategy ${PROJECT_NAME} rcpputils::rcpputils ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_message_pool_memory_strategy strategies/test_message_pool_memory_strategy.cpp)
|
||||
ament_add_ros_isolated_gtest(test_message_pool_memory_strategy strategies/test_message_pool_memory_strategy.cpp)
|
||||
if(TARGET test_message_pool_memory_strategy)
|
||||
target_link_libraries(test_message_pool_memory_strategy ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_any_service_callback test_any_service_callback.cpp)
|
||||
ament_add_ros_isolated_gtest(test_any_service_callback test_any_service_callback.cpp)
|
||||
if(TARGET test_any_service_callback)
|
||||
target_link_libraries(test_any_service_callback ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_any_subscription_callback test_any_subscription_callback.cpp)
|
||||
ament_add_ros_isolated_gtest(test_any_subscription_callback test_any_subscription_callback.cpp)
|
||||
if(TARGET test_any_subscription_callback)
|
||||
target_link_libraries(test_any_subscription_callback ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_client test_client.cpp)
|
||||
ament_add_ros_isolated_gtest(test_client test_client.cpp)
|
||||
ament_add_test_label(test_client mimick)
|
||||
if(TARGET test_client)
|
||||
target_link_libraries(test_client ${PROJECT_NAME} mimick ${rcl_interfaces_TARGETS} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_clock_conditional test_clock_conditional.cpp)
|
||||
ament_add_ros_isolated_gtest(test_clock_conditional test_clock_conditional.cpp)
|
||||
ament_add_test_label(test_clock_conditional mimick)
|
||||
if(TARGET test_clock_conditional)
|
||||
target_link_libraries(test_clock_conditional ${PROJECT_NAME} mimick ${rcl_interfaces_TARGETS} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_copy_all_parameter_values test_copy_all_parameter_values.cpp)
|
||||
ament_add_ros_isolated_gtest(test_copy_all_parameter_values test_copy_all_parameter_values.cpp)
|
||||
if(TARGET test_copy_all_parameter_values)
|
||||
target_link_libraries(test_copy_all_parameter_values ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_create_timer test_create_timer.cpp)
|
||||
ament_add_ros_isolated_gtest(test_create_timer test_create_timer.cpp)
|
||||
if(TARGET test_create_timer)
|
||||
target_link_libraries(test_create_timer ${PROJECT_NAME})
|
||||
target_include_directories(test_create_timer PRIVATE ./)
|
||||
endif()
|
||||
ament_add_gtest(test_generic_client test_generic_client.cpp)
|
||||
ament_add_ros_isolated_gtest(test_generic_client test_generic_client.cpp)
|
||||
ament_add_test_label(test_generic_client mimick)
|
||||
if(TARGET test_generic_client)
|
||||
target_link_libraries(test_generic_client ${PROJECT_NAME}
|
||||
@@ -83,7 +83,7 @@ if(TARGET test_generic_client)
|
||||
${test_msgs_TARGETS}
|
||||
)
|
||||
endif()
|
||||
ament_add_gtest(test_generic_service test_generic_service.cpp)
|
||||
ament_add_ros_isolated_gtest(test_generic_service test_generic_service.cpp)
|
||||
ament_add_test_label(test_generic_service mimick)
|
||||
if(TARGET test_generic_service)
|
||||
target_link_libraries(test_generic_service ${PROJECT_NAME}
|
||||
@@ -95,7 +95,7 @@ if(TARGET test_generic_service)
|
||||
${test_msgs_TARGETS}
|
||||
)
|
||||
endif()
|
||||
ament_add_gtest(test_client_common test_client_common.cpp)
|
||||
ament_add_ros_isolated_gtest(test_client_common test_client_common.cpp)
|
||||
ament_add_test_label(test_client_common mimick)
|
||||
if(TARGET test_client_common)
|
||||
target_link_libraries(test_client_common ${PROJECT_NAME}
|
||||
@@ -107,122 +107,122 @@ if(TARGET test_client_common)
|
||||
${test_msgs_TARGETS}
|
||||
)
|
||||
endif()
|
||||
ament_add_gtest(test_create_subscription test_create_subscription.cpp)
|
||||
ament_add_ros_isolated_gtest(test_create_subscription test_create_subscription.cpp)
|
||||
if(TARGET test_create_subscription)
|
||||
target_link_libraries(test_create_subscription ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_expand_topic_or_service_name test_expand_topic_or_service_name.cpp)
|
||||
ament_add_ros_isolated_gtest(test_expand_topic_or_service_name test_expand_topic_or_service_name.cpp)
|
||||
ament_add_test_label(test_expand_topic_or_service_name mimick)
|
||||
if(TARGET test_expand_topic_or_service_name)
|
||||
target_link_libraries(test_expand_topic_or_service_name ${PROJECT_NAME} mimick rcl::rcl rmw::rmw)
|
||||
endif()
|
||||
ament_add_gtest(test_function_traits test_function_traits.cpp)
|
||||
ament_add_ros_isolated_gtest(test_function_traits test_function_traits.cpp)
|
||||
if(TARGET test_function_traits)
|
||||
target_link_libraries(test_function_traits ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_future_return_code
|
||||
test_future_return_code.cpp)
|
||||
if(TARGET test_future_return_code)
|
||||
target_link_libraries(test_future_return_code ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gmock(test_intra_process_manager test_intra_process_manager.cpp)
|
||||
ament_add_ros_isolated_gmock(test_intra_process_manager test_intra_process_manager.cpp)
|
||||
if(TARGET test_intra_process_manager)
|
||||
target_link_libraries(test_intra_process_manager ${PROJECT_NAME} ${rcl_interfaces_TARGETS} rmw::rmw)
|
||||
endif()
|
||||
ament_add_gmock(test_intra_process_manager_with_allocators test_intra_process_manager_with_allocators.cpp)
|
||||
ament_add_ros_isolated_gmock(test_intra_process_manager_with_allocators test_intra_process_manager_with_allocators.cpp)
|
||||
if(TARGET test_intra_process_manager_with_allocators)
|
||||
target_link_libraries(test_intra_process_manager_with_allocators ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_ring_buffer_implementation test_ring_buffer_implementation.cpp)
|
||||
ament_add_ros_isolated_gtest(test_ring_buffer_implementation test_ring_buffer_implementation.cpp)
|
||||
if(TARGET test_ring_buffer_implementation)
|
||||
target_link_libraries(test_ring_buffer_implementation ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_intra_process_buffer test_intra_process_buffer.cpp)
|
||||
ament_add_ros_isolated_gtest(test_intra_process_buffer test_intra_process_buffer.cpp)
|
||||
if(TARGET test_intra_process_buffer)
|
||||
target_link_libraries(test_intra_process_buffer ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_loaned_message test_loaned_message.cpp)
|
||||
ament_add_ros_isolated_gtest(test_loaned_message test_loaned_message.cpp)
|
||||
ament_add_test_label(test_loaned_message mimick)
|
||||
target_link_libraries(test_loaned_message ${PROJECT_NAME} mimick ${test_msgs_TARGETS})
|
||||
|
||||
ament_add_gtest(test_memory_strategy test_memory_strategy.cpp)
|
||||
ament_add_ros_isolated_gtest(test_memory_strategy test_memory_strategy.cpp)
|
||||
target_link_libraries(test_memory_strategy ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
|
||||
ament_add_gtest(test_message_memory_strategy test_message_memory_strategy.cpp)
|
||||
ament_add_ros_isolated_gtest(test_message_memory_strategy test_message_memory_strategy.cpp)
|
||||
target_link_libraries(test_message_memory_strategy ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
|
||||
ament_add_gtest(test_node test_node.cpp TIMEOUT 240)
|
||||
ament_add_ros_isolated_gtest(test_node test_node.cpp TIMEOUT 240)
|
||||
ament_add_test_label(test_node mimick)
|
||||
if(TARGET test_node)
|
||||
target_link_libraries(test_node ${PROJECT_NAME} mimick rcpputils::rcpputils rmw::rmw ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_node_interfaces__get_node_interfaces
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__get_node_interfaces
|
||||
node_interfaces/test_get_node_interfaces.cpp)
|
||||
if(TARGET test_node_interfaces__get_node_interfaces)
|
||||
target_link_libraries(test_node_interfaces__get_node_interfaces ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_base
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_base
|
||||
node_interfaces/test_node_base.cpp)
|
||||
ament_add_test_label(test_node_interfaces__node_base mimick)
|
||||
if(TARGET test_node_interfaces__node_base)
|
||||
target_link_libraries(test_node_interfaces__node_base ${PROJECT_NAME} mimick rcl::rcl rmw::rmw)
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_clock
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_clock
|
||||
node_interfaces/test_node_clock.cpp)
|
||||
if(TARGET test_node_interfaces__node_clock)
|
||||
target_link_libraries(test_node_interfaces__node_clock ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_graph
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_graph
|
||||
node_interfaces/test_node_graph.cpp
|
||||
TIMEOUT 120)
|
||||
ament_add_test_label(test_node_interfaces__node_graph mimick)
|
||||
if(TARGET test_node_interfaces__node_graph)
|
||||
target_link_libraries(test_node_interfaces__node_graph ${PROJECT_NAME} mimick rcl::rcl ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_interfaces
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_interfaces
|
||||
node_interfaces/test_node_interfaces.cpp)
|
||||
if(TARGET test_node_interfaces__node_interfaces)
|
||||
target_link_libraries(test_node_interfaces__node_interfaces ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_parameters
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_parameters
|
||||
node_interfaces/test_node_parameters.cpp)
|
||||
ament_add_test_label(test_node_interfaces__node_parameters mimick)
|
||||
if(TARGET test_node_interfaces__node_parameters)
|
||||
target_link_libraries(test_node_interfaces__node_parameters ${PROJECT_NAME} mimick rcpputils::rcpputils ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_services
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_services
|
||||
node_interfaces/test_node_services.cpp)
|
||||
ament_add_test_label(test_node_interfaces__node_services mimick)
|
||||
if(TARGET test_node_interfaces__node_services)
|
||||
target_link_libraries(test_node_interfaces__node_services ${PROJECT_NAME} mimick rcl::rcl)
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_timers
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_timers
|
||||
node_interfaces/test_node_timers.cpp)
|
||||
ament_add_test_label(test_node_interfaces__node_timers mimick)
|
||||
if(TARGET test_node_interfaces__node_timers)
|
||||
target_link_libraries(test_node_interfaces__node_timers ${PROJECT_NAME} mimick rcl::rcl)
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_topics
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_topics
|
||||
node_interfaces/test_node_topics.cpp)
|
||||
ament_add_test_label(test_node_interfaces__node_topics mimick)
|
||||
if(TARGET test_node_interfaces__node_topics)
|
||||
target_link_libraries(test_node_interfaces__node_topics ${PROJECT_NAME} mimick rcl::rcl ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_type_descriptions
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_type_descriptions
|
||||
node_interfaces/test_node_type_descriptions.cpp)
|
||||
if(TARGET test_node_interfaces__node_type_descriptions)
|
||||
target_link_libraries(test_node_interfaces__node_type_descriptions ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__node_waitables
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__node_waitables
|
||||
node_interfaces/test_node_waitables.cpp)
|
||||
ament_add_test_label(test_node_interfaces__node_waitables mimick)
|
||||
if(TARGET test_node_interfaces__node_waitables)
|
||||
target_link_libraries(test_node_interfaces__node_waitables ${PROJECT_NAME} mimick rcl::rcl)
|
||||
endif()
|
||||
ament_add_gtest(test_node_interfaces__test_template_utils # Compile time test
|
||||
ament_add_ros_isolated_gtest(test_node_interfaces__test_template_utils # Compile time test
|
||||
node_interfaces/detail/test_template_utils.cpp)
|
||||
if(TARGET test_node_interfaces__test_template_utils)
|
||||
target_link_libraries(test_node_interfaces__test_template_utils ${PROJECT_NAME})
|
||||
@@ -249,45 +249,45 @@ endif()
|
||||
# target_link_libraries(build_failure__get_node_topics_interface_const_ptr_rclcpp_node
|
||||
# ${PROJECT_NAME})
|
||||
|
||||
ament_add_gtest(test_node_global_args test_node_global_args.cpp)
|
||||
ament_add_ros_isolated_gtest(test_node_global_args test_node_global_args.cpp)
|
||||
if(TARGET test_node_global_args)
|
||||
target_link_libraries(test_node_global_args ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_node_options test_node_options.cpp)
|
||||
ament_add_ros_isolated_gtest(test_node_options test_node_options.cpp)
|
||||
ament_add_test_label(test_node_options mimick)
|
||||
if(TARGET test_node_options)
|
||||
target_link_libraries(test_node_options ${PROJECT_NAME} mimick rcl::rcl)
|
||||
endif()
|
||||
ament_add_gtest(test_init_options test_init_options.cpp)
|
||||
ament_add_ros_isolated_gtest(test_init_options test_init_options.cpp)
|
||||
ament_add_test_label(test_init_options mimick)
|
||||
if(TARGET test_init_options)
|
||||
target_link_libraries(test_init_options ${PROJECT_NAME} mimick rcl::rcl)
|
||||
endif()
|
||||
ament_add_gmock(test_parameter_client test_parameter_client.cpp)
|
||||
ament_add_ros_isolated_gmock(test_parameter_client test_parameter_client.cpp)
|
||||
if(TARGET test_parameter_client)
|
||||
target_link_libraries(test_parameter_client ${PROJECT_NAME} ${rcl_interfaces_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_parameter_service test_parameter_service.cpp)
|
||||
ament_add_ros_isolated_gtest(test_parameter_service test_parameter_service.cpp)
|
||||
if(TARGET test_parameter_service)
|
||||
target_link_libraries(test_parameter_service ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_parameter_events_filter test_parameter_events_filter.cpp)
|
||||
ament_add_ros_isolated_gtest(test_parameter_events_filter test_parameter_events_filter.cpp)
|
||||
if(TARGET test_parameter_events_filter)
|
||||
target_link_libraries(test_parameter_events_filter ${PROJECT_NAME} ${rcl_interfaces_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_parameter test_parameter.cpp)
|
||||
ament_add_ros_isolated_gtest(test_parameter test_parameter.cpp)
|
||||
if(TARGET test_parameter)
|
||||
target_link_libraries(test_parameter ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_parameter_event_handler test_parameter_event_handler.cpp)
|
||||
ament_add_ros_isolated_gtest(test_parameter_event_handler test_parameter_event_handler.cpp)
|
||||
if(TARGET test_parameter_event_handler)
|
||||
target_link_libraries(test_parameter_event_handler ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_parameter_map test_parameter_map.cpp)
|
||||
ament_add_ros_isolated_gtest(test_parameter_map test_parameter_map.cpp)
|
||||
if(TARGET test_parameter_map)
|
||||
target_link_libraries(test_parameter_map ${PROJECT_NAME} rcl::rcl rcl_yaml_param_parser::rcl_yaml_param_parser rcutils::rcutils)
|
||||
endif()
|
||||
ament_add_gtest(test_publisher test_publisher.cpp TIMEOUT 120)
|
||||
ament_add_ros_isolated_gtest(test_publisher test_publisher.cpp TIMEOUT 120)
|
||||
ament_add_test_label(test_publisher mimick)
|
||||
if(TARGET test_publisher)
|
||||
target_link_libraries(test_publisher ${PROJECT_NAME} mimick rcl::rcl rcutils::rcutils ${test_msgs_TARGETS})
|
||||
@@ -298,7 +298,7 @@ if(WIN32)
|
||||
set(append_library_dirs "${append_library_dirs}/$<CONFIG>")
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_publisher_with_type_adapter test_publisher_with_type_adapter.cpp
|
||||
ament_add_ros_isolated_gtest(test_publisher_with_type_adapter test_publisher_with_type_adapter.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}"
|
||||
)
|
||||
if(TARGET test_publisher_with_type_adapter)
|
||||
@@ -307,7 +307,7 @@ if(TARGET test_publisher_with_type_adapter)
|
||||
${cpp_typesupport_target})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_subscription_with_type_adapter test_subscription_with_type_adapter.cpp
|
||||
ament_add_ros_isolated_gtest(test_subscription_with_type_adapter test_subscription_with_type_adapter.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}"
|
||||
)
|
||||
if(TARGET test_subscription_with_type_adapter)
|
||||
@@ -316,7 +316,7 @@ if(TARGET test_subscription_with_type_adapter)
|
||||
${cpp_typesupport_target})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_subscription_publisher_with_same_type_adapter test_subscription_publisher_with_same_type_adapter.cpp
|
||||
ament_add_ros_isolated_gtest(test_subscription_publisher_with_same_type_adapter test_subscription_publisher_with_same_type_adapter.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}"
|
||||
)
|
||||
if(TARGET test_subscription_publisher_with_same_type_adapter)
|
||||
@@ -327,11 +327,11 @@ if(TARGET test_subscription_publisher_with_same_type_adapter)
|
||||
)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_publisher_subscription_count_api test_publisher_subscription_count_api.cpp)
|
||||
ament_add_ros_isolated_gtest(test_publisher_subscription_count_api test_publisher_subscription_count_api.cpp)
|
||||
if(TARGET test_publisher_subscription_count_api)
|
||||
target_link_libraries(test_publisher_subscription_count_api ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_qos test_qos.cpp)
|
||||
ament_add_ros_isolated_gtest(test_qos test_qos.cpp)
|
||||
if(TARGET test_qos)
|
||||
target_link_libraries(test_qos
|
||||
${PROJECT_NAME}
|
||||
@@ -339,137 +339,137 @@ if(TARGET test_qos)
|
||||
)
|
||||
endif()
|
||||
|
||||
ament_add_gmock(test_qos_overriding_options test_qos_overriding_options.cpp)
|
||||
ament_add_ros_isolated_gmock(test_qos_overriding_options test_qos_overriding_options.cpp)
|
||||
if(TARGET test_qos_overriding_options)
|
||||
target_link_libraries(test_qos_overriding_options ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gmock(test_qos_parameters test_qos_parameters.cpp)
|
||||
ament_add_ros_isolated_gmock(test_qos_parameters test_qos_parameters.cpp)
|
||||
if(TARGET test_qos_parameters)
|
||||
target_link_libraries(test_qos_parameters ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_rate test_rate.cpp)
|
||||
ament_add_ros_isolated_gtest(test_rate test_rate.cpp)
|
||||
if(TARGET test_rate)
|
||||
target_link_libraries(test_rate ${PROJECT_NAME})
|
||||
endif()
|
||||
ament_add_gtest(test_serialized_message_allocator test_serialized_message_allocator.cpp)
|
||||
ament_add_ros_isolated_gtest(test_serialized_message_allocator test_serialized_message_allocator.cpp)
|
||||
if(TARGET test_serialized_message_allocator)
|
||||
target_link_libraries(test_serialized_message_allocator ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_serialized_message test_serialized_message.cpp)
|
||||
ament_add_ros_isolated_gtest(test_serialized_message test_serialized_message.cpp)
|
||||
if(TARGET test_serialized_message)
|
||||
target_link_libraries(test_serialized_message ${PROJECT_NAME} rcpputils::rcpputils ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_service test_service.cpp)
|
||||
ament_add_ros_isolated_gtest(test_service test_service.cpp)
|
||||
ament_add_test_label(test_service mimick)
|
||||
if(TARGET test_service)
|
||||
target_link_libraries(test_service ${PROJECT_NAME} mimick ${rcl_interfaces_TARGES} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gmock(test_service_introspection test_service_introspection.cpp)
|
||||
ament_add_ros_isolated_gmock(test_service_introspection test_service_introspection.cpp)
|
||||
ament_add_test_label(test_service_introspection mimick)
|
||||
if(TARGET test_service_introspection)
|
||||
target_link_libraries(test_service_introspection ${PROJECT_NAME} mimick ${service_msgs_TARGETS} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
# Creating and destroying nodes is slow with Connext, so this needs larger timeout.
|
||||
ament_add_gtest(test_subscription test_subscription.cpp TIMEOUT 120)
|
||||
ament_add_ros_isolated_gtest(test_subscription test_subscription.cpp TIMEOUT 120)
|
||||
ament_add_test_label(test_subscription mimick)
|
||||
if(TARGET test_subscription)
|
||||
target_link_libraries(test_subscription ${PROJECT_NAME} mimick ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_subscription_publisher_count_api test_subscription_publisher_count_api.cpp)
|
||||
ament_add_ros_isolated_gtest(test_subscription_publisher_count_api test_subscription_publisher_count_api.cpp)
|
||||
if(TARGET test_subscription_publisher_count_api)
|
||||
target_link_libraries(test_subscription_publisher_count_api ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_subscription_traits test_subscription_traits.cpp)
|
||||
ament_add_ros_isolated_gtest(test_subscription_traits test_subscription_traits.cpp)
|
||||
if(TARGET test_subscription_traits)
|
||||
target_link_libraries(test_subscription_traits ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gtest(test_type_support test_type_support.cpp)
|
||||
ament_add_ros_isolated_gtest(test_type_support test_type_support.cpp)
|
||||
if(TARGET test_type_support)
|
||||
target_link_libraries(test_type_support ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
ament_add_gmock(test_typesupport_helpers test_typesupport_helpers.cpp)
|
||||
ament_add_ros_isolated_gmock(test_typesupport_helpers test_typesupport_helpers.cpp)
|
||||
if(TARGET test_typesupport_helpers)
|
||||
target_link_libraries(test_typesupport_helpers ${PROJECT_NAME} rcpputils::rcpputils)
|
||||
endif()
|
||||
ament_add_gtest(test_find_weak_nodes test_find_weak_nodes.cpp)
|
||||
ament_add_ros_isolated_gtest(test_find_weak_nodes test_find_weak_nodes.cpp)
|
||||
if(TARGET test_find_weak_nodes)
|
||||
target_link_libraries(test_find_weak_nodes ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_externally_defined_services test_externally_defined_services.cpp)
|
||||
ament_add_ros_isolated_gtest(test_externally_defined_services test_externally_defined_services.cpp)
|
||||
target_link_libraries(test_externally_defined_services ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS})
|
||||
|
||||
ament_add_gtest(test_duration test_duration.cpp
|
||||
ament_add_ros_isolated_gtest(test_duration test_duration.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_duration)
|
||||
target_link_libraries(test_duration ${PROJECT_NAME} rcl::rcl)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_logger test_logger.cpp)
|
||||
ament_add_ros_isolated_gtest(test_logger test_logger.cpp)
|
||||
target_link_libraries(test_logger ${PROJECT_NAME} rcutils::rcutils)
|
||||
|
||||
ament_add_gmock(test_logging test_logging.cpp)
|
||||
ament_add_ros_isolated_gmock(test_logging test_logging.cpp)
|
||||
target_link_libraries(test_logging ${PROJECT_NAME} rcutils::rcutils)
|
||||
|
||||
ament_add_gmock(test_context test_context.cpp)
|
||||
ament_add_ros_isolated_gmock(test_context test_context.cpp)
|
||||
target_link_libraries(test_context ${PROJECT_NAME})
|
||||
|
||||
ament_add_gtest(test_time test_time.cpp
|
||||
ament_add_ros_isolated_gtest(test_time test_time.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_time)
|
||||
target_link_libraries(test_time ${PROJECT_NAME} rcl::rcl rcutils::rcutils)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_timer test_timer.cpp
|
||||
ament_add_ros_isolated_gtest(test_timer test_timer.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
ament_add_test_label(test_timer mimick)
|
||||
if(TARGET test_timer)
|
||||
target_link_libraries(test_timer ${PROJECT_NAME} mimick rcl::rcl)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_timers_manager test_timers_manager.cpp
|
||||
ament_add_ros_isolated_gtest(test_timers_manager test_timers_manager.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_timers_manager)
|
||||
target_link_libraries(test_timers_manager ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_time_source test_time_source.cpp
|
||||
ament_add_ros_isolated_gtest(test_time_source test_time_source.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_time_source)
|
||||
target_link_libraries(test_time_source ${PROJECT_NAME} rcl::rcl)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_utilities test_utilities.cpp
|
||||
ament_add_ros_isolated_gtest(test_utilities test_utilities.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
ament_add_test_label(test_utilities mimick)
|
||||
if(TARGET test_utilities)
|
||||
target_link_libraries(test_utilities ${PROJECT_NAME} mimick rcl::rcl)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_wait_for_message test_wait_for_message.cpp)
|
||||
ament_add_ros_isolated_gtest(test_wait_for_message test_wait_for_message.cpp)
|
||||
if(TARGET test_wait_for_message)
|
||||
target_link_libraries(test_wait_for_message ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_logger_service test_logger_service.cpp)
|
||||
ament_add_ros_isolated_gtest(test_logger_service test_logger_service.cpp)
|
||||
if(TARGET test_logger_service)
|
||||
target_link_libraries(test_logger_service ${PROJECT_NAME} ${rcl_interfaces_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_interface_traits test_interface_traits.cpp
|
||||
ament_add_ros_isolated_gtest(test_interface_traits test_interface_traits.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_interface_traits)
|
||||
target_link_libraries(test_interface_traits ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_reinitialized_timers
|
||||
ament_add_ros_isolated_gtest(test_reinitialized_timers
|
||||
executors/test_reinitialized_timers.cpp
|
||||
TIMEOUT 30)
|
||||
if(TARGET test_reinitialized_timers)
|
||||
target_link_libraries(test_reinitialized_timers ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_executors
|
||||
executors/test_executors.cpp
|
||||
executors/test_waitable.cpp
|
||||
@@ -482,7 +482,7 @@ if(TARGET test_executors)
|
||||
target_link_libraries(test_executors ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_executors_timer_cancel_behavior
|
||||
executors/test_executors_timer_cancel_behavior.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}"
|
||||
@@ -491,7 +491,7 @@ if(TARGET test_executors_timer_cancel_behavior)
|
||||
target_link_libraries(test_executors_timer_cancel_behavior ${PROJECT_NAME} ${rosgraph_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_executors_callback_group_behavior
|
||||
executors/test_executors_callback_group_behavior.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}"
|
||||
@@ -500,7 +500,7 @@ if(TARGET test_executors_callback_group_behavior)
|
||||
target_link_libraries(test_executors_callback_group_behavior ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_executors_intraprocess
|
||||
executors/test_executors_intraprocess.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}"
|
||||
@@ -509,7 +509,7 @@ if(TARGET test_executors_intraprocess)
|
||||
target_link_libraries(test_executors_intraprocess ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_executors_busy_waiting
|
||||
executors/test_executors_busy_waiting.cpp
|
||||
executors/test_waitable.cpp
|
||||
@@ -519,7 +519,7 @@ if(TARGET test_executors_busy_waiting)
|
||||
target_link_libraries(test_executors_busy_waiting ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(
|
||||
ament_add_ros_isolated_gtest(
|
||||
test_executors_warmup
|
||||
executors/test_executors_warmup.cpp
|
||||
executors/test_waitable.cpp
|
||||
@@ -529,50 +529,50 @@ if(TARGET test_executors_warmup)
|
||||
target_link_libraries(test_executors_warmup ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_multi_threaded_executor executors/test_multi_threaded_executor.cpp
|
||||
ament_add_ros_isolated_gtest(test_multi_threaded_executor executors/test_multi_threaded_executor.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_multi_threaded_executor)
|
||||
target_link_libraries(test_multi_threaded_executor ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_entities_collector executors/test_entities_collector.cpp
|
||||
ament_add_ros_isolated_gtest(test_entities_collector executors/test_entities_collector.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}" TIMEOUT 120)
|
||||
if(TARGET test_entities_collector)
|
||||
target_link_libraries(test_entities_collector ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_executor_notify_waitable executors/test_executor_notify_waitable.cpp
|
||||
ament_add_ros_isolated_gtest(test_executor_notify_waitable executors/test_executor_notify_waitable.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}" TIMEOUT 120)
|
||||
ament_add_test_label(test_executor_notify_waitable mimick)
|
||||
if(TARGET test_executor_notify_waitable)
|
||||
target_link_libraries(test_executor_notify_waitable ${PROJECT_NAME} mimick rcpputils::rcpputils)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_events_executor executors/test_events_executor.cpp TIMEOUT 60)
|
||||
ament_add_ros_isolated_gtest(test_events_executor executors/test_events_executor.cpp TIMEOUT 60)
|
||||
if(TARGET test_events_executor)
|
||||
target_link_libraries(test_events_executor ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_events_queue executors/test_events_queue.cpp
|
||||
ament_add_ros_isolated_gtest(test_events_queue executors/test_events_queue.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_events_queue)
|
||||
target_link_libraries(test_events_queue ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_guard_condition test_guard_condition.cpp
|
||||
ament_add_ros_isolated_gtest(test_guard_condition test_guard_condition.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
ament_add_test_label(test_guard_condition mimick)
|
||||
if(TARGET test_guard_condition)
|
||||
target_link_libraries(test_guard_condition ${PROJECT_NAME} mimick)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_wait_set test_wait_set.cpp
|
||||
ament_add_ros_isolated_gtest(test_wait_set test_wait_set.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}")
|
||||
if(TARGET test_wait_set)
|
||||
target_link_libraries(test_wait_set ${PROJECT_NAME} ${rcl_interfaces_TARGETS} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_subscription_topic_statistics topic_statistics/test_subscription_topic_statistics.cpp
|
||||
ament_add_ros_isolated_gtest(test_subscription_topic_statistics topic_statistics/test_subscription_topic_statistics.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}"
|
||||
)
|
||||
if(TARGET test_subscription_topic_statistics)
|
||||
@@ -584,48 +584,48 @@ if(TARGET test_subscription_topic_statistics)
|
||||
)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_subscription_options test_subscription_options.cpp)
|
||||
ament_add_ros_isolated_gtest(test_subscription_options test_subscription_options.cpp)
|
||||
if(TARGET test_subscription_options)
|
||||
target_link_libraries(test_subscription_options ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_dynamic_storage wait_set_policies/test_dynamic_storage.cpp)
|
||||
ament_add_ros_isolated_gtest(test_dynamic_storage wait_set_policies/test_dynamic_storage.cpp)
|
||||
if(TARGET test_dynamic_storage)
|
||||
target_link_libraries(test_dynamic_storage ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_storage_policy_common wait_set_policies/test_storage_policy_common.cpp)
|
||||
ament_add_ros_isolated_gtest(test_storage_policy_common wait_set_policies/test_storage_policy_common.cpp)
|
||||
ament_add_test_label(test_storage_policy_common mimick)
|
||||
if(TARGET test_storage_policy_common)
|
||||
target_link_libraries(test_storage_policy_common ${PROJECT_NAME} mimick ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_static_storage wait_set_policies/test_static_storage.cpp)
|
||||
ament_add_ros_isolated_gtest(test_static_storage wait_set_policies/test_static_storage.cpp)
|
||||
if(TARGET test_static_storage)
|
||||
target_link_libraries(test_static_storage ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_thread_safe_synchronization wait_set_policies/test_thread_safe_synchronization.cpp)
|
||||
ament_add_ros_isolated_gtest(test_thread_safe_synchronization wait_set_policies/test_thread_safe_synchronization.cpp)
|
||||
if(TARGET test_thread_safe_synchronization)
|
||||
target_link_libraries(test_thread_safe_synchronization ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_intra_process_waitable waitables/test_intra_process_waitable.cpp)
|
||||
ament_add_ros_isolated_gtest(test_intra_process_waitable waitables/test_intra_process_waitable.cpp)
|
||||
if(TARGET test_intra_process_waitable)
|
||||
target_link_libraries(test_intra_process_waitable ${PROJECT_NAME} ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_rosout_qos test_rosout_qos.cpp)
|
||||
ament_add_ros_isolated_gtest(test_rosout_qos test_rosout_qos.cpp)
|
||||
if(TARGET test_rosout_qos)
|
||||
target_link_libraries(test_rosout_qos ${PROJECT_NAME} rcl::rcl rmw::rmw)
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_rosout_subscription test_rosout_subscription.cpp)
|
||||
ament_add_ros_isolated_gtest(test_rosout_subscription test_rosout_subscription.cpp)
|
||||
if(TARGET test_rosout_subscription)
|
||||
target_link_libraries(test_rosout_subscription ${PROJECT_NAME} ${rcl_interfaces_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_executor test_executor.cpp
|
||||
ament_add_ros_isolated_gtest(test_executor test_executor.cpp
|
||||
APPEND_LIBRARY_DIRS "${append_library_dirs}"
|
||||
TIMEOUT 120)
|
||||
ament_add_test_label(test_executor mimick)
|
||||
@@ -633,7 +633,7 @@ if(TARGET test_executor)
|
||||
target_link_libraries(test_executor ${PROJECT_NAME} mimick ${test_msgs_TARGETS})
|
||||
endif()
|
||||
|
||||
ament_add_gtest(test_graph_listener test_graph_listener.cpp)
|
||||
ament_add_ros_isolated_gtest(test_graph_listener test_graph_listener.cpp)
|
||||
ament_add_test_label(test_graph_listener mimick)
|
||||
if(TARGET test_graph_listener)
|
||||
target_link_libraries(test_graph_listener ${PROJECT_NAME} mimick)
|
||||
|
||||
@@ -16,11 +16,17 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "rclcpp/allocator/allocator_common.hpp"
|
||||
#include "rcpputils/compile_warnings.hpp"
|
||||
|
||||
TEST(TestAllocatorCommon, retyped_allocate) {
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_START
|
||||
#include "rclcpp/allocator/allocator_common.hpp"
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_STOP
|
||||
|
||||
TEST(TestAllocatorCommon, retyped_allocate)
|
||||
{
|
||||
std::allocator<int> allocator;
|
||||
void * untyped_allocator = &allocator;
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_START
|
||||
void * allocated_mem =
|
||||
rclcpp::allocator::retyped_allocate<std::allocator<char>>(1u, untyped_allocator);
|
||||
// The more natural check here is ASSERT_NE(nullptr, ptr), but clang static
|
||||
@@ -49,9 +55,12 @@ TEST(TestAllocatorCommon, retyped_allocate) {
|
||||
reallocated_mem, untyped_allocator);
|
||||
};
|
||||
EXPECT_NO_THROW(code2());
|
||||
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_STOP
|
||||
}
|
||||
|
||||
TEST(TestAllocatorCommon, retyped_zero_allocate_basic) {
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_START
|
||||
std::allocator<int> allocator;
|
||||
void * untyped_allocator = &allocator;
|
||||
void * allocated_mem =
|
||||
@@ -63,9 +72,11 @@ TEST(TestAllocatorCommon, retyped_zero_allocate_basic) {
|
||||
allocated_mem, untyped_allocator);
|
||||
};
|
||||
EXPECT_NO_THROW(code());
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_STOP
|
||||
}
|
||||
|
||||
TEST(TestAllocatorCommon, retyped_zero_allocate) {
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_START
|
||||
std::allocator<int> allocator;
|
||||
void * untyped_allocator = &allocator;
|
||||
void * allocated_mem =
|
||||
@@ -96,9 +107,11 @@ TEST(TestAllocatorCommon, retyped_zero_allocate) {
|
||||
reallocated_mem, untyped_allocator);
|
||||
};
|
||||
EXPECT_NO_THROW(code2());
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_STOP
|
||||
}
|
||||
|
||||
TEST(TestAllocatorCommon, get_rcl_allocator) {
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_START
|
||||
std::allocator<int> allocator;
|
||||
auto rcl_allocator = rclcpp::allocator::get_rcl_allocator<int>(allocator);
|
||||
EXPECT_NE(nullptr, rcl_allocator.allocate);
|
||||
@@ -106,9 +119,12 @@ TEST(TestAllocatorCommon, get_rcl_allocator) {
|
||||
EXPECT_NE(nullptr, rcl_allocator.reallocate);
|
||||
EXPECT_NE(nullptr, rcl_allocator.zero_allocate);
|
||||
// Not testing state as that may or may not be null depending on platform
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_STOP
|
||||
}
|
||||
|
||||
TEST(TestAllocatorCommon, get_void_rcl_allocator) {
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_START
|
||||
|
||||
std::allocator<void> allocator;
|
||||
auto rcl_allocator =
|
||||
rclcpp::allocator::get_rcl_allocator<void, std::allocator<void>>(allocator);
|
||||
@@ -117,4 +133,5 @@ TEST(TestAllocatorCommon, get_void_rcl_allocator) {
|
||||
EXPECT_NE(nullptr, rcl_allocator.reallocate);
|
||||
EXPECT_NE(nullptr, rcl_allocator.zero_allocate);
|
||||
// Not testing state as that may or may not be null depending on platform
|
||||
RCPPUTILS_DEPRECATION_WARNING_OFF_STOP
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
rclcpp::Node::SharedPtr node;
|
||||
rclcpp::Publisher<test_msgs::msg::Empty>::SharedPtr publisher;
|
||||
rclcpp::Subscription<test_msgs::msg::Empty>::SharedPtr subscription;
|
||||
int callback_count;
|
||||
std::atomic<int> callback_count;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -152,7 +152,7 @@ TYPED_TEST(TestExecutors, spinWithTimer)
|
||||
using ExecutorType = TypeParam;
|
||||
ExecutorType executor;
|
||||
|
||||
bool timer_completed = false;
|
||||
std::atomic<bool> timer_completed = false;
|
||||
auto timer = this->node->create_wall_timer(1ms, [&]() {timer_completed = true;});
|
||||
executor.add_node(this->node);
|
||||
|
||||
@@ -263,7 +263,7 @@ TYPED_TEST(TestExecutors, testSpinUntilFutureCompleteNoTimeout)
|
||||
}
|
||||
});
|
||||
|
||||
bool spin_exited = false;
|
||||
std::atomic<bool> spin_exited = false;
|
||||
|
||||
// Timeout set to negative for no timeout.
|
||||
std::thread spinner([&]() {
|
||||
@@ -300,7 +300,7 @@ TYPED_TEST(TestExecutors, testSpinUntilFutureCompleteWithTimeout)
|
||||
ExecutorType executor;
|
||||
executor.add_node(this->node);
|
||||
|
||||
bool spin_exited = false;
|
||||
std::atomic<bool> spin_exited = false;
|
||||
|
||||
// Needs to run longer than spin_until_future_complete's timeout.
|
||||
std::future<void> future = std::async(
|
||||
@@ -344,7 +344,7 @@ TYPED_TEST(TestExecutors, spinAll)
|
||||
|
||||
// Long timeout, but should not block test if spin_all works as expected as we cancel the
|
||||
// executor.
|
||||
bool spin_exited = false;
|
||||
std::atomic<bool> spin_exited = false;
|
||||
std::thread spinner([&spin_exited, &executor, this]() {
|
||||
executor.spin_all(1s);
|
||||
executor.remove_node(this->node, true);
|
||||
@@ -586,7 +586,7 @@ TYPED_TEST(TestExecutors, testSpinUntilFutureCompleteInterrupted)
|
||||
ExecutorType executor;
|
||||
executor.add_node(this->node);
|
||||
|
||||
bool spin_exited = false;
|
||||
std::atomic<bool> spin_exited = false;
|
||||
|
||||
// This needs to block longer than it takes to get to the shutdown call below and for
|
||||
// spin_until_future_complete to return
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include "rclcpp/detail/add_guard_condition_to_rcl_wait_set.hpp"
|
||||
#include "rclcpp/waitable.hpp"
|
||||
@@ -88,7 +89,7 @@ TestWaitable::execute(const std::shared_ptr<void> &)
|
||||
void
|
||||
TestWaitable::set_on_execute_callback(std::function<void()> on_execute_callback)
|
||||
{
|
||||
on_execute_callback_ = on_execute_callback;
|
||||
on_execute_callback_ = std::move(on_execute_callback);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -34,7 +34,9 @@ public:
|
||||
|
||||
std::shared_ptr<void> create_request() override {return nullptr;}
|
||||
std::shared_ptr<rmw_request_id_t> create_request_header() override {return nullptr;}
|
||||
void handle_request(std::shared_ptr<rmw_request_id_t>, std::shared_ptr<void>) override {}
|
||||
void handle_request(
|
||||
const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<void> &) override {}
|
||||
};
|
||||
|
||||
class TestClient : public rclcpp::ClientBase
|
||||
@@ -46,7 +48,7 @@ public:
|
||||
std::shared_ptr<void> create_response() override {return nullptr;}
|
||||
std::shared_ptr<rmw_request_id_t> create_request_header() override {return nullptr;}
|
||||
void handle_response(
|
||||
std::shared_ptr<rmw_request_id_t>, std::shared_ptr<void>) override {}
|
||||
const std::shared_ptr<rmw_request_id_t> &, const std::shared_ptr<void> &) override {}
|
||||
};
|
||||
|
||||
class TestNodeService : public ::testing::Test
|
||||
|
||||
@@ -162,7 +162,14 @@ public:
|
||||
explicit PublisherBase(const std::string & topic, const rclcpp::QoS & qos)
|
||||
: topic_name(topic),
|
||||
qos_profile(qos)
|
||||
{}
|
||||
{
|
||||
// Initialize a mock GID with unique data based on this pointer
|
||||
gid_.implementation_identifier = "mock_rmw";
|
||||
auto ptr_value = reinterpret_cast<std::uintptr_t>(this);
|
||||
for (size_t i = 0; i < RMW_GID_STORAGE_SIZE; ++i) {
|
||||
gid_.data[i] = static_cast<uint8_t>((ptr_value >> (i * 8)) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~PublisherBase()
|
||||
{}
|
||||
@@ -192,6 +199,12 @@ public:
|
||||
return qos_profile.durability() == rclcpp::DurabilityPolicy::TransientLocal;
|
||||
}
|
||||
|
||||
const rmw_gid_t &
|
||||
get_gid() const
|
||||
{
|
||||
return gid_;
|
||||
}
|
||||
|
||||
bool
|
||||
operator==([[maybe_unused]] const rmw_gid_t & gid) const
|
||||
{
|
||||
@@ -210,6 +223,7 @@ public:
|
||||
private:
|
||||
std::string topic_name;
|
||||
rclcpp::QoS qos_profile;
|
||||
rmw_gid_t gid_;
|
||||
};
|
||||
|
||||
template<typename T, typename Alloc = std::allocator<void>>
|
||||
|
||||
@@ -75,6 +75,11 @@ public:
|
||||
{
|
||||
typedef MyAllocator<U> other;
|
||||
};
|
||||
|
||||
rcl_allocator_t get_rcl_allocator()
|
||||
{
|
||||
return rcl_get_default_allocator();
|
||||
}
|
||||
};
|
||||
|
||||
// Explicit specialization for void
|
||||
@@ -102,6 +107,11 @@ public:
|
||||
{
|
||||
typedef MyAllocator<U> other;
|
||||
};
|
||||
|
||||
rcl_allocator_t get_rcl_allocator()
|
||||
{
|
||||
return rcl_get_default_allocator();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename U>
|
||||
|
||||
@@ -471,14 +471,38 @@ TEST_F(TestNode, ConfigureNodesFilterAndCheckAddParameterEventCallback)
|
||||
std::atomic_bool received_from_remote_node1{false};
|
||||
std::atomic_bool received_from_remote_node2{false};
|
||||
|
||||
// The ParameterEventHandler creates its /parameter_events subscription (with no
|
||||
// content filter) at construction time. When declare_parameter is later called on
|
||||
// remote nodes, it internally triggers set_parameter which publishes a ParameterEvent
|
||||
// with the parameter in the new_parameters field. That event arrives on the
|
||||
// already-existing, unfiltered subscription and is stored in its queue.
|
||||
// When configure_nodes_filter is subsequently called, it applies a content filter to
|
||||
// the subscription, but events already sitting in the subscriber's queue are not
|
||||
// affected. Per the DDS specification, a content-filtered topic filter applies at the
|
||||
// point of data delivery/insertion into the reader's cache. Once data is in the cache,
|
||||
// it has been "received." Retroactively purging it when the filter changes is not
|
||||
// standard behavior.
|
||||
// rmw_connextdds correctly honors this: only future incoming samples are filtered, so
|
||||
// queued declaration events would still be delivered. rmw_fastrtps_cpp may retroactively
|
||||
// apply filters to already-queued messages or deliver them lazily, causing those
|
||||
// events to be silently discarded - which is arguably incorrect but happens to make
|
||||
// naive tests pass.
|
||||
// Only track changed_parameters to ignore queued declare_parameter events.
|
||||
auto cb =
|
||||
[&remote_node_name1, &remote_node_name2, &received_from_remote_node1,
|
||||
&received_from_remote_node2]
|
||||
[&remote_node_name1, &remote_node_name2,
|
||||
&remote_node1_param_name, &remote_node2_param_name,
|
||||
&received_from_remote_node1, &received_from_remote_node2]
|
||||
(const rcl_interfaces::msg::ParameterEvent & parm) {
|
||||
if (parm.node == "/" + remote_node_name1) {
|
||||
received_from_remote_node1 = true;
|
||||
} else if (parm.node == "/" + remote_node_name2) {
|
||||
received_from_remote_node2 = true;
|
||||
for (const auto & changed_parameter : parm.changed_parameters) {
|
||||
if (parm.node == "/" + remote_node_name1 &&
|
||||
changed_parameter.name == remote_node1_param_name)
|
||||
{
|
||||
received_from_remote_node1 = true;
|
||||
} else if (parm.node == "/" + remote_node_name2 && // NOLINT(readability/braces)
|
||||
changed_parameter.name == remote_node2_param_name)
|
||||
{
|
||||
received_from_remote_node2 = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -505,7 +529,12 @@ TEST_F(TestNode, ConfigureNodesFilterAndCheckAddParameterEventCallback)
|
||||
};
|
||||
|
||||
{
|
||||
std::thread thread(wait_param_event, 1s, nullptr);
|
||||
std::thread thread(
|
||||
wait_param_event,
|
||||
3s,
|
||||
[&received_from_remote_node2]() {
|
||||
return received_from_remote_node2.load();
|
||||
});
|
||||
std::this_thread::sleep_for(100ms);
|
||||
remote_node1->set_parameter(rclcpp::Parameter(remote_node1_param_name, 20));
|
||||
remote_node2->set_parameter(rclcpp::Parameter(remote_node2_param_name, "abc"));
|
||||
@@ -562,32 +591,33 @@ TEST_F(TestNode, ConfigureNodesFilterAndCheckAddParameterCallback)
|
||||
remote_node1->declare_parameter(remote_node1_param_name, 10);
|
||||
remote_node2->declare_parameter(remote_node2_param_name, "Default");
|
||||
|
||||
// The ParameterEventHandler creates its /parameter_events subscription (with no
|
||||
// content filter) at construction time. When declare_parameter is later called on
|
||||
// remote nodes, it internally triggers set_parameter which publishes a ParameterEvent
|
||||
// with the parameter in the new_parameters field. That event arrives on the
|
||||
// already-existing, unfiltered subscription and is stored in its queue.
|
||||
// Recreate the param_handler so its new subscription starts with an empty queue,
|
||||
// avoiding interference from queued declare_parameter events.
|
||||
param_handler.reset();
|
||||
param_handler = std::make_shared<TestParameterEventHandler>(node);
|
||||
|
||||
std::atomic_bool received_from_remote_node1{false};
|
||||
std::atomic_bool received_from_remote_node2{false};
|
||||
|
||||
auto cb_remote_node1 =
|
||||
[&remote_node1_param_name, &received_from_remote_node1]
|
||||
(const rclcpp::Parameter & parm) {
|
||||
if (parm.get_name() == remote_node1_param_name) {
|
||||
received_from_remote_node1 = true;
|
||||
}
|
||||
auto cb1 = [&received_from_remote_node1](const rclcpp::Parameter &) {
|
||||
received_from_remote_node1 = true;
|
||||
};
|
||||
|
||||
auto cb_remote_node2 =
|
||||
[&remote_node2_param_name, &received_from_remote_node2]
|
||||
(const rclcpp::Parameter & parm) {
|
||||
if (parm.get_name() == remote_node2_param_name) {
|
||||
received_from_remote_node2 = true;
|
||||
}
|
||||
auto cb2 = [&received_from_remote_node2](const rclcpp::Parameter &) {
|
||||
received_from_remote_node2 = true;
|
||||
};
|
||||
|
||||
// Configure to only receive parameter events from remote_node_name2
|
||||
ASSERT_TRUE(param_handler->configure_nodes_filter({remote_node_name2}));
|
||||
|
||||
auto handler1 = param_handler->add_parameter_callback(
|
||||
remote_node1_param_name, cb_remote_node1, remote_node_name1);
|
||||
auto handler2 = param_handler->add_parameter_callback(
|
||||
remote_node2_param_name, cb_remote_node2, remote_node_name2);
|
||||
auto h1 = param_handler->add_parameter_callback(
|
||||
remote_node1_param_name, cb1, "/" + remote_node_name1);
|
||||
auto h2 = param_handler->add_parameter_callback(
|
||||
remote_node2_param_name, cb2, "/" + remote_node_name2);
|
||||
|
||||
rclcpp::executors::SingleThreadedExecutor executor;
|
||||
executor.add_node(node);
|
||||
@@ -607,7 +637,12 @@ TEST_F(TestNode, ConfigureNodesFilterAndCheckAddParameterCallback)
|
||||
};
|
||||
|
||||
{
|
||||
std::thread thread(wait_param_event, 1s, nullptr);
|
||||
std::thread thread(
|
||||
wait_param_event,
|
||||
3s,
|
||||
[&received_from_remote_node2]() {
|
||||
return received_from_remote_node2.load();
|
||||
});
|
||||
std::this_thread::sleep_for(100ms);
|
||||
remote_node1->set_parameter(rclcpp::Parameter(remote_node1_param_name, 20));
|
||||
remote_node2->set_parameter(rclcpp::Parameter(remote_node2_param_name, "abc"));
|
||||
|
||||
@@ -101,7 +101,8 @@ public:
|
||||
const std::string & action_name,
|
||||
const rosidl_action_type_support_t * type_support,
|
||||
const rcl_action_client_options_t & client_options)
|
||||
: node_graph_(node_graph),
|
||||
: context_(node_base->get_context()),
|
||||
node_graph_(node_graph),
|
||||
node_handle(node_base->get_shared_rcl_node_handle()),
|
||||
action_type_support_(type_support),
|
||||
logger(node_logging->get_logger().get_child("rclcpp_action")),
|
||||
|
||||
@@ -13,8 +13,19 @@
|
||||
# limitations under the License.
|
||||
|
||||
# register node plugins
|
||||
list(REMOVE_DUPLICATES _RCLCPP_COMPONENTS_PACKAGE_RESOURCE_INDICES)
|
||||
foreach(resource_index ${_RCLCPP_COMPONENTS_PACKAGE_RESOURCE_INDICES})
|
||||
# The internal data is stored in a project directory scoped properties to allow
|
||||
# registering the components from nested scopes in CMake, where variables
|
||||
# would not propagate out.
|
||||
get_property(_rclcpp_components_package_resource_indices
|
||||
DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
PROPERTY _RCLCPP_COMPONENTS_PACKAGE_RESOURCE_INDICES
|
||||
)
|
||||
list(REMOVE_DUPLICATES _rclcpp_components_package_resource_indices)
|
||||
foreach(resource_index ${_rclcpp_components_package_resource_indices})
|
||||
get_property(_rclcpp_components_nodes
|
||||
DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
PROPERTY "_RCLCPP_COMPONENTS_${resource_index}__NODES"
|
||||
)
|
||||
ament_index_register_resource(
|
||||
${resource_index} CONTENT "${_RCLCPP_COMPONENTS_${resource_index}__NODES}")
|
||||
${resource_index} CONTENT "${_rclcpp_components_nodes}")
|
||||
endforeach()
|
||||
|
||||
@@ -64,15 +64,19 @@ macro(rclcpp_components_register_node target)
|
||||
endif()
|
||||
set(component ${ARGS_PLUGIN})
|
||||
set(node ${ARGS_EXECUTABLE})
|
||||
_rclcpp_components_register_package_hook()
|
||||
set(_path "lib")
|
||||
set(library_name "$<TARGET_FILE_NAME:${target}>")
|
||||
if(WIN32)
|
||||
set(_path "bin")
|
||||
endif()
|
||||
set(_RCLCPP_COMPONENTS_${resource_index}__NODES
|
||||
"${_RCLCPP_COMPONENTS_${resource_index}__NODES}${component};${_path}/$<TARGET_FILE_NAME:${target}>\n")
|
||||
list(APPEND _RCLCPP_COMPONENTS_PACKAGE_RESOURCE_INDICES ${resource_index})
|
||||
set_property(
|
||||
DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
APPEND_STRING PROPERTY _RCLCPP_COMPONENTS_${resource_index}__NODES
|
||||
"${component};${_path}/$<TARGET_FILE_NAME:${target}>\n")
|
||||
set_property(
|
||||
DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
APPEND PROPERTY _RCLCPP_COMPONENTS_PACKAGE_RESOURCE_INDICES
|
||||
${resource_index})
|
||||
|
||||
if(ARGS_NO_UNDEFINED_SYMBOLS AND WIN32)
|
||||
message(WARNING "NO_UNDEFINED_SYMBOLS is enabled for target \"${target}\", but this is unsupported on windows.")
|
||||
|
||||
@@ -47,7 +47,6 @@ macro(rclcpp_components_register_nodes target)
|
||||
endif()
|
||||
|
||||
if(${ARGC} GREATER 0)
|
||||
_rclcpp_components_register_package_hook()
|
||||
set(_unique_names)
|
||||
foreach(_arg ${ARGS_UNPARSED_ARGUMENTS})
|
||||
if(_arg IN_LIST _unique_names)
|
||||
@@ -63,9 +62,14 @@ macro(rclcpp_components_register_nodes target)
|
||||
else()
|
||||
set(_path "lib")
|
||||
endif()
|
||||
set(_RCLCPP_COMPONENTS_${resource_index}__NODES
|
||||
"${_RCLCPP_COMPONENTS_${resource_index}__NODES}${_arg};${_path}/$<TARGET_FILE_NAME:${target}>\n")
|
||||
list(APPEND _RCLCPP_COMPONENTS_PACKAGE_RESOURCE_INDICES ${resource_index})
|
||||
set_property(
|
||||
DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
APPEND_STRING PROPERTY _RCLCPP_COMPONENTS_${resource_index}__NODES
|
||||
"${_arg};${_path}/$<TARGET_FILE_NAME:${target}>\n")
|
||||
set_property(
|
||||
DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
APPEND PROPERTY _RCLCPP_COMPONENTS_PACKAGE_RESOURCE_INDICES
|
||||
${resource_index})
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -25,6 +25,8 @@ macro(_rclcpp_components_register_package_hook)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
_rclcpp_components_register_package_hook()
|
||||
|
||||
get_filename_component(@PROJECT_NAME@_SHARE_DIR "${@PROJECT_NAME@_DIR}" DIRECTORY)
|
||||
set(@PROJECT_NAME@_NODE_TEMPLATE "${@PROJECT_NAME@_SHARE_DIR}/node_main.cpp.in")
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@ int main(int argc, char * argv[])
|
||||
/// Component container with a multi-threaded executor.
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
auto exec = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
|
||||
auto node = std::make_shared<rclcpp_components::ComponentManager>();
|
||||
rclcpp::executors::MultiThreadedExecutor::SharedPtr exec = nullptr;
|
||||
const auto node = std::make_shared<rclcpp_components::ComponentManager>();
|
||||
if (node->has_parameter("thread_num")) {
|
||||
const auto thread_num = node->get_parameter("thread_num").as_int();
|
||||
exec = std::make_shared<rclcpp::executors::MultiThreadedExecutor>(
|
||||
rclcpp::ExecutorOptions{}, thread_num);
|
||||
node->set_executor(exec);
|
||||
} else {
|
||||
node->set_executor(exec);
|
||||
exec = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
|
||||
}
|
||||
node->set_executor(exec);
|
||||
exec->add_node(node);
|
||||
exec->spin();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user