part of sting sent from arduino to ros is missed [closed]
part of arduino code:
void loop(){
String ang = String(angle);//angle is global value
String dis = String(myLidarLite.distance()); //myLidarLite.distance() is API function to get distance data
String total = ang+'a'+ dis;
int len = total.length();
char toROS[len-1];
total.toCharArray(toROS, len);
scan.data = toROS; //std_msgs::String scan;
LIDAR.publish (&scan); //ros::Publisher LIDAR("Lidar_raw", &scan);
nh.spinOnce(); //ros::NodeHandle nh;
delay(5);
}
I observed the output of this rostopic:
... data: 76b66
--- data: 103b48
--- data: 134b50
--- data: 163b61
--- data: 193b34
--- data: 227b9
--- data: 248b8
--- data: 271b69
--- data: 296b
--- data: 325b54
...
The dis is missing in some data, I try to output this format string in Serial Monitor and it's right. It just random missed.. Any suggestions will be appreciate.