clean up publisher and subscription creation logic (#867)
* streamline creation of publishers after removing deprecated API Signed-off-by: William Woodall <william@osrfoundation.org> * use deduced template arguments to cleanup create_subscription Signed-off-by: William Woodall <william@osrfoundation.org> * add missing file Signed-off-by: William Woodall <william@osrfoundation.org> * streamline creation of subscriptions after removing deprecated API Signed-off-by: William Woodall <william@osrfoundation.org> * small subscription code cleanup to match publisher's style Signed-off-by: William Woodall <william@osrfoundation.org> * some fixes to rclcpp_lifecycle to match rclcpp Signed-off-by: William Woodall <william@osrfoundation.org> * add README to the rclcpp/detail include directory Signed-off-by: William Woodall <william@osrfoundation.org> * fixup SubscriptionBase's use of visibility macros Signed-off-by: William Woodall <william@osrfoundation.org> * reapply function to create default options, as it is still needed on Windows Signed-off-by: William Woodall <william@osrfoundation.org> * address review comments Signed-off-by: William Woodall <william@osrfoundation.org> * workaround cppcheck 1.89 syntax error Signed-off-by: William Woodall <william@osrfoundation.org>
This commit is contained in:
parent
7728d8a38c
commit
81049c42c0
22 changed files with 381 additions and 297 deletions
|
@ -166,8 +166,9 @@ public:
|
|||
create_publisher(
|
||||
const std::string & topic_name,
|
||||
const rclcpp::QoS & qos,
|
||||
const PublisherOptionsWithAllocator<AllocatorT> & options =
|
||||
create_default_publisher_options<AllocatorT>()
|
||||
const PublisherOptionsWithAllocator<AllocatorT> & options = (
|
||||
create_default_publisher_options<AllocatorT>()
|
||||
)
|
||||
);
|
||||
|
||||
/// Create and return a Subscription.
|
||||
|
@ -179,15 +180,17 @@ public:
|
|||
* \param[in] msg_mem_strat The message memory strategy to use for allocating messages.
|
||||
* \return Shared pointer to the created subscription.
|
||||
*/
|
||||
/* TODO(jacquelinekay):
|
||||
Windows build breaks when static member function passed as default
|
||||
argument to msg_mem_strat, nullptr is a workaround.
|
||||
*/
|
||||
template<
|
||||
typename MessageT,
|
||||
typename CallbackT,
|
||||
typename AllocatorT = std::allocator<void>,
|
||||
typename SubscriptionT = rclcpp::Subscription<MessageT, AllocatorT>>
|
||||
typename CallbackMessageT =
|
||||
typename rclcpp::subscription_traits::has_message_type<CallbackT>::type,
|
||||
typename SubscriptionT = rclcpp::Subscription<MessageT, AllocatorT>,
|
||||
typename MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<
|
||||
CallbackMessageT,
|
||||
AllocatorT
|
||||
>>
|
||||
std::shared_ptr<SubscriptionT>
|
||||
create_subscription(
|
||||
const std::string & topic_name,
|
||||
|
@ -195,10 +198,10 @@ public:
|
|||
CallbackT && callback,
|
||||
const SubscriptionOptionsWithAllocator<AllocatorT> & options =
|
||||
create_default_subscription_options<AllocatorT>(),
|
||||
typename rclcpp::message_memory_strategy::MessageMemoryStrategy<
|
||||
typename rclcpp::subscription_traits::has_message_type<CallbackT>::type, AllocatorT
|
||||
>::SharedPtr
|
||||
msg_mem_strat = nullptr);
|
||||
typename MessageMemoryStrategyT::SharedPtr msg_mem_strat = (
|
||||
MessageMemoryStrategyT::create_default()
|
||||
)
|
||||
);
|
||||
|
||||
/// Create a timer.
|
||||
/**
|
||||
|
|
|
@ -59,16 +59,16 @@ template<
|
|||
typename MessageT,
|
||||
typename CallbackT,
|
||||
typename AllocatorT,
|
||||
typename SubscriptionT>
|
||||
typename CallbackMessageT,
|
||||
typename SubscriptionT,
|
||||
typename MessageMemoryStrategyT>
|
||||
std::shared_ptr<SubscriptionT>
|
||||
LifecycleNode::create_subscription(
|
||||
const std::string & topic_name,
|
||||
const rclcpp::QoS & qos,
|
||||
CallbackT && callback,
|
||||
const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & options,
|
||||
typename rclcpp::message_memory_strategy::MessageMemoryStrategy<
|
||||
typename rclcpp::subscription_traits::has_message_type<CallbackT>::type, AllocatorT>::SharedPtr
|
||||
msg_mem_strat)
|
||||
typename MessageMemoryStrategyT::SharedPtr msg_mem_strat)
|
||||
{
|
||||
return rclcpp::create_subscription<MessageT>(
|
||||
*this,
|
||||
|
|
|
@ -43,8 +43,7 @@ public:
|
|||
|
||||
/// brief child class of rclcpp Publisher class.
|
||||
/**
|
||||
* Overrides all publisher functions to check for
|
||||
* enabled/disabled state.
|
||||
* Overrides all publisher functions to check for enabled/disabled state.
|
||||
*/
|
||||
template<typename MessageT, typename Alloc = std::allocator<void>>
|
||||
class LifecyclePublisher : public LifecyclePublisherInterface,
|
||||
|
@ -61,11 +60,9 @@ public:
|
|||
LifecyclePublisher(
|
||||
rclcpp::node_interfaces::NodeBaseInterface * node_base,
|
||||
const std::string & topic,
|
||||
const rcl_publisher_options_t & publisher_options,
|
||||
const rclcpp::PublisherEventCallbacks event_callbacks,
|
||||
std::shared_ptr<MessageAlloc> allocator)
|
||||
: rclcpp::Publisher<MessageT, Alloc>(
|
||||
node_base, topic, publisher_options, event_callbacks, allocator),
|
||||
const rclcpp::QoS & qos,
|
||||
const rclcpp::PublisherOptionsWithAllocator<Alloc> & options)
|
||||
: rclcpp::Publisher<MessageT, Alloc>(node_base, topic, qos, options),
|
||||
enabled_(false),
|
||||
logger_(rclcpp::get_logger("LifecyclePublisher"))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue