create_subscription error

asked 2020-09-13 15:25:40 -0500

Mircea Ispas gravatar image

I have the following code to create a new subscription:

std::function<void(const std_msgs::msg::String::SharedPtr message)> ros2Callback = [callback](const std_msgs::msg::String::SharedPtr message)
{
    callback(message->data);
};

auto ros2Subscription = m_ros2Node->create_subscription<std_msgs::msg::String>(topic, 10, ros2Callback);

This doesn't compile with Visual Studio 2019 - error:

Error C2280
std::shared_ptr<rclcpp::Subscription<CallbackMessageT,AllocatorT,rclcpp::message_memory_strategy::MessageMemoryStrategy<CallbackMessageT,AllocatorT>>> std::dynamic_pointer_cast<SubscriptionT,_Ty>(const std::shared_ptr<_Ty> &) noexcept': attempting to reference a deleted function
ros2-windows\include\rclcpp\create_subscription.hpp: 148

Can you please help me to solve this?

edit retag flag offensive close merge delete