ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Setup Int32MultiArray in micro-ROS arduino library (ROS2) [closed]

asked 2021-05-09 17:11:03 -0500

B00M3R gravatar image

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.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by B00M3R
close date 2021-05-10 15:58:26.617684

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-10 02:44:04 -0500

Pablogs gravatar image

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.

edit flag offensive delete link more

Comments

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

B00M3R gravatar image B00M3R  ( 2021-05-10 16:08:04 -0500 )edit

Hi, I am having issues subscribing to the Int64MultiArray msgs. have you tried it. if yes could you please share the code

Sarwan gravatar image Sarwan  ( 2021-08-23 09:05:35 -0500 )edit
Pablogs gravatar image Pablogs  ( 2021-08-24 00:49:07 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-05-09 17:11:03 -0500

Seen: 978 times

Last updated: May 10 '21