[ROS2] Making rclcpp::Publisher a template class [closed]
Is it possible to do that? Like
template <typename T>
class CustomerPublisher : public rclcpp::Node
{
...
typename rclcpp::Publisher<T>::SharedPtr publisher_;
}
I tried it and instantiate a CustomerPublisher<std_msgs::msg::String>
. It is able to compile, but got the following error
...undefined reference to `CustomerPublisher<std_msgs::msg::String_<std::allocator<void> > >::publish(std_msgs::msg::String_<std::allocator<void> >)'