'ROS2: how to create an Int8MultiArray

This is a ROS2 beginner question

I've tried to use several ROS sources which suggested me to include "std_msgs/Int8MultiArray.h". However, if I do that I will get an error that is

fatal error: std_msgs/Int8MultiArray: No such file or directory
compilation terminated

What is the correct way to use array-like structure in ROS2? If there is a similar hpp header, where should I reference it?

Thank you! Any advice will be greatly appreciated!!!



Solution 1:[1]

Are you using ROS1 or ROS2 and what are your sources written for? The error you gave is in the format of a ROS1 message. If you're trying to import a ROS2 message it should look like this:

#include "std_msgs/msg/UInt8MultiArray"

Notice that there is an extra msg directory that isn't present for ROS1 messages.

Solution 2:[2]

You have to include this in your code to work :

#include "std_msgs/msg/u_int8_multi_array.hpp"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BTables
Solution 2 Anish B.