Hi everybody i'm currently using an arduino board (MKR WAN 1300) as a ROS node, In the arduino sketch i'm using a custom message type named "RosInfo" and i want him to publish this type of msg to a topic named "/fromarduino".The message definition of RosInfo is the following;
uint32 id
uint8 lenght
uint8[] value
uint64 timestamp
the problem is that: all the fields seems to work fine but the value field is empty when i try to echo the topic in the command line:
id: 21
lenght: 2
value: []
timestamp: 1562351536
---
id: 20
lenght: 2
value: []
timestamp: 1562351536
---
In the arduino sketch i'm filling the RosInfo obj this way
ros_pkt.id = buff_toROS[tailR].id;
ros_pkt.timestamp = buff_toROS[tailR].timestamp;
ros_pkt.lenght = buff_toROS[tailR].len;
int i=0;
for(i=0; i<=ros_pkt.lenght; i++){
ros_pkt.value[i]= buff_toROS[tailR].value[i];
}
fromarduino.publish(ros_pkt);
buff_toROS is an array that i'm using like a circulare queue:
typedef struct raw_data{
unsigned char value[8];
unsigned int id;
unsigned char len;
unsigned long timestamp;
} raw_data;
unsigned char headR = 0;
unsigned char tailR = 0;
unsigned int countR = 0;
raw_data buff_toROS[10];
I literally tried as many methods as possible to fill the ros_pkt,value but no one seems to be releted to the the fact that it is empty. Hope that someone could help me. I apologize in advance if I have not asked the question correctly but it is my first on this forum. Thank you all.
Originally posted by dimaluigi on ROS Answers with karma: 3 on 2019-07-05
Post score: 0