0
$\begingroup$

Rosanswers logo

Hi there. I just started with ROS2 and I'm trying to send a couple of sensor datas form my microcontroller to my ROS2 system using the micro-ROS library in the arduino IDE --> C++. Can someone give me an example how to setup an Int32MultiArray in the micro-ROS arduino library (ROS2)? I'm struggeling a lot. So basically I'd like to send an 2x5 Array of int32.


Originally posted by B00M3R on ROS Answers with karma: 3 on 2021-05-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

When dealing with sequences in micro-ROS you have to assign memory and set capacity and size. An example here.

If you need detailed information, please open an issue in the Github repo and share your code.


Originally posted by Pablogs with karma: 443 on 2021-05-10

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by B00M3R on 2021-05-10:
Thanks Pablo,

this was the right hint I needed.

//DummyData

uint32_t senors [2][5] = {{1,2,3,4,5},{6,7,8,9,10}};

std_msgs__msg__Int32MultiArray * msg_sensors; msg_sensors = std_msgs__msg__Int32MultiArray__create();

msg_sensors->layout.dim.data = (std_msgs__msg__MultiArrayDimension*)malloc(2sizeof(std_msgs__msg__MultiArrayDimension));
msg_sensors->data.data = (int32_t
)malloc(sizeof(senors)); msg_sensors->data.capacity = 1; msg_sensors->data.size = sizeof(senors)/sizeof(int32_t); memcpy(msg_sensors->data.data , senors, sizeof(senors));

rcl_publish(&pub_Encoder, msg_sensors, NULL);

*sorry but the code formating doesn't work

Comment by Sarwan on 2021-08-23:
Hi, I am having issues subscribing to the Int64MultiArray msgs. have you tried it. if yes could you please share the code

Comment by Pablogs on 2021-08-24:
Answered here: https://github.com/micro-ROS/micro_ros_arduino/issues/413

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.