ROSSerial Arduino Arrays
Hi All,
I'm trying to use Rosserial Arduino to process some data from a low cost laser rangefinder. Over the course of a scan I try to add the data to an array of float in arduino:
float snd_distance = getDistance(servo_pos);
distance_array[servo_pos] = snd_distance;
Then I have a function which populates the message:
void populateMessage(float distances[145]){
//Set up frame data
scanData.header.frame_id = "1";
scanData.header.seq = scanData.header.seq++;
scanData.header.stamp = nh.now();
scanData.angle_min = 0.0;
scanData.angle_max = 2.53072742;
scanData.angle_increment = 0.0174532925;
scanData.range_min = 0;
scanData.range_max = 40;
for(int i = 0; i <= 144; i++){
scanData.ranges[i] = distances[i];
}
pub_scan.publish(&scanData);
nh.spinOnce();
}
However, there seems to be a problem copying the values of distances over to scanData.ranges. I see no errors during compilation, however execution locks up at that step and I seem unable to get past it. Has anyone seen this before? Many thanks.