How to publish a two-dimensional array msg with int8 type?
I now have a two-dimensional array of size nxn where n < 10 with int8 or int16 type array elements. I need to publish this array to a topic. I defined my own msg header, a simple int8 type msg such as the following:
int8 num
Can I do something like this: Let's say A is a two-dimensional array A = [1 2; 1 3];
ros::Publisher pub = n.advertise<test1::int8>("Chatter", 1000);
pub.publish(A);
In the callback function of the subscriber:
void chatterCallback(const test1::num& msg)
{
ROS_INFO(...);
}
Is there any problem with this approach?