no instance of overloaded function "rosidl_runtime_cpp::BoundedVector<Tp, UpperBound, Alloc>::data [with ...]" matches the argument listC/C++(304)
ROS2 Humble
I am working with custom message interface (Data.msg): byte[<=1024] data_packet
Now I want to get the data from the topic in a callback:
void callback(custom_interfaces::msg::Data::SharedPtr msg)
{
auto x = msg->data_packet.data();
}
But I get this error message:
no instance of overloaded function "rosidlruntimecpp::BoundedVector
::data [with Tp=unsigned char, UpperBound=1024UL, Alloc=std::allocator ]" matches the argument listC/C++(304)
and compilation error:
error: no matching function for call to ‘rosidl_runtime_cpp::BoundedVector<unsigned char, 1024, std::allocator<unsigned char> >::data()’
21 | auto x = msg->data_packet.data();
I can get to the contents though like this:
std::vector<unsigned char> data(msg->data_packet.begin(), msg->data_packet.end());
So this is not a very big problem, but it would be very convenient to having to create new variable each time I need to read this data.
Asked by magladko on 2023-07-04 14:43:41 UTC
Comments