Micro-ROS Arduino std_msgs array example needed
I'm using the arduino IDE to program a Teensy with micro-ros and want to publish a topic of type std_msgs__msg__Float32MultiArray (or std_msgs__msg__Int32MultiArray or other similar array type)
I cannot find any example code of the array formats from which to work from. I've tried to pull the below from snippets (for example https://answers.ros.org/question/3780...), and while the below code currently compiles, it does not run successfully on the teensy.
It could be as simple a misinformed malloc, or there may be something completely wrong in my approach.
Any assistance welcome, although a working example using micro-ros std arrays would be extremely useful
Cheers! Woody
std_msgs__msg__Float32MultiArray * msg_Temperatures2=std_msgs__msg__Float32MultiArray__create();
float allTemps[4]={0.,0.,0.,0.};
msg_Temperatures2->layout.dim.data = (std_msgs__msg__MultiArrayDimension*)malloc(sizeof(std_msgs__msg__MultiArrayDimension));
msg_Temperatures2->data.data = (float*)malloc(sizeof(allTemps));
msg_Temperatures2->data.capacity = 1;
msg_Temperatures2->data.size = sizeof(allTemps)/sizeof(float);
memcpy(msg_Temperatures2->data.data , allTemps, sizeof(allTemps));
RCSOFTCHECK(rcl_publish(&publisher_Temperatures, &msg_Temperatures2, NULL));