ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Thank you for this answer. I have modified my script regarding your advice, I still have troubles on some points :
I can't resize ranges and intensities arrays, both scan.ranges.resize(5)
and scan->ranges.resize(5)
are no accepted when compiling (not a type from sensor_msgs::LaserScan, Arduino and ROS classes are not exactly the same i guess)
After integrating the loop for populate ranges and intensities arrays, I now lost synchronisation between ROS node and Arduino :
[ERROR] [WallTime: 1493197519.087966] Lost sync with device, restarting...
I don't know how to deal with this problem. From this rosanswer, the problem seems to be that i don't call spinOnce() frequently enough. But i don't understand why the populating loop slow down the script at this point.
Here is my new Arduino script :
//populate the sonar message
scan.header.frame_id = "/ultrasound";
scan.angle_increment = 0.26; // rad
scan.angle_min = -0.52; //
scan.angle_max = 0.52;
scan.range_min = 0.0;
scan.range_max = 450.0;
//scan.ranges.resize(5);
//scan->ranges.resize(5);
time_current_scan = millis();
scan.scan_time = time_current_scan - time_previous_scan;
time_previous_scan = millis();
for (i=0;i<=5;i++){
scan.ranges[i] = val_ranges[i];
scan.intensities[i] = val_ranges[i];
}
// publish
pu.publish(&scan );
Suggestions are welcomed :)
Regards
Matthieu
2 | No.2 Revision |
Thank you for this answer. I have modified my script regarding your advice, I still have troubles on some points :
I can't resize ranges and intensities arrays, both scan.ranges.resize(5)
and scan->ranges.resize(5)
are no accepted when compiling (not a type from sensor_msgs::LaserScan, Arduino and ROS classes are not exactly the same i guess)
After integrating the loop for populate ranges and intensities arrays, I now lost synchronisation between ROS node and Arduino :
[ERROR] [WallTime: 1493197519.087966] Lost sync with device, restarting...
I don't know how to deal with this problem. From this rosanswer, the problem seems to be that i don't call spinOnce() frequently enough. But i don't understand why the populating loop slow down the script at this point.
Here is my new Arduino script :
//populate the sonar message
scan.header.frame_id = "/ultrasound";
scan.angle_increment = 0.26; // rad
scan.angle_min = -0.52; //
scan.angle_max = 0.52;
scan.range_min = 0.0;
scan.range_max = 450.0;
//scan.ranges.resize(5);
//scan->ranges.resize(5);
time_current_scan = millis();
scan.scan_time = time_current_scan - time_previous_scan;
time_previous_scan = millis();
for (i=0;i<=5;i++){
(i=0;i<=4;i++){
scan.ranges[i] = val_ranges[i];
scan.intensities[i] = val_ranges[i];
}
// publish
pu.publish(&scan );
Suggestions are welcomed :)
Regards
Matthieu